SlideShare a Scribd company logo
Managing PostgreSQL with Puppet
CCBYSA-NC http://www.flickr.com/photos/urgetopunt/7876067126/
Steve Singer
ssinger@ca.afilias.info
Who is Steve?
● Slony maintainer
● Database Developer @ Afilias (Toronto)
http://www.flickr.com/photos/obis/2639893609/
Registrars
DNS
Lookup
100+ of Databases
http://www.flickr.com/photos/getbutterfly/6317955134
Technologies
DevOps
Deployment Automation
http://www.nasa.gov/mission_pages/station/multimedia/gallery/iss034e037352.html
Goals of Automation: Database
servers 'look' the same
http://www.flickr.com/photos/oskay/265900118
Consistency between QA, Staging,
Production
http://www.flickr.com/photos/tempest/130084735
Reduce Manual Commands
Puppet
http://puppetlabs.com
Puppet Architecture
Puppetmaster
Computer
Puppet agent
Computer
Puppet agent
Computer
Puppet agent
Puppet Terminology
class pgsql
puppetmaster catalog
class slony
Node definition
Puppet Class
class postgresql {
package { 'postgresql-server' :
ensure => installed,
provider => 'yum'
}
}
resource
Resource Type
Declarative
file { '/tmp/hello_world.txt' :
content => 'Welcome to Chicago',
owner => 'pgopen',
mode => 0644
}
/tmp/hello_world.txt
Welcome to Chicago
Puppet At Afilias
PuppetMaster
LDAP
(ENC)
Goals for Databases
● Deploy Binaries
● Manage pg_hba.conf and postgresq.conf
● Manage postgres unix users
● Handle init db
● Manage Crontabs
● Manage slons and slonik preambles
PostgreSQL Module
https://github.com/puppetlabs/puppet-postgresql
● Pre-existing module for managing postgresql
● Manages installing, start/stopping postgresql
● We don't actually use it
pgsql_cluster resource
define pgsql_cluster ($clustername,$port,$datadir,
$conf_template,$listen_address,$pguser,
$pghba_template,$service_name,$pguser_password,$encoding)
{
...
}
• One instance per database $datadir
• Performs initdb
• Deploys postgresql.conf
• Deploys pg_hba.conf
• Creates standard database users
postgresql.conf.erb
#------------------------------------------------------------------------------
# RESOURCE USAGE (except WAL)
#------------------------------------------------------------------------------
# - Memory -
shared_buffers = <%= shared_buffers %> # min 128kB
# (change requires restart)
Templates
postgresql.conf
#------------------------------------------------------------------------------
# RESOURCE USAGE (except WAL)
#------------------------------------------------------------------------------
# - Memory -
shared_buffers = 300MB # min 128kB
# (change requires restart)
Templates
postgresql.conf
$shared_buffers= '300MB'
$conf_template='dba/postgresql.91.conf.erb'
file { "${pg_datadir}/postgresql.conf" :
owner => "$pguser",
group => postgres,
mode => 644,
require => Exec["${name}_initdb"],
content => template("$conf_template"),
}
• $
listen_addresses and facter
Puppet master Database Server
Puppet agent
facterFacts
$::ipaddress_eth0
listen_address= '<%= scope.lookupvar('::ipaddress_eth0') %>'
Hiera 101
Separate Code From Data
http://commons.wikimedia.org/wiki/File:Lower_Antelope_Canyon_478.jpg
By Uploaded by Meckimac [GFDL (http://www.gnu.org/copyleft/fdl.html) or CC-BY-SA-3.0 (http://creativecommons.org/licenses/by-sa/3.0/)],
via Wikimedia Commons
Hiera 101: Lookup Values
class db_server {
$application='postgres'
$product='billing'
$port = hiera('port')
.
.
}
Hiera 101: Define a Hierarchy
--
:hierarchy:
-domains/%{domain}/%{fqdn}/%{application}
-domains/%{domain}/%{application}/
-environment_type/%{environment_type}/%{application}
-complexes/%{product}/%{application}
Hiera 101: Hierarchy
domains/tor.afilias-int.info/db1.tor.afilias-int.info
postgres.yaml
db2.tor.afilias-int.info
postgres.yaml
environment_type
/QA
postgres.yaml
PRODUCTION
postgres.yaml
products
billing
postgres.yaml
wiki
postgres.yaml
Hiera 101: postgres.yaml
port : 5432
postgres_pgversion : '9.2.4'
postgres_unixuser : postgres
postgres_db_list :
pgopen : ssinger
pgeu : jwieck
conf template server type
postgresql.90.small.conf.erb
postgresql.91.small.conf.erb
postgresql.92.small.conf.erb
postgresql.90.oltp.conf.erb
postgresql.91.oltp.conf.erb
postgresql.92.oltp.conf.erb
postgresql.90.batch.conf.erb
postgresql.91.batch.conf.erb
postgresql.92.batch.conf.erb
Switch Based Config
postgresql.90.conf.erb
postgresql.92.conf.erb
shared_buffers = <%= shared buffers %>
max_connections = <%= max_connections %>
postgresql.91.conf.erb
shared_buffers = <%= shared buffers %>
max_connections = <%= max_connections %>
shared_buffers = <%= shared buffers %>
max_connections = <%= max_connections %>
Crontabs
cron { “backup_${name}” :
command => “ /opt/dbs/scripts/backup.sh $clustername”,
user => 'postgres',
hour => '0',
minute => '0',
ensure => 'present'
}
Slony
cluster name = mydbcluster
node 9181 admin conninfo = 'host=db1.on1 user=slony'
node 9182 admin conninfo = 'host=db2.on1 user=slony'
set add table ( id =1 , fully qualified name = 'public.foo' );
Slony Settings
# YAML for the slons running on a particular server
postgres_slons:
- 9181
# YAML map of connection data to all slons
postgres_slon_nodes:
'9181':
'host': 'db1.on1.afilias-int.info'
'port' : '5432'
'9192':
'host': 'db2.tx1.afilias-int.info'
'port' : '5432'
Slony: Slonik preambles
cluster name=<%= clustername %>;
# A slonik preamble that defines
# the 'node xxx admin conninfo...' data
# and an associated DEFINE for each
# node in the cluster
#
<% slon_conf.each do | node_id, values | %>
<% port=values['port']
if port==nil or port==''
port=complex_port
end %>
node <%= node_id %> admin conninfo='host=<%= values['host'] %> ......
define CONNINFO_<%= node_id %> 'host=<%= values['host'] %> .....
<% end %>
/opt/configs/$clustername/slonik.preamble :
slonik_preamble.erb
Removing Things
class db_node {
.
.
}
class db_node::remove {
file { “$datadir”,
ensure => 'absent',
force => true,
Backup => false
}
.
.
}
pg_basebackup
if($datadir_restore_command) {
exec { "${name}_initdb" :
command => $datadir_restore_command,
unless => "/usr/bin/test -d ${pg_datadir}/base"
...
}
}
else {
exec {"${name}_initdb" :
command => /usr/bin/initdb -D ${pg_datadir}
unless => "/usr/bin/test -d ${pg_datadir}/base"
}
}
Working with others
Photo:: thegoldguys.blogspot.com
Questions?
CCBYSA http://commons.wikimedia.org/wiki/File:Wayang_kulit_elephant_01B.jpg
http://puppetlabs.com
ssinger@ca.afilias.info

More Related Content

What's hot (19)

PDF
ZooKeeper - wait free protocol for coordinating processes
Julia Proskurnia
 
PDF
Transforming the Ceph Integration Tests with OpenStack
Ceph Community
 
PPT
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...
SaltStack
 
PDF
[오픈소스컨설팅] EFK Stack 소개와 설치 방법
Open Source Consulting
 
PDF
SaltConf14 - Ryan Lane, Wikimedia - Immediate consistency with Trebuchet Depl...
SaltStack
 
PDF
Chef & OpenStack: OSCON 2014
Matt Ray
 
PDF
The SaltStack Pub Crawl - Fosscomm 2016
effie mouzeli
 
PPT
Python Deployment with Fabric
andymccurdy
 
PDF
TXLF: Chef- Software Defined Infrastructure Today & Tomorrow
Matt Ray
 
PDF
[OpenInfra Days Korea 2018] Day 2 - E6 - OpenInfra monitoring with Prometheus
OpenStack Korea Community
 
PDF
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Puppet
 
PDF
Introduction to ZooKeeper - TriHUG May 22, 2012
mumrah
 
PDF
Etcd- Mission Critical Key-Value Store
CoreOS
 
PDF
Enjoying k8s cluster with Minikube and Helm
ロフト くん
 
PDF
Trevor McDonald - Nagios XI Under The Hood
Nagios
 
PPTX
Vagrant, Ansible, and OpenStack on your laptop
Lorin Hochstein
 
PDF
Chef 11 Preview/Chef for OpenStack
Matt Ray
 
PPTX
Serverspec and Sensu - Testing and Monitoring collide
m_richardson
 
PDF
SaltConf14 - Forrest Alvarez, Choice Hotels - Salt Formulas and States
SaltStack
 
ZooKeeper - wait free protocol for coordinating processes
Julia Proskurnia
 
Transforming the Ceph Integration Tests with OpenStack
Ceph Community
 
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...
SaltStack
 
[오픈소스컨설팅] EFK Stack 소개와 설치 방법
Open Source Consulting
 
SaltConf14 - Ryan Lane, Wikimedia - Immediate consistency with Trebuchet Depl...
SaltStack
 
Chef & OpenStack: OSCON 2014
Matt Ray
 
The SaltStack Pub Crawl - Fosscomm 2016
effie mouzeli
 
Python Deployment with Fabric
andymccurdy
 
TXLF: Chef- Software Defined Infrastructure Today & Tomorrow
Matt Ray
 
[OpenInfra Days Korea 2018] Day 2 - E6 - OpenInfra monitoring with Prometheus
OpenStack Korea Community
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Puppet
 
Introduction to ZooKeeper - TriHUG May 22, 2012
mumrah
 
Etcd- Mission Critical Key-Value Store
CoreOS
 
Enjoying k8s cluster with Minikube and Helm
ロフト くん
 
Trevor McDonald - Nagios XI Under The Hood
Nagios
 
Vagrant, Ansible, and OpenStack on your laptop
Lorin Hochstein
 
Chef 11 Preview/Chef for OpenStack
Matt Ray
 
Serverspec and Sensu - Testing and Monitoring collide
m_richardson
 
SaltConf14 - Forrest Alvarez, Choice Hotels - Salt Formulas and States
SaltStack
 

Viewers also liked (20)

PDF
PostgreSQL replication from setup to advanced features.
Pivorak MeetUp
 
PPTX
MySQL Multi Master Replication
Moshe Kaplan
 
PDF
Bruce Momjian - Inside PostgreSQL Shared Memory @ Postgres Open
PostgresOpen
 
PDF
Puppi. Puppet strings to the shell
Alessandro Franceschi
 
PDF
Technical Introduction to PostgreSQL and PPAS
Ashnikbiz
 
PDF
Gurjeet Singh - How Postgres is Different From (Better Tha) Your RDBMS @ Post...
PostgresOpen
 
PDF
Keith Fiske - When PostgreSQL Can't, You Can @ Postgres Open
PostgresOpen
 
PDF
Ryan Jarvinen Open Shift Talk @ Postgres Open 2013
PostgresOpen
 
PDF
Kevin Kempter - PostgreSQL Backup and Recovery Methods @ Postgres Open
PostgresOpen
 
PPTX
David Keeney - SQL Database Server Requests from the Browser @ Postgres Open
PostgresOpen
 
PDF
Keith Paskett - Postgres on ZFS @ Postgres Open
PostgresOpen
 
PDF
Henrietta Dombrovskaya - A New Approach to Resolve Object-Relational Impedanc...
PostgresOpen
 
PDF
Selena Deckelmann - Sane Schema Management with Alembic and SQLAlchemy @ Pos...
PostgresOpen
 
PDF
Islamabad PUG - 7th Meetup - performance tuning
Umair Shahid
 
PDF
Islamabad PUG - 7th meetup - performance tuning
Umair Shahid
 
PDF
Robert Haas Query Planning Gone Wrong Presentation @ Postgres Open
PostgresOpen
 
PDF
Out of the box replication in postgres 9.4(pg confus)
Denish Patel
 
PDF
Michael Bayer Introduction to SQLAlchemy @ Postgres Open
PostgresOpen
 
PDF
PoPostgreSQL Web Projects: From Start to FinishStart To Finish
elliando dias
 
PDF
Koichi Suzuki - Postgres-XC Dynamic Cluster Management @ Postgres Open
PostgresOpen
 
PostgreSQL replication from setup to advanced features.
Pivorak MeetUp
 
MySQL Multi Master Replication
Moshe Kaplan
 
Bruce Momjian - Inside PostgreSQL Shared Memory @ Postgres Open
PostgresOpen
 
Puppi. Puppet strings to the shell
Alessandro Franceschi
 
Technical Introduction to PostgreSQL and PPAS
Ashnikbiz
 
Gurjeet Singh - How Postgres is Different From (Better Tha) Your RDBMS @ Post...
PostgresOpen
 
Keith Fiske - When PostgreSQL Can't, You Can @ Postgres Open
PostgresOpen
 
Ryan Jarvinen Open Shift Talk @ Postgres Open 2013
PostgresOpen
 
Kevin Kempter - PostgreSQL Backup and Recovery Methods @ Postgres Open
PostgresOpen
 
David Keeney - SQL Database Server Requests from the Browser @ Postgres Open
PostgresOpen
 
Keith Paskett - Postgres on ZFS @ Postgres Open
PostgresOpen
 
Henrietta Dombrovskaya - A New Approach to Resolve Object-Relational Impedanc...
PostgresOpen
 
Selena Deckelmann - Sane Schema Management with Alembic and SQLAlchemy @ Pos...
PostgresOpen
 
Islamabad PUG - 7th Meetup - performance tuning
Umair Shahid
 
Islamabad PUG - 7th meetup - performance tuning
Umair Shahid
 
Robert Haas Query Planning Gone Wrong Presentation @ Postgres Open
PostgresOpen
 
Out of the box replication in postgres 9.4(pg confus)
Denish Patel
 
Michael Bayer Introduction to SQLAlchemy @ Postgres Open
PostgresOpen
 
PoPostgreSQL Web Projects: From Start to FinishStart To Finish
elliando dias
 
Koichi Suzuki - Postgres-XC Dynamic Cluster Management @ Postgres Open
PostgresOpen
 
Ad

Similar to Steve Singer - Managing PostgreSQL with Puppet @ Postgres Open (20)

PDF
Oracle to Postgres Migration - part 2
PgTraining
 
PDF
Writing & Sharing Great Modules on the Puppet Forge
Puppet
 
KEY
Grabbing the PostgreSQL Elephant by the Trunk
Harold Giménez
 
ODP
GUC Tutorial Package (9.0)
PostgreSQL Experts, Inc.
 
PPTX
NLIT 2011: Chef & Capistrano
nickblah
 
PDF
Nuvola: a tale of migration to AWS
Matteo Moretti
 
KEY
Cooking with Chef
Ken Robertson
 
PDF
Development Setup of B-Translator
Dashamir Hoxha
 
PPTX
Deployment with Fabric
andymccurdy
 
PDF
Deploying Rails Applications with Capistrano
Almir Mendes
 
ODP
MySQL 101 PHPTek 2017
Dave Stokes
 
PDF
Testing with PostgreSQL
Shawn Sorichetti
 
PDF
Scaling Mapufacture on Amazon Web Services
Andrew Turner
 
PDF
Postgres Vienna DB Meetup 2014
Michael Renner
 
PPTX
Ansible introduction uses how to install and how to usepptx
tamilarasi05
 
PDF
From Zero to Hero - Centralized Logging with Logstash & Elasticsearch
Sematext Group, Inc.
 
PDF
From zero to hero - Easy log centralization with Logstash and Elasticsearch
Rafał Kuć
 
PDF
Perl Programming - 04 Programming Database
Danairat Thanabodithammachari
 
PDF
The Accidental DBA
PostgreSQL Experts, Inc.
 
PPT
Why and How Powershell will rule the Command Line - Barcamp LA 4
Ilya Haykinson
 
Oracle to Postgres Migration - part 2
PgTraining
 
Writing & Sharing Great Modules on the Puppet Forge
Puppet
 
Grabbing the PostgreSQL Elephant by the Trunk
Harold Giménez
 
GUC Tutorial Package (9.0)
PostgreSQL Experts, Inc.
 
NLIT 2011: Chef & Capistrano
nickblah
 
Nuvola: a tale of migration to AWS
Matteo Moretti
 
Cooking with Chef
Ken Robertson
 
Development Setup of B-Translator
Dashamir Hoxha
 
Deployment with Fabric
andymccurdy
 
Deploying Rails Applications with Capistrano
Almir Mendes
 
MySQL 101 PHPTek 2017
Dave Stokes
 
Testing with PostgreSQL
Shawn Sorichetti
 
Scaling Mapufacture on Amazon Web Services
Andrew Turner
 
Postgres Vienna DB Meetup 2014
Michael Renner
 
Ansible introduction uses how to install and how to usepptx
tamilarasi05
 
From Zero to Hero - Centralized Logging with Logstash & Elasticsearch
Sematext Group, Inc.
 
From zero to hero - Easy log centralization with Logstash and Elasticsearch
Rafał Kuć
 
Perl Programming - 04 Programming Database
Danairat Thanabodithammachari
 
The Accidental DBA
PostgreSQL Experts, Inc.
 
Why and How Powershell will rule the Command Line - Barcamp LA 4
Ilya Haykinson
 
Ad

More from PostgresOpen (6)

PDF
Craig Kerstiens - Scalable Uniques in Postgres @ Postgres Open
PostgresOpen
 
PDF
John Melesky - Federating Queries Using Postgres FDW @ Postgres Open
PostgresOpen
 
PDF
Robert Bernier - Recovering From A Damaged PostgreSQL Cluster @ Postgres Open
PostgresOpen
 
PDF
Michael Paquier - Taking advantage of custom bgworkers @ Postgres Open
PostgresOpen
 
PDF
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
PostgresOpen
 
PDF
Andrew Dunstan 9.3 JSON Presentation @ Postgres Open 2013
PostgresOpen
 
Craig Kerstiens - Scalable Uniques in Postgres @ Postgres Open
PostgresOpen
 
John Melesky - Federating Queries Using Postgres FDW @ Postgres Open
PostgresOpen
 
Robert Bernier - Recovering From A Damaged PostgreSQL Cluster @ Postgres Open
PostgresOpen
 
Michael Paquier - Taking advantage of custom bgworkers @ Postgres Open
PostgresOpen
 
Kevin Kempter PostgreSQL Backup and Recovery Methods @ Postgres Open
PostgresOpen
 
Andrew Dunstan 9.3 JSON Presentation @ Postgres Open 2013
PostgresOpen
 

Recently uploaded (20)

PDF
Market Wrap for 18th July 2025 by CIFDAQ
CIFDAQ
 
PPTX
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
PPTX
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
PPTX
The Yotta x CloudStack Advantage: Scalable, India-First Cloud
ShapeBlue
 
PDF
Integrating IIoT with SCADA in Oil & Gas A Technical Perspective.pdf
Rejig Digital
 
PPTX
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
PDF
How Current Advanced Cyber Threats Transform Business Operation
Eryk Budi Pratama
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PDF
introduction to computer hardware and sofeware
chauhanshraddha2007
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
PDF
Alpha Altcoin Setup : TIA - 19th July 2025
CIFDAQ
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PDF
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Lecture A - AI Workflows for Banking.pdf
Dr. LAM Yat-fai (林日辉)
 
Market Wrap for 18th July 2025 by CIFDAQ
CIFDAQ
 
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
The Yotta x CloudStack Advantage: Scalable, India-First Cloud
ShapeBlue
 
Integrating IIoT with SCADA in Oil & Gas A Technical Perspective.pdf
Rejig Digital
 
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
How Current Advanced Cyber Threats Transform Business Operation
Eryk Budi Pratama
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
introduction to computer hardware and sofeware
chauhanshraddha2007
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
Alpha Altcoin Setup : TIA - 19th July 2025
CIFDAQ
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
The Future of Artificial Intelligence (AI)
Mukul
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Lecture A - AI Workflows for Banking.pdf
Dr. LAM Yat-fai (林日辉)
 

Steve Singer - Managing PostgreSQL with Puppet @ Postgres Open