SlideShare a Scribd company logo
1 of 42
Download to read offline
;
PostgreSQL 9.0 HA
Julien Pivotto
April, 1 2012 @ Loadays
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
The mission
Before the migration
Table of content
1 Overview
The mission
Before the migration
2 PostgreSQL 9.0
Intro
Streaming replication
Master conļ¬guration
Slave conļ¬guration
PostgreSQL speciļ¬c tricks
Setting up a slave
3 Clustering
Set up of corosync
OCF resource
4 Backups
Cron jobs
BackupPC
5 Monitoring
Nagios
Munin
6 Automation
Puppet module
The node ļ¬le
#TODO
7 The end
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
The mission
Before the migration
Who am I
ā€¢ Julien Pivotto
ā€¢ Consultant at Inuits since May 2011
ā€¢ FOSS defender since 2005
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
The mission
Before the migration
A.R.S.I.A.
ā€¢ Association RĆ©gionale de SantĆ© et dā€™Identiļ¬cation Animales
ā€¢ 30 linux servers in several locations
ā€¢ A lot of Open Source
ā€¢ CentOS, Samba, Open-xchange, mailscanner, Cyrus,
ā€¢ . . . Puppet, jenkins, foreman, OpenVPN, GLPI, rabbitmq,
ā€¢ . . . BackupPC, CUPS, icinga, trac, zope, plone,
ā€¢ . . . solr, pentaho, funambol, munin, squid, asterisk,
ā€¢ . . . and PostgreSQL, . . .
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
The mission
Before the migration
C.E.R.I.S.E
ā€¢ A web application
ā€¢ Plone (python)
ā€¢ 15k+ visits, 500k+ pages and 2.000.000+ hits each month
ā€¢ Developped by Aļ¬ƒnitic
ā€¢ Several databases
ā€¢ PostgreSQL 9.0
ā€¢ Oracle database
ā€¢ Several servers/services
ā€¢ Two reverse proxies in failover HA
ā€¢ Two application servers in load balancing HA
ā€¢ Two PostgreSQL servers in failover HA
ā€¢ An oracledb server
ā€¢ A development server
ā€¢ A pentaho server
ā€¢ Being integrated in jenkins (to be continued. . . )
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
The mission
Before the migration
PostgreSQL before the migration
ā€¢ PostgreSQL 8.3.7
ā€¢ No native support of HA
ā€¢ High availability with heartbeat 2 and DRBD
ā€¢ Installed on the application servers
ā€¢ Nothing automated
ā€¢ Failover: Passive node is not even read only
ā€¢ Installed in November 2008
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
The mission
Before the migration
Monitoring before the installation
ā€¢ Icinga
ā€¢ Check of the DRBD
ā€¢ Simple connection check to PostgreSQL
ā€¢ Graphing with Cacti
ā€¢ Size of the databases
ā€¢ Connexions to the database
ā€¢ Checkpoints
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
The mission
Before the migration
Backups before the installation
ā€¢ Backups were done every hour one the same machine
ā€¢ External backups once a day on disk and on tape
ā€¢ Backups are made with pg_dump command
ā€¢ BackupPC get those ļ¬les
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Intro
Streaming replication
Master conļ¬guration
Slave conļ¬guration
PostgreSQL speciļ¬c tricks
Setting up a slave
PostgreSQL 9.0
ā€¢ PostgreSQL 9.0 was out in september 2010
ā€¢ It brings to the world native replication in PostgresSQL
ā€¢ There is not any native failover tool
ā€¢ So we need to use PostgreSQL + Corosync
ā€¢ The setup of PostgreSQL is managed by Puppet
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Intro
Streaming replication
Master conļ¬guration
Slave conļ¬guration
PostgreSQL speciļ¬c tricks
Setting up a slave
Write-Ahead Logging
ā€¢ It means that every change to dataļ¬le must ļ¬rst be written
into a log ļ¬le
ā€¢ Less disk writes: only the log ļ¬le needs to be ļ¬‚ushed to disk to
guarantee that a transaction is committed, rather than every
data ļ¬le changed by the transaction
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Intro
Streaming replication
Master conļ¬guration
Slave conļ¬guration
PostgreSQL speciļ¬c tricks
Setting up a slave
What is streaming replication
ā€¢ Streaming replication provides the capability to ship and apply
WAL XLOGS to standby servers
ā€¢ Itā€™s possible to have multiple standby servers
ā€¢ Standby servers can be read-only ("Hot standby")
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Intro
Streaming replication
Master conļ¬guration
Slave conļ¬guration
PostgreSQL speciļ¬c tricks
Setting up a slave
DisadvantagesSpeciļ¬cations of streaming replication
ā€¢ Streaming replication supports only asynchronous log-shipping
ā€¢ But when the database is used, the delay is close to
synchronous log-shipping
ā€¢ Adding a standby server requires manual action
ā€¢ But in our case we will only have one standby server
ā€¢ PostgreSQL does not provide HA feature
ā€¢ But Corosync does
ā€¢ It is a single-threaded replication
ā€¢ It is a single-threaded replication
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Intro
Streaming replication
Master conļ¬guration
Slave conļ¬guration
PostgreSQL speciļ¬c tricks
Setting up a slave
Master conļ¬guration
The master only needs one conļ¬guration ļ¬le.
Conļ¬guration non-related to SR
#Postgresql configuration
#http://www.postgresql.org/docs/9.0/interactive/index.html
listen_addresses = ā€™*ā€™
max_connections = 200
shared_buffers = 4096MB
work_mem = 4096MB
effective_cache_size = 10024MB
commit_delay = 100000
effective_cache_size = 2560
log_destination = ā€˜stderrā€™
log_directory = ā€˜pg_logā€™
logging_collector = on
log_filename = ā€˜postgresql-%Y-%m-%d_%H%M%S.logā€™
log_truncate_on_rotation = on
log_rotation_age = 1d
log_rotation_size = 0
log_min_messages = notice
log_min_duration_statement = 1000
log_line_prefix = ā€˜%t %u ā€™
log_statement = ā€˜noneā€™
datestyle = ā€˜iso, dmyā€™
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Intro
Streaming replication
Master conļ¬guration
Slave conļ¬guration
PostgreSQL speciļ¬c tricks
Setting up a slave
Master conļ¬guration
Conļ¬guration related to SR
wal_level = hot_standby
max_wal_senders = 2
wal_keep_segments = 128
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Intro
Streaming replication
Master conļ¬guration
Slave conļ¬guration
PostgreSQL speciļ¬c tricks
Setting up a slave
Master conļ¬guration
ā€¢ wal_level = hot_standby
Allows stanby server to be readable
ā€¢ max_wal_senders = 2
We allow up to 2 standby nodes
ā€¢ wal_keep_segments = 128
The minimum wal segments to keep
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Intro
Streaming replication
Master conļ¬guration
Slave conļ¬guration
PostgreSQL speciļ¬c tricks
Setting up a slave
Slave conļ¬guration
ā€¢ The slave requires at least two conļ¬guration ļ¬les
ā€¢ A postgreSQL.conf ļ¬le
ā€¢ A recovery.conf ļ¬le, used to apply the WAL XLOGS shipped by
the master
ā€¢ A trigger ļ¬le to stop replication can be speciļ¬ed
PostgreSQL.conf - Conļ¬guration related to SR
wal_level = hot_standby
hot_standby = on
Note that the ļ¬le also have the same ļ¬rst part of the conļ¬g ļ¬le
than the master conļ¬guration.
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Intro
Streaming replication
Master conļ¬guration
Slave conļ¬guration
PostgreSQL speciļ¬c tricks
Setting up a slave
Slave conļ¬guration
recovery.conf
standby_mode = ā€˜onā€™
primary_conninfo = ā€˜host=192.168.177.2 user=replicuserā€™
ā€¢ standby_mode means that this is a standby server
ā€¢ primary_conninfo is the connection to the master
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Intro
Streaming replication
Master conļ¬guration
Slave conļ¬guration
PostgreSQL speciļ¬c tricks
Setting up a slave
Replication user
ā€¢ A super user called replication has to be created
ā€¢ The SQL command to create it is
CREATE USER replication SUPERUSER LOGIN CONNECTION
LIMIT 1 ENCRYPTED PASSWORD ā€˜foobarā€™;
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Intro
Streaming replication
Master conļ¬guration
Slave conļ¬guration
PostgreSQL speciļ¬c tricks
Setting up a slave
pg_hba.conf
ā€¢ pg_hba.conf is the ļ¬le that contains some kind of ACLs for
the PostgreSQL connections
ā€¢ In that ļ¬le we will add both nodes as ā€˜trustedā€™ and the
replication user as trusted too
pg_hba.conf
hostnossl all all 10.0.10.8/32 trust
hostnossl all all 10.0.10.9/32 trust
hostnossl replication replicuser 192.168.177.2/24 trust
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Intro
Streaming replication
Master conļ¬guration
Slave conļ¬guration
PostgreSQL speciļ¬c tricks
Setting up a slave
Setting up a slave
ā€¢ You have to type a bunch of commands on the master when
you add a new standby server
Adding a standby server
psql -c "SELECT pg_start_backup(ā€™labelā€™, true)"
rsync -a ${PGDATA}/ standby:/srv/pgsql/standby/ --exclude postmaster.pid --exclude ā€˜*-masterā€™
--exclude ā€˜*-slaveā€™
psql -c "SELECT pg_stop_backup()"
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Set up of corosync
OCF resource
Corosync conļ¬guration
ā€¢ The goal of corosync is to make the switch between
master/slave when needed
ā€¢ It will ensure that a master is online and connected to the
router
ā€¢ The two servers are connected to each other on eth1
ā€¢ Corosync is installed by Puppet
ā€¢ We take it from the clusterlabs repositories
ā€¢ We use a personalized master/slave ocf resource to manage
the PostgreSQL M/S
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Set up of corosync
OCF resource
crm.conf
The main conļ¬guration ļ¬le of corosync is
/etc/corosync/crm.conf. It contains all the
resources/nodes/etc. . .
Deļ¬ning the nodes
node babar.interne.arsia.be 
attributes standby="off"
node dumbo.interne.arsia.be 
attributes standby="off"
In this code, the two nodes are deļ¬ned, and we tell corosync that
they should be started at launch.
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Set up of corosync
OCF resource
crm.conf
Deļ¬ning the primitives
primitive pgsql ocf:inuits:pgsql-ms
primitive virt_ip ocf:heartbeat:IPaddr2 
params nic="eth0" iflabel="0" ip="10.0.10.10" cidr_netmask="24" broadcast="10.0.10.255" 
meta target-role="Started" is-managed="true"
primitive ping ocf:pacemaker:ping 
params host_list="10.0.10.1" 
op monitor interval="10s" timeout="10s" 
op start interval="0" timeout="45s" 
op stop interval="0" timeout="50s"
ā€¢ We deļ¬ne 3 primitives:
ā€¢ pgsql, the PostgreSQL primitive
ā€¢ virt_ip, the ļ¬‚oating IP address
ā€¢ ping, the primitive that will check that the servers are
connected to the router
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Set up of corosync
OCF resource
crm.conf
Conļ¬guring the primitives
ms pgsql-ms pgsql 
params pgsqlconfig="/var/lib/pgsql/data/postgresql.conf" 
lsb_script="/etc/init.d/postgresql-9.0" 
pgsqlrecovery="/var/lib/pgsql/data/recovery.conf" 
meta clone-max="2" clone-node-max="1" master-max="1" master-node-max="1" notify="false"
clone clone-ping ping 
meta globally-unique="false"
ā€¢ We conļ¬gure the PostgreSQL M/S: the init script, the
conļ¬guration ļ¬les. . .
ā€¢ We also conļ¬gure the ping resource as a clone (it will be
launched on both servers)
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Set up of corosync
OCF resource
crm.conf
Deļ¬ning the nodes
group PSQL virt_ip
location connected PSQL 
rule $id="connected-rule" -inf: not_defined pingd or pingd lte 0
colocation ip_psql inf: PSQL pgsql-ms:Master
property $id="cib-bootstrap-options" 
cluster-infrastructure="openais" 
expected-quorum-votes="2" 
stonith-enabled="false" 
no-quorum-policy="ignore" 
default-resource-stickiness="INFINITY"
rsc_defaults $id="rsc_defaults-options" 
migration-threshold="INFINITY" 
failure-timeout="10" 
resource-stickiness="INFINITY"
ā€¢ These lines will ensure that the master is always on the same
node as the ļ¬‚oating IP address
ā€¢ And also that the master is connected to the router
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Set up of corosync
OCF resource
OCF resource
ā€¢ There is a custom OCF resource to manage the master/slave
PostgreSQL
ā€¢ It is based on an example of resource written by Andrew
Beekhof from Clusterlabs
ā€¢ The ļ¬le has to be in
/usr/lib/ocf/resource.d/inuits/pgsql-ms
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Set up of corosync
OCF resource
OCF resource
ā€¢ The script does the following:
ā€¢ It moves the postgresql.conf-master to
postgresql.conf when a node is promoted/master
ā€¢ It moves the postgresql.conf-slave to postgresql.conf
when a node is depromoted/slave
ā€¢ It ensure that recovery.conf-slave is on recovery.conf
on slave and absent on master
ā€¢ It starts/restarts PostgreSQL when needed.
ā€¢ I will post that ļ¬le on Github soon
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Cron jobs
BackupPC
Backups of the databases
ā€¢ Sometimes, you need backups (especially when you donā€™t have
backups. . . )
ā€¢ We do a backup per hour on each node (one at minute 0 and
one at minute 30)
ā€¢ We do a backup per day on each node
ā€¢ We do a backup per day on before BackupPC backup on each
node.
ā€¢ We keep 24 hourly backups and 7 daily backups on disk
ā€¢ With BackupPC we keep months of backups
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Cron jobs
BackupPC
Hourly backup script
/usr/local/bin/backup_hourly.sh
#!/bin/bash
DATE=$(date +%H)
BACKUP_PATH=/var/lib/backups/hourly
for db in foobar_db foobar2_db
do
/usr/bin/pg_dump $db | gzip > $BACKUP_PATH/${db}_$DATE.pgsql.gz
ln -fs $BACKUP_PATH/${db}_$DATE.pgsql.gz $BACKUP_PATH/${db}_current.pgsql.gz
done
The daily script is almost the same.
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Cron jobs
BackupPC
BackupPC script
/usr/local/bin/backup_backuppc.sh
#!/bin/bash
DATE=$(date +%u)
BACKUP_PATH=/var/lib/backups/backuppc
for db in cerise trackitquality trackit zodb_cerise
do
/usr/bin/pg_dump -U postgres $db | gzip > $BACKUP_PATH/${db}_$DATE.pgsql.gz
ln -fs $BACKUP_PATH/${db}_$DATE.pgsql.gz $BACKUP_PATH/${db}_current.pgsql.gz
done
In the backupPC conļ¬g, I added the following:
BackupPC config
$Conf{DumpPreUserCmd} = ā€˜$sshPath -t -q -x -l backuppc $host /usr/local/bin/backup_backuppc.shā€™;
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Nagios
Munin
check_postgres script
ā€¢ The check_postgres.pl is a nagios-compatible perl script
ā€¢ Available on http://www.bucardo.org/check_postgres/
and on Github
ā€¢ What we check with it:
ā€¢ The current connections
ā€¢ The status of the replication (the delay)
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Nagios
Munin
Check hot_standby latency
ā€¢ The check_postgres.pl script has a check for hot_standby
delay
ā€¢ But we do not know who is the master and the slave, and it is
required to launch the script
ā€¢ So, here is a bash script I wrote to know the M/S order
Master/slave replication check
#!/bin/bash
/usr/lib64/nagios/plugins/check_postgres.pl --db="$1" 
--action hot_standby_delay -w 300 -c 600 --host=$(
crm_resource --resource pgsql-ms --locate|
awk ā€˜/Master/ {master=$6} / $/ {slave=$6} END {print master","slave}ā€™
)
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Nagios
Munin
Munin postgres scripts
ā€¢ Munin is shipped with perl plugins for postgresql
ā€¢ We use four of them:
ā€¢ postgres_size,
ā€¢ postgres_checkpoints,
ā€¢ postgres_connections_db,
ā€¢ postgres_cache
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Nagios
Munin
Munin postgres scripts
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Puppet module
The node ļ¬le
#TODO
Puppet module
ā€¢ The puppet postgres module is forked from Kris Buytaertā€™s
github page
ā€¢ It is modiļ¬ed to remove all references to services, because we
want corosync to manage them
ā€¢ It creates the users, the super users, the databases
ā€¢ It is a parameterized class, with a "cluster" parameter. So we
can also install simple PostgreSQL
ā€¢ The cache sizes are parameterized too, so we can also use that
in Vagrant boxes
ā€¢ Here are some examples from the module I will upload on
Github ASAP
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Puppet module
The node ļ¬le
#TODO
Class postgres
The postgres class installs the packages and makes the initdb stuļ¬€.
init.pp
class postgres (
$cluster = ā€˜noā€™,
$running_ip = ā€˜127.0.0.1ā€™
){ ...
ā€¢ The cluster parameter indicates if we want or not clustering
ā€¢ running_ip is used for the SQL commands. In case of a
cluster, you have to put clusteā€™s IP address here.
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Puppet module
The node ļ¬le
#TODO
Sqlexec deļ¬nition
sqlexec.pp
define postgres::sqlexec($username, $database, $sql, $sqlcheck) {
exec{ "psql -h $postgres::running_ip ā€“username=${username} $database
-c ĀØ${sql}ĀØ>> /var/log/puppet-postgresql.sql.log 2>&1 && /bin/sleep 5":
environment => "PGPASSWORD=${postgres_password}",
path => $::path,
timeout => 600,
unless => "psql -h $postgres::running_ip -U $username $database -c $sqlcheck",
require => Service[ā€™postgresql-9.0ā€™],
}
}
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Puppet module
The node ļ¬le
#TODO
Example in the node ļ¬le
Here is the result in the node ļ¬le:
dumbo.pp
node babar {
class {
ā€™postgresā€™:
cluster => ā€™yesā€™,
running_ip => ā€™10.0.10.10ā€™,
}
include postgres::munin
include postgres::backup
include cluster::node
postgres::config{
$::fqdn: listen => ā€™*ā€™,
}
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Puppet module
The node ļ¬le
#TODO
Example in the node ļ¬le
dumbo.pp
postgres::hba {
$::fqdn:
allowedrules => [
"host all all $::ipaddress/32 trust",
ā€™hostnossl all all 10.0.10.8/32 trustā€™,
ā€™hostnossl all all 10.0.10.9/32 trustā€™,
ā€™hostnossl all all 10.0.10.10/32 trustā€™,
ā€™hostnossl replication replicuser 192.168.177.2/24 trustā€™,
],
}
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Puppet module
The node ļ¬le
#TODO
Example in the node ļ¬le
dumbo.pp
postgres::createsuperuser{
ā€™replicuserā€™:
passwd => ā€™foobarā€™,
}
postgres::createuser{
ā€™ceriseā€™:
passwd => ā€™foobarā€™;
}
postgres::createdb{
ā€™zodb_ceriseā€™:
owner => ā€™ceriseā€™,
require => Postgres::Createuser[ā€™ceriseā€™],
}
}
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Puppet module
The node ļ¬le
#TODO
#TODO
ā€¢ The ļ¬rst synchronisation is not puppetized
ā€¢ More advanced checks on the database #monitoringsucks
(e.g. slow queries)
ā€¢ A disaster recovery
ā€¢ Improve the ocf script
ā€¢ Check the content of the backups
ā€¢ . . .
Julien Pivotto PostgreSQL 9.0 HA
;
Overview
PostgreSQL 9.0
Clustering
Backups
Monitoring
Automation
The end
Any questions?
Julien Pivotto PostgreSQL 9.0 HA

More Related Content

What's hot

Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Puppet
Ā 
Serverspec and Sensu - Testing and Monitoring collide
Serverspec and Sensu - Testing and Monitoring collideServerspec and Sensu - Testing and Monitoring collide
Serverspec and Sensu - Testing and Monitoring collidem_richardson
Ā 
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test EverythingPortland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test EverythingPuppet
Ā 
Transforming the Ceph Integration Tests with OpenStack
Transforming the Ceph Integration Tests with OpenStack Transforming the Ceph Integration Tests with OpenStack
Transforming the Ceph Integration Tests with OpenStack Ceph Community
Ā 
Puppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionPuppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionJoshua Thijssen
Ā 
SaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStack
SaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStackSaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStack
SaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStackSaltStack
Ā 
Verifying your Ansible Roles using Docker, Test Kitchen and Serverspec
Verifying your Ansible Roles using Docker, Test Kitchen and ServerspecVerifying your Ansible Roles using Docker, Test Kitchen and Serverspec
Verifying your Ansible Roles using Docker, Test Kitchen and ServerspecEdmund Dipple
Ā 
SCALE12X: Chef for OpenStack
SCALE12X: Chef for OpenStackSCALE12X: Chef for OpenStack
SCALE12X: Chef for OpenStackMatt Ray
Ā 
SaltConf 2015: Salt stack at web scale: Better, Stronger, Faster
SaltConf 2015: Salt stack at web scale: Better, Stronger, FasterSaltConf 2015: Salt stack at web scale: Better, Stronger, Faster
SaltConf 2015: Salt stack at web scale: Better, Stronger, FasterThomas Jackson
Ā 
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014Puppet
Ā 
Modern Infrastructure from Scratch with Puppet
Modern Infrastructure from Scratch with PuppetModern Infrastructure from Scratch with Puppet
Modern Infrastructure from Scratch with PuppetPuppet
Ā 
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...SaltStack
Ā 
Package Management and Chef - ChefConf 2015
Package Management and Chef - ChefConf 2015Package Management and Chef - ChefConf 2015
Package Management and Chef - ChefConf 2015Chef
Ā 
OSDC2014: Testing Server Infrastructure with #serverspec
OSDC2014: Testing Server Infrastructure with #serverspecOSDC2014: Testing Server Infrastructure with #serverspec
OSDC2014: Testing Server Infrastructure with #serverspecAndreas Schmidt
Ā 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflowTomas Doran
Ā 
Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014Tomas Doran
Ā 
London devops logging
London devops loggingLondon devops logging
London devops loggingTomas Doran
Ā 
Arnold Bechtoldt, Inovex GmbH Linux systems engineer - Configuration Manageme...
Arnold Bechtoldt, Inovex GmbH Linux systems engineer - Configuration Manageme...Arnold Bechtoldt, Inovex GmbH Linux systems engineer - Configuration Manageme...
Arnold Bechtoldt, Inovex GmbH Linux systems engineer - Configuration Manageme...SaltStack
Ā 

What's hot (20)

Hacking on WildFly 9
Hacking on WildFly 9Hacking on WildFly 9
Hacking on WildFly 9
Ā 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Ā 
Puppet evolutions
Puppet evolutionsPuppet evolutions
Puppet evolutions
Ā 
Serverspec and Sensu - Testing and Monitoring collide
Serverspec and Sensu - Testing and Monitoring collideServerspec and Sensu - Testing and Monitoring collide
Serverspec and Sensu - Testing and Monitoring collide
Ā 
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test EverythingPortland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Ā 
Transforming the Ceph Integration Tests with OpenStack
Transforming the Ceph Integration Tests with OpenStack Transforming the Ceph Integration Tests with OpenStack
Transforming the Ceph Integration Tests with OpenStack
Ā 
Puppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionPuppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 Edition
Ā 
SaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStack
SaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStackSaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStack
SaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStack
Ā 
Verifying your Ansible Roles using Docker, Test Kitchen and Serverspec
Verifying your Ansible Roles using Docker, Test Kitchen and ServerspecVerifying your Ansible Roles using Docker, Test Kitchen and Serverspec
Verifying your Ansible Roles using Docker, Test Kitchen and Serverspec
Ā 
SCALE12X: Chef for OpenStack
SCALE12X: Chef for OpenStackSCALE12X: Chef for OpenStack
SCALE12X: Chef for OpenStack
Ā 
SaltConf 2015: Salt stack at web scale: Better, Stronger, Faster
SaltConf 2015: Salt stack at web scale: Better, Stronger, FasterSaltConf 2015: Salt stack at web scale: Better, Stronger, Faster
SaltConf 2015: Salt stack at web scale: Better, Stronger, Faster
Ā 
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
Ā 
Modern Infrastructure from Scratch with Puppet
Modern Infrastructure from Scratch with PuppetModern Infrastructure from Scratch with Puppet
Modern Infrastructure from Scratch with Puppet
Ā 
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...
SaltConf14 - Saurabh Surana, HP Cloud - Automating operations and support wit...
Ā 
Package Management and Chef - ChefConf 2015
Package Management and Chef - ChefConf 2015Package Management and Chef - ChefConf 2015
Package Management and Chef - ChefConf 2015
Ā 
OSDC2014: Testing Server Infrastructure with #serverspec
OSDC2014: Testing Server Infrastructure with #serverspecOSDC2014: Testing Server Infrastructure with #serverspec
OSDC2014: Testing Server Infrastructure with #serverspec
Ā 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflow
Ā 
Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014
Ā 
London devops logging
London devops loggingLondon devops logging
London devops logging
Ā 
Arnold Bechtoldt, Inovex GmbH Linux systems engineer - Configuration Manageme...
Arnold Bechtoldt, Inovex GmbH Linux systems engineer - Configuration Manageme...Arnold Bechtoldt, Inovex GmbH Linux systems engineer - Configuration Manageme...
Arnold Bechtoldt, Inovex GmbH Linux systems engineer - Configuration Manageme...
Ā 

Similar to Postgresql 9.0 HA at LOADAYS 2012

Postgresql 9.0 HA at RMLL 2012
Postgresql 9.0 HA at RMLL 2012Postgresql 9.0 HA at RMLL 2012
Postgresql 9.0 HA at RMLL 2012Julien Pivotto
Ā 
Built-in-Physical-and-Logical-Replication-in-Postgresql-Firat-Gulec.pptx
Built-in-Physical-and-Logical-Replication-in-Postgresql-Firat-Gulec.pptxBuilt-in-Physical-and-Logical-Replication-in-Postgresql-Firat-Gulec.pptx
Built-in-Physical-and-Logical-Replication-in-Postgresql-Firat-Gulec.pptxnadirpervez2
Ā 
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...javier ramirez
Ā 
SUSE Container as a Service Platform
SUSE Container as a Service PlatformSUSE Container as a Service Platform
SUSE Container as a Service PlatformSUSE
Ā 
Built in physical and logical replication in postgresql-Firat Gulec
Built in physical and logical replication in postgresql-Firat GulecBuilt in physical and logical replication in postgresql-Firat Gulec
Built in physical and logical replication in postgresql-Firat GulecFIRAT GULEC
Ā 
Switch as a Server - PuppetConf 2014 - Leslie Carr
Switch as a Server - PuppetConf 2014 - Leslie CarrSwitch as a Server - PuppetConf 2014 - Leslie Carr
Switch as a Server - PuppetConf 2014 - Leslie CarrCumulus Networks
Ā 
2009-01-20 RHEL 5.3 for System z
2009-01-20 RHEL 5.3 for System z2009-01-20 RHEL 5.3 for System z
2009-01-20 RHEL 5.3 for System zShawn Wells
Ā 
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...Command Prompt., Inc
Ā 
PaaSTA: Running applications at Yelp
PaaSTA: Running applications at YelpPaaSTA: Running applications at Yelp
PaaSTA: Running applications at YelpNathan Handler
Ā 
Sanger OpenStack presentation March 2017
Sanger OpenStack presentation March 2017Sanger OpenStack presentation March 2017
Sanger OpenStack presentation March 2017Dave Holland
Ā 
Cloud Foundry on OpenStack - An Experience Report | anynines
Cloud Foundry on OpenStack - An Experience Report | anynines Cloud Foundry on OpenStack - An Experience Report | anynines
Cloud Foundry on OpenStack - An Experience Report | anynines anynines GmbH
Ā 
Automating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps ApproachAutomating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps ApproachAkshaya Mahapatra
Ā 
Making Spinnaker Go @ Stitch Fix
Making Spinnaker Go @ Stitch FixMaking Spinnaker Go @ Stitch Fix
Making Spinnaker Go @ Stitch FixDiana Tkachenko
Ā 
Introduction to PostgreSQL for System Administrators
Introduction to PostgreSQL for System AdministratorsIntroduction to PostgreSQL for System Administrators
Introduction to PostgreSQL for System AdministratorsJignesh Shah
Ā 
A3Sec Advanced Deployment System
A3Sec Advanced Deployment SystemA3Sec Advanced Deployment System
A3Sec Advanced Deployment Systema3sec
Ā 
Ceph Day Shanghai - CeTune - Benchmarking and tuning your Ceph cluster
Ceph Day Shanghai - CeTune - Benchmarking and tuning your Ceph cluster Ceph Day Shanghai - CeTune - Benchmarking and tuning your Ceph cluster
Ceph Day Shanghai - CeTune - Benchmarking and tuning your Ceph cluster Ceph Community
Ā 
Neutron CI Run on Docker
Neutron CI Run on DockerNeutron CI Run on Docker
Neutron CI Run on DockerHirofumi Ichihara
Ā 
Streaming Processing with a Distributed Commit Log
Streaming Processing with a Distributed Commit LogStreaming Processing with a Distributed Commit Log
Streaming Processing with a Distributed Commit LogJoe Stein
Ā 
Sanger, upcoming Openstack for Bio-informaticians
Sanger, upcoming Openstack for Bio-informaticiansSanger, upcoming Openstack for Bio-informaticians
Sanger, upcoming Openstack for Bio-informaticiansPeter Clapham
Ā 

Similar to Postgresql 9.0 HA at LOADAYS 2012 (20)

Postgresql 9.0 HA at RMLL 2012
Postgresql 9.0 HA at RMLL 2012Postgresql 9.0 HA at RMLL 2012
Postgresql 9.0 HA at RMLL 2012
Ā 
Built-in-Physical-and-Logical-Replication-in-Postgresql-Firat-Gulec.pptx
Built-in-Physical-and-Logical-Replication-in-Postgresql-Firat-Gulec.pptxBuilt-in-Physical-and-Logical-Replication-in-Postgresql-Firat-Gulec.pptx
Built-in-Physical-and-Logical-Replication-in-Postgresql-Firat-Gulec.pptx
Ā 
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Ā 
SUSE Container as a Service Platform
SUSE Container as a Service PlatformSUSE Container as a Service Platform
SUSE Container as a Service Platform
Ā 
Built in physical and logical replication in postgresql-Firat Gulec
Built in physical and logical replication in postgresql-Firat GulecBuilt in physical and logical replication in postgresql-Firat Gulec
Built in physical and logical replication in postgresql-Firat Gulec
Ā 
Switch as a Server - PuppetConf 2014 - Leslie Carr
Switch as a Server - PuppetConf 2014 - Leslie CarrSwitch as a Server - PuppetConf 2014 - Leslie Carr
Switch as a Server - PuppetConf 2014 - Leslie Carr
Ā 
2009-01-20 RHEL 5.3 for System z
2009-01-20 RHEL 5.3 for System z2009-01-20 RHEL 5.3 for System z
2009-01-20 RHEL 5.3 for System z
Ā 
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
Ā 
PaaSTA: Running applications at Yelp
PaaSTA: Running applications at YelpPaaSTA: Running applications at Yelp
PaaSTA: Running applications at Yelp
Ā 
Sanger OpenStack presentation March 2017
Sanger OpenStack presentation March 2017Sanger OpenStack presentation March 2017
Sanger OpenStack presentation March 2017
Ā 
The Accidental DBA
The Accidental DBAThe Accidental DBA
The Accidental DBA
Ā 
Cloud Foundry on OpenStack - An Experience Report | anynines
Cloud Foundry on OpenStack - An Experience Report | anynines Cloud Foundry on OpenStack - An Experience Report | anynines
Cloud Foundry on OpenStack - An Experience Report | anynines
Ā 
Automating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps ApproachAutomating Software Development Life Cycle - A DevOps Approach
Automating Software Development Life Cycle - A DevOps Approach
Ā 
Making Spinnaker Go @ Stitch Fix
Making Spinnaker Go @ Stitch FixMaking Spinnaker Go @ Stitch Fix
Making Spinnaker Go @ Stitch Fix
Ā 
Introduction to PostgreSQL for System Administrators
Introduction to PostgreSQL for System AdministratorsIntroduction to PostgreSQL for System Administrators
Introduction to PostgreSQL for System Administrators
Ā 
A3Sec Advanced Deployment System
A3Sec Advanced Deployment SystemA3Sec Advanced Deployment System
A3Sec Advanced Deployment System
Ā 
Ceph Day Shanghai - CeTune - Benchmarking and tuning your Ceph cluster
Ceph Day Shanghai - CeTune - Benchmarking and tuning your Ceph cluster Ceph Day Shanghai - CeTune - Benchmarking and tuning your Ceph cluster
Ceph Day Shanghai - CeTune - Benchmarking and tuning your Ceph cluster
Ā 
Neutron CI Run on Docker
Neutron CI Run on DockerNeutron CI Run on Docker
Neutron CI Run on Docker
Ā 
Streaming Processing with a Distributed Commit Log
Streaming Processing with a Distributed Commit LogStreaming Processing with a Distributed Commit Log
Streaming Processing with a Distributed Commit Log
Ā 
Sanger, upcoming Openstack for Bio-informaticians
Sanger, upcoming Openstack for Bio-informaticiansSanger, upcoming Openstack for Bio-informaticians
Sanger, upcoming Openstack for Bio-informaticians
Ā 

More from Julien Pivotto

The O11y Toolkit
The O11y ToolkitThe O11y Toolkit
The O11y ToolkitJulien Pivotto
Ā 
What's New in Prometheus and Its Ecosystem
What's New in Prometheus and Its EcosystemWhat's New in Prometheus and Its Ecosystem
What's New in Prometheus and Its EcosystemJulien Pivotto
Ā 
Prometheus: What is is, what is new, what is coming
Prometheus: What is is, what is new, what is comingPrometheus: What is is, what is new, what is coming
Prometheus: What is is, what is new, what is comingJulien Pivotto
Ā 
What's new in Prometheus?
What's new in Prometheus?What's new in Prometheus?
What's new in Prometheus?Julien Pivotto
Ā 
Introduction to Grafana Loki
Introduction to Grafana LokiIntroduction to Grafana Loki
Introduction to Grafana LokiJulien Pivotto
Ā 
Why you should revisit mgmt
Why you should revisit mgmtWhy you should revisit mgmt
Why you should revisit mgmtJulien Pivotto
Ā 
Observing the HashiCorp Ecosystem From Prometheus
Observing the HashiCorp Ecosystem From PrometheusObserving the HashiCorp Ecosystem From Prometheus
Observing the HashiCorp Ecosystem From PrometheusJulien Pivotto
Ā 
Monitoring in a fast-changing world with Prometheus
Monitoring in a fast-changing world with PrometheusMonitoring in a fast-changing world with Prometheus
Monitoring in a fast-changing world with PrometheusJulien Pivotto
Ā 
5 tips for Prometheus Service Discovery
5 tips for Prometheus Service Discovery5 tips for Prometheus Service Discovery
5 tips for Prometheus Service DiscoveryJulien Pivotto
Ā 
Prometheus and TLS - an Introduction
Prometheus and TLS - an IntroductionPrometheus and TLS - an Introduction
Prometheus and TLS - an IntroductionJulien Pivotto
Ā 
Powerful graphs in Grafana
Powerful graphs in GrafanaPowerful graphs in Grafana
Powerful graphs in GrafanaJulien Pivotto
Ā 
HAProxy as Egress Controller
HAProxy as Egress ControllerHAProxy as Egress Controller
HAProxy as Egress ControllerJulien Pivotto
Ā 
Improved alerting with Prometheus and Alertmanager
Improved alerting with Prometheus and AlertmanagerImproved alerting with Prometheus and Alertmanager
Improved alerting with Prometheus and AlertmanagerJulien Pivotto
Ā 
SIngle Sign On with Keycloak
SIngle Sign On with KeycloakSIngle Sign On with Keycloak
SIngle Sign On with KeycloakJulien Pivotto
Ā 
Monitoring as an entry point for collaboration
Monitoring as an entry point for collaborationMonitoring as an entry point for collaboration
Monitoring as an entry point for collaborationJulien Pivotto
Ā 
Incident Resolution as Code
Incident Resolution as CodeIncident Resolution as Code
Incident Resolution as CodeJulien Pivotto
Ā 
Monitor your CentOS stack with Prometheus
Monitor your CentOS stack with PrometheusMonitor your CentOS stack with Prometheus
Monitor your CentOS stack with PrometheusJulien Pivotto
Ā 
Monitor your CentOS stack with Prometheus
Monitor your CentOS stack with PrometheusMonitor your CentOS stack with Prometheus
Monitor your CentOS stack with PrometheusJulien Pivotto
Ā 
An introduction to Ansible
An introduction to AnsibleAn introduction to Ansible
An introduction to AnsibleJulien Pivotto
Ā 

More from Julien Pivotto (20)

The O11y Toolkit
The O11y ToolkitThe O11y Toolkit
The O11y Toolkit
Ā 
What's New in Prometheus and Its Ecosystem
What's New in Prometheus and Its EcosystemWhat's New in Prometheus and Its Ecosystem
What's New in Prometheus and Its Ecosystem
Ā 
Prometheus: What is is, what is new, what is coming
Prometheus: What is is, what is new, what is comingPrometheus: What is is, what is new, what is coming
Prometheus: What is is, what is new, what is coming
Ā 
What's new in Prometheus?
What's new in Prometheus?What's new in Prometheus?
What's new in Prometheus?
Ā 
Introduction to Grafana Loki
Introduction to Grafana LokiIntroduction to Grafana Loki
Introduction to Grafana Loki
Ā 
Why you should revisit mgmt
Why you should revisit mgmtWhy you should revisit mgmt
Why you should revisit mgmt
Ā 
Observing the HashiCorp Ecosystem From Prometheus
Observing the HashiCorp Ecosystem From PrometheusObserving the HashiCorp Ecosystem From Prometheus
Observing the HashiCorp Ecosystem From Prometheus
Ā 
Monitoring in a fast-changing world with Prometheus
Monitoring in a fast-changing world with PrometheusMonitoring in a fast-changing world with Prometheus
Monitoring in a fast-changing world with Prometheus
Ā 
5 tips for Prometheus Service Discovery
5 tips for Prometheus Service Discovery5 tips for Prometheus Service Discovery
5 tips for Prometheus Service Discovery
Ā 
Prometheus and TLS - an Introduction
Prometheus and TLS - an IntroductionPrometheus and TLS - an Introduction
Prometheus and TLS - an Introduction
Ā 
Powerful graphs in Grafana
Powerful graphs in GrafanaPowerful graphs in Grafana
Powerful graphs in Grafana
Ā 
YAML Magic
YAML MagicYAML Magic
YAML Magic
Ā 
HAProxy as Egress Controller
HAProxy as Egress ControllerHAProxy as Egress Controller
HAProxy as Egress Controller
Ā 
Improved alerting with Prometheus and Alertmanager
Improved alerting with Prometheus and AlertmanagerImproved alerting with Prometheus and Alertmanager
Improved alerting with Prometheus and Alertmanager
Ā 
SIngle Sign On with Keycloak
SIngle Sign On with KeycloakSIngle Sign On with Keycloak
SIngle Sign On with Keycloak
Ā 
Monitoring as an entry point for collaboration
Monitoring as an entry point for collaborationMonitoring as an entry point for collaboration
Monitoring as an entry point for collaboration
Ā 
Incident Resolution as Code
Incident Resolution as CodeIncident Resolution as Code
Incident Resolution as Code
Ā 
Monitor your CentOS stack with Prometheus
Monitor your CentOS stack with PrometheusMonitor your CentOS stack with Prometheus
Monitor your CentOS stack with Prometheus
Ā 
Monitor your CentOS stack with Prometheus
Monitor your CentOS stack with PrometheusMonitor your CentOS stack with Prometheus
Monitor your CentOS stack with Prometheus
Ā 
An introduction to Ansible
An introduction to AnsibleAn introduction to Ansible
An introduction to Ansible
Ā 

Recently uploaded

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
Ā 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
Ā 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
Ā 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
Ā 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
Ā 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
Ā 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
Ā 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
Ā 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vƔzquez
Ā 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
Ā 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
Ā 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
Ā 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
Ā 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
Ā 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
Ā 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
Ā 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Christopher Logan Kennedy
Ā 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
Ā 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
Ā 

Recently uploaded (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
Ā 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
Ā 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
Ā 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Ā 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Ā 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Ā 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
Ā 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
Ā 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Ā 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Ā 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Ā 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
Ā 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
Ā 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Ā 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
Ā 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Ā 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
Ā 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Ā 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
Ā 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
Ā 

Postgresql 9.0 HA at LOADAYS 2012

  • 1. ; PostgreSQL 9.0 HA Julien Pivotto April, 1 2012 @ Loadays
  • 2. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end The mission Before the migration Table of content 1 Overview The mission Before the migration 2 PostgreSQL 9.0 Intro Streaming replication Master conļ¬guration Slave conļ¬guration PostgreSQL speciļ¬c tricks Setting up a slave 3 Clustering Set up of corosync OCF resource 4 Backups Cron jobs BackupPC 5 Monitoring Nagios Munin 6 Automation Puppet module The node ļ¬le #TODO 7 The end Julien Pivotto PostgreSQL 9.0 HA
  • 3. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end The mission Before the migration Who am I ā€¢ Julien Pivotto ā€¢ Consultant at Inuits since May 2011 ā€¢ FOSS defender since 2005 Julien Pivotto PostgreSQL 9.0 HA
  • 4. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end The mission Before the migration A.R.S.I.A. ā€¢ Association RĆ©gionale de SantĆ© et dā€™Identiļ¬cation Animales ā€¢ 30 linux servers in several locations ā€¢ A lot of Open Source ā€¢ CentOS, Samba, Open-xchange, mailscanner, Cyrus, ā€¢ . . . Puppet, jenkins, foreman, OpenVPN, GLPI, rabbitmq, ā€¢ . . . BackupPC, CUPS, icinga, trac, zope, plone, ā€¢ . . . solr, pentaho, funambol, munin, squid, asterisk, ā€¢ . . . and PostgreSQL, . . . Julien Pivotto PostgreSQL 9.0 HA
  • 5. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end The mission Before the migration C.E.R.I.S.E ā€¢ A web application ā€¢ Plone (python) ā€¢ 15k+ visits, 500k+ pages and 2.000.000+ hits each month ā€¢ Developped by Aļ¬ƒnitic ā€¢ Several databases ā€¢ PostgreSQL 9.0 ā€¢ Oracle database ā€¢ Several servers/services ā€¢ Two reverse proxies in failover HA ā€¢ Two application servers in load balancing HA ā€¢ Two PostgreSQL servers in failover HA ā€¢ An oracledb server ā€¢ A development server ā€¢ A pentaho server ā€¢ Being integrated in jenkins (to be continued. . . ) Julien Pivotto PostgreSQL 9.0 HA
  • 6. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end The mission Before the migration PostgreSQL before the migration ā€¢ PostgreSQL 8.3.7 ā€¢ No native support of HA ā€¢ High availability with heartbeat 2 and DRBD ā€¢ Installed on the application servers ā€¢ Nothing automated ā€¢ Failover: Passive node is not even read only ā€¢ Installed in November 2008 Julien Pivotto PostgreSQL 9.0 HA
  • 7. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end The mission Before the migration Monitoring before the installation ā€¢ Icinga ā€¢ Check of the DRBD ā€¢ Simple connection check to PostgreSQL ā€¢ Graphing with Cacti ā€¢ Size of the databases ā€¢ Connexions to the database ā€¢ Checkpoints Julien Pivotto PostgreSQL 9.0 HA
  • 8. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end The mission Before the migration Backups before the installation ā€¢ Backups were done every hour one the same machine ā€¢ External backups once a day on disk and on tape ā€¢ Backups are made with pg_dump command ā€¢ BackupPC get those ļ¬les Julien Pivotto PostgreSQL 9.0 HA
  • 9. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Intro Streaming replication Master conļ¬guration Slave conļ¬guration PostgreSQL speciļ¬c tricks Setting up a slave PostgreSQL 9.0 ā€¢ PostgreSQL 9.0 was out in september 2010 ā€¢ It brings to the world native replication in PostgresSQL ā€¢ There is not any native failover tool ā€¢ So we need to use PostgreSQL + Corosync ā€¢ The setup of PostgreSQL is managed by Puppet Julien Pivotto PostgreSQL 9.0 HA
  • 10. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Intro Streaming replication Master conļ¬guration Slave conļ¬guration PostgreSQL speciļ¬c tricks Setting up a slave Write-Ahead Logging ā€¢ It means that every change to dataļ¬le must ļ¬rst be written into a log ļ¬le ā€¢ Less disk writes: only the log ļ¬le needs to be ļ¬‚ushed to disk to guarantee that a transaction is committed, rather than every data ļ¬le changed by the transaction Julien Pivotto PostgreSQL 9.0 HA
  • 11. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Intro Streaming replication Master conļ¬guration Slave conļ¬guration PostgreSQL speciļ¬c tricks Setting up a slave What is streaming replication ā€¢ Streaming replication provides the capability to ship and apply WAL XLOGS to standby servers ā€¢ Itā€™s possible to have multiple standby servers ā€¢ Standby servers can be read-only ("Hot standby") Julien Pivotto PostgreSQL 9.0 HA
  • 12. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Intro Streaming replication Master conļ¬guration Slave conļ¬guration PostgreSQL speciļ¬c tricks Setting up a slave DisadvantagesSpeciļ¬cations of streaming replication ā€¢ Streaming replication supports only asynchronous log-shipping ā€¢ But when the database is used, the delay is close to synchronous log-shipping ā€¢ Adding a standby server requires manual action ā€¢ But in our case we will only have one standby server ā€¢ PostgreSQL does not provide HA feature ā€¢ But Corosync does ā€¢ It is a single-threaded replication ā€¢ It is a single-threaded replication Julien Pivotto PostgreSQL 9.0 HA
  • 13. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Intro Streaming replication Master conļ¬guration Slave conļ¬guration PostgreSQL speciļ¬c tricks Setting up a slave Master conļ¬guration The master only needs one conļ¬guration ļ¬le. Conļ¬guration non-related to SR #Postgresql configuration #http://www.postgresql.org/docs/9.0/interactive/index.html listen_addresses = ā€™*ā€™ max_connections = 200 shared_buffers = 4096MB work_mem = 4096MB effective_cache_size = 10024MB commit_delay = 100000 effective_cache_size = 2560 log_destination = ā€˜stderrā€™ log_directory = ā€˜pg_logā€™ logging_collector = on log_filename = ā€˜postgresql-%Y-%m-%d_%H%M%S.logā€™ log_truncate_on_rotation = on log_rotation_age = 1d log_rotation_size = 0 log_min_messages = notice log_min_duration_statement = 1000 log_line_prefix = ā€˜%t %u ā€™ log_statement = ā€˜noneā€™ datestyle = ā€˜iso, dmyā€™ Julien Pivotto PostgreSQL 9.0 HA
  • 14. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Intro Streaming replication Master conļ¬guration Slave conļ¬guration PostgreSQL speciļ¬c tricks Setting up a slave Master conļ¬guration Conļ¬guration related to SR wal_level = hot_standby max_wal_senders = 2 wal_keep_segments = 128 Julien Pivotto PostgreSQL 9.0 HA
  • 15. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Intro Streaming replication Master conļ¬guration Slave conļ¬guration PostgreSQL speciļ¬c tricks Setting up a slave Master conļ¬guration ā€¢ wal_level = hot_standby Allows stanby server to be readable ā€¢ max_wal_senders = 2 We allow up to 2 standby nodes ā€¢ wal_keep_segments = 128 The minimum wal segments to keep Julien Pivotto PostgreSQL 9.0 HA
  • 16. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Intro Streaming replication Master conļ¬guration Slave conļ¬guration PostgreSQL speciļ¬c tricks Setting up a slave Slave conļ¬guration ā€¢ The slave requires at least two conļ¬guration ļ¬les ā€¢ A postgreSQL.conf ļ¬le ā€¢ A recovery.conf ļ¬le, used to apply the WAL XLOGS shipped by the master ā€¢ A trigger ļ¬le to stop replication can be speciļ¬ed PostgreSQL.conf - Conļ¬guration related to SR wal_level = hot_standby hot_standby = on Note that the ļ¬le also have the same ļ¬rst part of the conļ¬g ļ¬le than the master conļ¬guration. Julien Pivotto PostgreSQL 9.0 HA
  • 17. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Intro Streaming replication Master conļ¬guration Slave conļ¬guration PostgreSQL speciļ¬c tricks Setting up a slave Slave conļ¬guration recovery.conf standby_mode = ā€˜onā€™ primary_conninfo = ā€˜host=192.168.177.2 user=replicuserā€™ ā€¢ standby_mode means that this is a standby server ā€¢ primary_conninfo is the connection to the master Julien Pivotto PostgreSQL 9.0 HA
  • 18. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Intro Streaming replication Master conļ¬guration Slave conļ¬guration PostgreSQL speciļ¬c tricks Setting up a slave Replication user ā€¢ A super user called replication has to be created ā€¢ The SQL command to create it is CREATE USER replication SUPERUSER LOGIN CONNECTION LIMIT 1 ENCRYPTED PASSWORD ā€˜foobarā€™; Julien Pivotto PostgreSQL 9.0 HA
  • 19. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Intro Streaming replication Master conļ¬guration Slave conļ¬guration PostgreSQL speciļ¬c tricks Setting up a slave pg_hba.conf ā€¢ pg_hba.conf is the ļ¬le that contains some kind of ACLs for the PostgreSQL connections ā€¢ In that ļ¬le we will add both nodes as ā€˜trustedā€™ and the replication user as trusted too pg_hba.conf hostnossl all all 10.0.10.8/32 trust hostnossl all all 10.0.10.9/32 trust hostnossl replication replicuser 192.168.177.2/24 trust Julien Pivotto PostgreSQL 9.0 HA
  • 20. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Intro Streaming replication Master conļ¬guration Slave conļ¬guration PostgreSQL speciļ¬c tricks Setting up a slave Setting up a slave ā€¢ You have to type a bunch of commands on the master when you add a new standby server Adding a standby server psql -c "SELECT pg_start_backup(ā€™labelā€™, true)" rsync -a ${PGDATA}/ standby:/srv/pgsql/standby/ --exclude postmaster.pid --exclude ā€˜*-masterā€™ --exclude ā€˜*-slaveā€™ psql -c "SELECT pg_stop_backup()" Julien Pivotto PostgreSQL 9.0 HA
  • 21. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Set up of corosync OCF resource Corosync conļ¬guration ā€¢ The goal of corosync is to make the switch between master/slave when needed ā€¢ It will ensure that a master is online and connected to the router ā€¢ The two servers are connected to each other on eth1 ā€¢ Corosync is installed by Puppet ā€¢ We take it from the clusterlabs repositories ā€¢ We use a personalized master/slave ocf resource to manage the PostgreSQL M/S Julien Pivotto PostgreSQL 9.0 HA
  • 22. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Set up of corosync OCF resource crm.conf The main conļ¬guration ļ¬le of corosync is /etc/corosync/crm.conf. It contains all the resources/nodes/etc. . . Deļ¬ning the nodes node babar.interne.arsia.be attributes standby="off" node dumbo.interne.arsia.be attributes standby="off" In this code, the two nodes are deļ¬ned, and we tell corosync that they should be started at launch. Julien Pivotto PostgreSQL 9.0 HA
  • 23. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Set up of corosync OCF resource crm.conf Deļ¬ning the primitives primitive pgsql ocf:inuits:pgsql-ms primitive virt_ip ocf:heartbeat:IPaddr2 params nic="eth0" iflabel="0" ip="10.0.10.10" cidr_netmask="24" broadcast="10.0.10.255" meta target-role="Started" is-managed="true" primitive ping ocf:pacemaker:ping params host_list="10.0.10.1" op monitor interval="10s" timeout="10s" op start interval="0" timeout="45s" op stop interval="0" timeout="50s" ā€¢ We deļ¬ne 3 primitives: ā€¢ pgsql, the PostgreSQL primitive ā€¢ virt_ip, the ļ¬‚oating IP address ā€¢ ping, the primitive that will check that the servers are connected to the router Julien Pivotto PostgreSQL 9.0 HA
  • 24. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Set up of corosync OCF resource crm.conf Conļ¬guring the primitives ms pgsql-ms pgsql params pgsqlconfig="/var/lib/pgsql/data/postgresql.conf" lsb_script="/etc/init.d/postgresql-9.0" pgsqlrecovery="/var/lib/pgsql/data/recovery.conf" meta clone-max="2" clone-node-max="1" master-max="1" master-node-max="1" notify="false" clone clone-ping ping meta globally-unique="false" ā€¢ We conļ¬gure the PostgreSQL M/S: the init script, the conļ¬guration ļ¬les. . . ā€¢ We also conļ¬gure the ping resource as a clone (it will be launched on both servers) Julien Pivotto PostgreSQL 9.0 HA
  • 25. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Set up of corosync OCF resource crm.conf Deļ¬ning the nodes group PSQL virt_ip location connected PSQL rule $id="connected-rule" -inf: not_defined pingd or pingd lte 0 colocation ip_psql inf: PSQL pgsql-ms:Master property $id="cib-bootstrap-options" cluster-infrastructure="openais" expected-quorum-votes="2" stonith-enabled="false" no-quorum-policy="ignore" default-resource-stickiness="INFINITY" rsc_defaults $id="rsc_defaults-options" migration-threshold="INFINITY" failure-timeout="10" resource-stickiness="INFINITY" ā€¢ These lines will ensure that the master is always on the same node as the ļ¬‚oating IP address ā€¢ And also that the master is connected to the router Julien Pivotto PostgreSQL 9.0 HA
  • 26. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Set up of corosync OCF resource OCF resource ā€¢ There is a custom OCF resource to manage the master/slave PostgreSQL ā€¢ It is based on an example of resource written by Andrew Beekhof from Clusterlabs ā€¢ The ļ¬le has to be in /usr/lib/ocf/resource.d/inuits/pgsql-ms Julien Pivotto PostgreSQL 9.0 HA
  • 27. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Set up of corosync OCF resource OCF resource ā€¢ The script does the following: ā€¢ It moves the postgresql.conf-master to postgresql.conf when a node is promoted/master ā€¢ It moves the postgresql.conf-slave to postgresql.conf when a node is depromoted/slave ā€¢ It ensure that recovery.conf-slave is on recovery.conf on slave and absent on master ā€¢ It starts/restarts PostgreSQL when needed. ā€¢ I will post that ļ¬le on Github soon Julien Pivotto PostgreSQL 9.0 HA
  • 28. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Cron jobs BackupPC Backups of the databases ā€¢ Sometimes, you need backups (especially when you donā€™t have backups. . . ) ā€¢ We do a backup per hour on each node (one at minute 0 and one at minute 30) ā€¢ We do a backup per day on each node ā€¢ We do a backup per day on before BackupPC backup on each node. ā€¢ We keep 24 hourly backups and 7 daily backups on disk ā€¢ With BackupPC we keep months of backups Julien Pivotto PostgreSQL 9.0 HA
  • 29. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Cron jobs BackupPC Hourly backup script /usr/local/bin/backup_hourly.sh #!/bin/bash DATE=$(date +%H) BACKUP_PATH=/var/lib/backups/hourly for db in foobar_db foobar2_db do /usr/bin/pg_dump $db | gzip > $BACKUP_PATH/${db}_$DATE.pgsql.gz ln -fs $BACKUP_PATH/${db}_$DATE.pgsql.gz $BACKUP_PATH/${db}_current.pgsql.gz done The daily script is almost the same. Julien Pivotto PostgreSQL 9.0 HA
  • 30. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Cron jobs BackupPC BackupPC script /usr/local/bin/backup_backuppc.sh #!/bin/bash DATE=$(date +%u) BACKUP_PATH=/var/lib/backups/backuppc for db in cerise trackitquality trackit zodb_cerise do /usr/bin/pg_dump -U postgres $db | gzip > $BACKUP_PATH/${db}_$DATE.pgsql.gz ln -fs $BACKUP_PATH/${db}_$DATE.pgsql.gz $BACKUP_PATH/${db}_current.pgsql.gz done In the backupPC conļ¬g, I added the following: BackupPC config $Conf{DumpPreUserCmd} = ā€˜$sshPath -t -q -x -l backuppc $host /usr/local/bin/backup_backuppc.shā€™; Julien Pivotto PostgreSQL 9.0 HA
  • 31. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Nagios Munin check_postgres script ā€¢ The check_postgres.pl is a nagios-compatible perl script ā€¢ Available on http://www.bucardo.org/check_postgres/ and on Github ā€¢ What we check with it: ā€¢ The current connections ā€¢ The status of the replication (the delay) Julien Pivotto PostgreSQL 9.0 HA
  • 32. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Nagios Munin Check hot_standby latency ā€¢ The check_postgres.pl script has a check for hot_standby delay ā€¢ But we do not know who is the master and the slave, and it is required to launch the script ā€¢ So, here is a bash script I wrote to know the M/S order Master/slave replication check #!/bin/bash /usr/lib64/nagios/plugins/check_postgres.pl --db="$1" --action hot_standby_delay -w 300 -c 600 --host=$( crm_resource --resource pgsql-ms --locate| awk ā€˜/Master/ {master=$6} / $/ {slave=$6} END {print master","slave}ā€™ ) Julien Pivotto PostgreSQL 9.0 HA
  • 33. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Nagios Munin Munin postgres scripts ā€¢ Munin is shipped with perl plugins for postgresql ā€¢ We use four of them: ā€¢ postgres_size, ā€¢ postgres_checkpoints, ā€¢ postgres_connections_db, ā€¢ postgres_cache Julien Pivotto PostgreSQL 9.0 HA
  • 35. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Puppet module The node ļ¬le #TODO Puppet module ā€¢ The puppet postgres module is forked from Kris Buytaertā€™s github page ā€¢ It is modiļ¬ed to remove all references to services, because we want corosync to manage them ā€¢ It creates the users, the super users, the databases ā€¢ It is a parameterized class, with a "cluster" parameter. So we can also install simple PostgreSQL ā€¢ The cache sizes are parameterized too, so we can also use that in Vagrant boxes ā€¢ Here are some examples from the module I will upload on Github ASAP Julien Pivotto PostgreSQL 9.0 HA
  • 36. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Puppet module The node ļ¬le #TODO Class postgres The postgres class installs the packages and makes the initdb stuļ¬€. init.pp class postgres ( $cluster = ā€˜noā€™, $running_ip = ā€˜127.0.0.1ā€™ ){ ... ā€¢ The cluster parameter indicates if we want or not clustering ā€¢ running_ip is used for the SQL commands. In case of a cluster, you have to put clusteā€™s IP address here. Julien Pivotto PostgreSQL 9.0 HA
  • 37. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Puppet module The node ļ¬le #TODO Sqlexec deļ¬nition sqlexec.pp define postgres::sqlexec($username, $database, $sql, $sqlcheck) { exec{ "psql -h $postgres::running_ip ā€“username=${username} $database -c ĀØ${sql}ĀØ>> /var/log/puppet-postgresql.sql.log 2>&1 && /bin/sleep 5": environment => "PGPASSWORD=${postgres_password}", path => $::path, timeout => 600, unless => "psql -h $postgres::running_ip -U $username $database -c $sqlcheck", require => Service[ā€™postgresql-9.0ā€™], } } Julien Pivotto PostgreSQL 9.0 HA
  • 38. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Puppet module The node ļ¬le #TODO Example in the node ļ¬le Here is the result in the node ļ¬le: dumbo.pp node babar { class { ā€™postgresā€™: cluster => ā€™yesā€™, running_ip => ā€™10.0.10.10ā€™, } include postgres::munin include postgres::backup include cluster::node postgres::config{ $::fqdn: listen => ā€™*ā€™, } Julien Pivotto PostgreSQL 9.0 HA
  • 39. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Puppet module The node ļ¬le #TODO Example in the node ļ¬le dumbo.pp postgres::hba { $::fqdn: allowedrules => [ "host all all $::ipaddress/32 trust", ā€™hostnossl all all 10.0.10.8/32 trustā€™, ā€™hostnossl all all 10.0.10.9/32 trustā€™, ā€™hostnossl all all 10.0.10.10/32 trustā€™, ā€™hostnossl replication replicuser 192.168.177.2/24 trustā€™, ], } Julien Pivotto PostgreSQL 9.0 HA
  • 40. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Puppet module The node ļ¬le #TODO Example in the node ļ¬le dumbo.pp postgres::createsuperuser{ ā€™replicuserā€™: passwd => ā€™foobarā€™, } postgres::createuser{ ā€™ceriseā€™: passwd => ā€™foobarā€™; } postgres::createdb{ ā€™zodb_ceriseā€™: owner => ā€™ceriseā€™, require => Postgres::Createuser[ā€™ceriseā€™], } } Julien Pivotto PostgreSQL 9.0 HA
  • 41. ; Overview PostgreSQL 9.0 Clustering Backups Monitoring Automation The end Puppet module The node ļ¬le #TODO #TODO ā€¢ The ļ¬rst synchronisation is not puppetized ā€¢ More advanced checks on the database #monitoringsucks (e.g. slow queries) ā€¢ A disaster recovery ā€¢ Improve the ocf script ā€¢ Check the content of the backups ā€¢ . . . Julien Pivotto PostgreSQL 9.0 HA