SlideShare a Scribd company logo
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
Managing replication
clusters
with repmgr, Barman and PgBouncer
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
Disclaimer/copyright
All content and images are created by/owned by 2ndQuadrant.
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
TOPICS
Using these three applications to manage
PostgreSQL replication and HA:
● Barman
● repmgr
● PgBouncer
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
What is HA?
●
Recovery Point Objective (RPO)
●
Recovery Time Objective (RTO)
Both as close to zero as possible/feasible
●
HA needs:
●
planning
●
documentation
●
practice
●
monitoring
●
HA involves tradeoffs
●
Many ways of implementing it
●
Keep systems up-to-date!!!
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
Replication and all that
● replication: not HA by itself
● replication: sounds simple, is complicated
● archiving: sounds boring, but essential
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
Types of replication
● streaming replication
● logical replication
● multi-master replication
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
Terminology
● archive-centric
SELECT pg_is_in_recovery()
● Master, primary...
● Standby, slave, replica...
● Streaming replication, binary replication, physical replication...
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
Overview
What are
– repmgr
– barman
– pgbouncer
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
repmgr
● replication manager
● two main roles
– set up and manage a replication cluster
– automatic failover and monitoring
● License: GPL
● current version: 4.0.4
● https://repmgr.org
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
simple repmgr setup
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
complex repmgr setup
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
repmgr commands
● primary register/unregister
● standby clone
● standby register/unregister
● standby promote
● standby follow
● standby switchover
● node rejoin
● node status
● witness register
● witness unregister
● cluster show
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
barman
● backup and recovery manager
● among others:
– takes (incremental) backups
– archives WAL
– serves WAL
● License: GPL
● current version: 2.3
● http://www.pgbarman.org/
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
Main Barman commands
● archive-wal
● backup
● check
● cron
● delete
● get-wal
● list-backup
● list-files
● list-server
● receive-wal
● recover
● show-backup
● show-server
● replication-status
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
pgbouncer
● lightweight connection pooler
● useful functionality
– lowers performance impact of PostgreSQL connections
– can divert connections to other servers
● License: ISC (BSD-ish)
● current version: 1.8.1 (Dec 2018)
● https://pgbouncer.github.io/
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
barman - a quick demo (1)
● sample configuration file (Barman server only)
[barman]
barman_home = /home/barman
barman_user = barman
log_file = /var/log/barman/barman.log
compression = gzip
reuse_backup = link
minimum_redundancy = 2
retention_policy = RECOVERY WINDOW OF 4 WEEKS
streaming_archiver = on
[test_cluster]
description = "Repmgr Test Cluster"
ssh_command = ssh -q localhost
conninfo = host=127.0.0.1 user=postgres port=5501
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
barman - a quick demo (2)
● take a backup:
$ barman backup test_cluster
Starting backup using rsync-exclusive method for server test in /home/barman/test_cluster/base/
20161028T151425
Backup start at xlog location: 0/5000028 (000000010000000000000005, 00000028)
Copying files.
Copy done.
Asking PostgreSQL server to finalize the backup.
Backup size: 29.2 MiB. Actual size on disk: 158.4 KiB (-99.47% deduplication ratio).
Backup end at xlog location: 0/5000130 (000000010000000000000005, 00000130)
Backup completed
Processing xlog segments from file archival for test
000000010000000000000004
000000010000000000000005
000000010000000000000005.00000028.backup
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
barman - a quick demo (3)
● list backup(s)
$ barman list-backup test_cluster
test_cluster 20180301T124344 - Thu Mar 1 12:43:47 2018 - Size: 28.5 MiB - WAL Size: 0 B
test_cluster 20180301T121110 - Thu Mar 1 12:11:21 2018 - Size: 28.4 MiB - WAL Size: 54.8 KiB
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
barman - a quick demo (4)
● backup detail
$ barman show-backup test 20180301T124344
Backup 20180301T124344:
Server Name : test
Status : DONE
PostgreSQL Version : 90605
PGDATA directory : /tmp/repmgr-test/node_1/data
Base backup information:
Disk usage : 28.4 MiB (28.5 MiB with WALs)
Incremental size : 142.3 KiB (-99.51%)
Timeline : 1
Begin WAL : 000000010000000000000005
End WAL : 000000010000000000000005
WAL number : 1
WAL compression ratio: 99.84%
Begin time : 2018-03-01 12:43:44.721340+09:00
End time : 2018-03-01 12:43:47.314113+09:00
Begin Offset : 40
End Offset : 248
Begin XLOG : 0/5000028
End XLOG : 0/50000F8
WAL information:
No of files : 0
Disk usage : 0 B
Last available : 000000010000000000000005
Catalog information:
Retention Policy : VALID
Previous Backup : 20180301T121110
Next Backup : - (this is the latest base backup)
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
barman - a quick demo (5)
● restore from backup
● various kinds of PITR recovery also available
$ barman recover --remote-ssh-command "ssh postgres@remotehost" test_cluster last 
/var/lib/postgresql/data
Starting remote restore for server test using backup 20180301T124344
Destination directory: /var/lib/postgresql/data
Copying the base backup.
Copying required WAL segments.
Generating archive status files
Identify dangerous settings in destination directory.
WARNING
You are required to review the following options as potentially dangerous
postgresql.conf line 643: include = 'postgresql.replication.conf'
postgresql.conf line 644: include = 'postgresql.local.conf'
Your PostgreSQL server has been successfully prepared for recovery!
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
repmgr - a quick demo (1)
● sample configuration file (per-node)
node_id=2
node_name=node2
conninfo='host=localhost dbname=repmgr user=repmgr port=5502'
data_directory='/var/lib/pgsql/data'
# barman settings
barman_server=barman.local
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
repmgr - a quick demo (2)
● clone a standby... from the Barman backup!
● recovery.conf looks like this:
$ repmgr -D /tmp/repmgr-test/node_2/data 
-f /tmp/repmgr-test/node_2/repmgr.conf 
-h localhost -p 5501 -d repmgr -U repmgr --verbose -LINFO 
standby clone
[2016-11-01 12:12:25] [NOTICE] using configuration file "/tmp/repmgr-test/node_2/repmgr.conf"
[2016-11-01 12:12:25] [NOTICE] destination directory '/tmp/repmgr-test/node_2/data' provided
[2016-11-01 12:12:25] [INFO] Connecting to Barman server to verify backup for test_cluster
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
[2016-11-01 12:12:25] [INFO] creating directory "/tmp/repmgr-test/node_2/data/repmgr"...
[2016-11-01 12:12:25] [INFO] Connecting to Barman server to fetch server parameters
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
[2016-11-01 12:12:26] [INFO] connecting to upstream node
[2016-11-01 12:12:26] [INFO] connected to upstream node, checking its state
[2016-11-01 12:12:26] [INFO] Successfully connected to upstream node. Current installation size is 28 MB
[2016-11-01 12:12:26] [NOTICE] getting backup from Barman...
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
[2016-11-01 12:12:28] [NOTICE] standby clone (from Barman) complete
[2016-11-01 12:12:28] [NOTICE] you can now start your PostgreSQL server
[2016-11-01 12:12:28] [HINT] for example : pg_ctl -D /tmp/repmgr-test/node_2/data start
[2016-11-01 12:12:28] [HINT] After starting the server, you need to register this standby with
"repmgr standby register"
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
repmgr - a quick demo (3)
● recovery.conf looks like this:
● barman-wal-restore script does the “ heavy lifting” of fetching WAL
– from barman 2.0 part of the barman-cli package
standby_mode = 'on'
primary_conninfo = 'user=repmgr port=5501 host=localhost application_name=node2'
recovery_target_timeline = 'latest'
restore_command = 'barman-wal-restore barman.local test_cluster %f %p'
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
back to barman - keep the WAL flowing
● WAL retention management - tricky
● use barman in the restore command
● removes need to manage:
– wal_keep_segments
– replication slots
– archive_cleanup_command
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
repmgrd demo (1)
● repmgrd-specific configuration in repmgr.conf
node_id=2
node_name=node2
conninfo='host=node2 dbname=repmgr user=repmgr connect_timeout=2'
data_directory='/var/lib/pgsql/data'
# barman settings
barman_server=barman
#repmgrd settings
failover=automatic
promote_command='repmgr standby promote'
follow_command='repmgr standby follow --wait --upstream-node-id=%n'
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
repmgrd demo (2)
● Time to say goodbye to the primary...
● Standby promotes itself
pg_ctl -D /var/lib/pgsql/data/ -m immediate stop
[2018-03-20 13:54:02] [INFO] node "node2" (node ID: 2) monitoring upstream node "node1" (node ID: 1) in normal
state
[2018-03-20 13:54:14] [WARNING] unable to connect to upstream node "node1" (node ID: 1)
[2018-03-20 13:54:14] [INFO] checking state of node 1, 1 of 5 attempts
[2018-03-20 13:54:14] [INFO] sleeping 1 seconds until next reconnection attempt
[2018-03-20 13:54:15] [INFO] checking state of node 1, 2 of 5 attempts
[2018-03-20 13:54:15] [INFO] sleeping 1 seconds until next reconnection attempt
[2018-03-20 13:54:16] [INFO] checking state of node 1, 3 of 5 attempts
[2018-03-20 13:54:16] [INFO] sleeping 1 seconds until next reconnection attempt
[2018-03-20 13:54:17] [INFO] checking state of node 1, 4 of 5 attempts
[2018-03-20 13:54:17] [INFO] sleeping 1 seconds until next reconnection attempt
[2018-03-20 13:54:18] [INFO] checking state of node 1, 5 of 5 attempts
[2018-03-20 13:54:18] [WARNING] unable to reconnect to node 1 after 5 attempts
[2018-03-20 13:54:18] [NOTICE] this node is the only available candidate and will now promote itself
NOTICE: promoting standby to primary
DETAIL: promoting server "node2" (ID: 2) using "/home/ibarwick/devel/builds/94/bin/pg_ctl -l
/tmp/postgres.5502.log -m fast -w -D '/space/sda1/ibarwick/repmgr-test/node_2/data' promote"
NOTICE: STANDBY PROMOTE successful
DETAIL: server "node2" (ID: 2) was successfully promoted to primary
[2018-03-20 13:54:19] [NOTICE] 0 followers to notify
[2018-03-20 13:54:19] [INFO] switching to primary monitoring mode
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
repmgrd failover mechanism
● quorum vote
● individual standbys can have different priorities
● witness server to establish qualified majority
● concept of “locations”
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
repmgrd event notifications
● repmgr/repmgrd generate “event notifications”
● “after” trigger for certain events
● recorded in the repmgr metadatabase
● can be used to execute custom scripts
● following events can generated when repmgrd is running:
– repmgrd_start
– repmgrd_shutdown
– repmgrd_failover_promote
– repmgrd_failover_follow
– standby_promote
– standby_follow
– standby_disconnect_manual
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
repmgr event log
● Logs info about events of note
$ repmgr cluster event --terse
Node ID | Name | Event | OK | Timestamp
---------+-------+--------------------------+----+---------------------
2 | node2 | repmgrd_reload | t | 2018-03-20 13:54:19
2 | node2 | repmgrd_failover_promote | t | 2018-03-20 13:54:19
2 | node2 | standby_promote | t | 2018-03-20 13:54:19
2 | node2 | repmgrd_start | t | 2018-03-20 13:53:30
1 | node1 | repmgrd_start | t | 2018-03-20 13:53:27
2 | node2 | standby_register_sync | t | 2018-03-20 13:53:24
2 | node2 | standby_register | t | 2018-03-20 13:53:24
2 | node2 | standby_clone | t | 2018-03-20 13:53:23
1 | node1 | primary_register | t | 2018-03-20 13:53:11
1 | node1 | cluster_created | t | 2018-03-20 13:53:11
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
PgBouncer - concepts
● PgBouncer intercepts incoming PostgreSQL connections
● Re-routes these to local or remote databases
– acts as both pooler and proxy
● Provides a “virtual database” for issuing commands
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
PgBouncer - configuration
● simple example
[pgbouncer]
listen_addr = *
listen_port = 6432
[databases]
appdb-rw= host=node1 dbname=repmgr
appdb-ro= host=node2 dbname=repmgr
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
pgbouncer console
$ psql 'host=localhost user=postgres port=6501 dbname=pgbouncer'
psql (9.6.0, server 1.7.2/bouncer)
Type "help" for help.
pgbouncer=# show help;
NOTICE: Console usage
DETAIL:
SHOW HELP|CONFIG|DATABASES|POOLS|CLIENTS|SERVERS|VERSION
SHOW STATS|FDS|SOCKETS|ACTIVE_SOCKETS|LISTS|MEM
SHOW DNS_HOSTS|DNS_ZONES
SET key = arg
RELOAD
PAUSE [<db>]
RESUME [<db>]
DISABLE <db>
ENABLE <db>
KILL <db>
SUSPEND
SHUTDOWN
SHOW
Time: 0.140 ms
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
pgbouncer connections
● connect to the primary:
● connect to the standby:
$ psql 'host=node2 user=repmgr port=6432 dbname=repmgr-rw'
psql (9.6.5)
Type "help" for help.
repmgr-rw=# CREATE TABLE foo (id INT);
CREATE TABLE
Time: 4.636 ms
$ psql 'host=node2 user=repmgr port=6432 dbname=repmgr-ro'
psql (9.6.5)
Type "help" for help.
repmgr-ro=# CREATE TABLE foo (id INT);
ERROR: cannot execute CREATE TABLE in a read-only transaction
Time: 0.867 ms
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
Putting it all together
● Custom promote_command
● Performs following steps:
– pauses PgBouncer
– promotes the standby
– dynamically rewrites PgBouncer config file
– reloads PgBouncer config
– resumes PgBouncer
● barman reconfiguration not implemented
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
PgBouncer – use include file
● [database] section as include file:
Note: %include directive available from PgBouncer 1.6
[pgbouncer]
listen_addr = *
listen_port = 6432
%include /etc/pgbouncer.database.ini
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
Script (1) - variables
● Assuming PgBouncer running on DB node:
#!/usr/bin/env bash
set -u
set -e
# Configurable items
PGBOUNCER_HOSTS="node1 node2 node3"
PGBOUNCER_DATABASE_INI="/etc/pgbouncer.database.ini"
PGBOUNCER_DATABASE="appdb"
PGBOUNCER_PORT=6432
REPMGR_DB="repmgr"
REPMGR_USER="repmgr"
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
Script (2) – pause/promote
● PgBouncer paused while standby promoted
# 1. Pause running pgbouncer instances
for HOST in $PGBOUNCER_HOSTS
do
psql -t -c "pause" -h $HOST -p $PGBOUNCER_PORT 
-U postgres pgbouncer
done
# 2. Promote this node from standby to primary
repmgr standby promote -f /etc/repmgr.conf
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
Script (3) – reconfigure
● Rewrite [databases] section
# 3. Reconfigure pgbouncer instances
PGBOUNCER_DATABASE_INI_NEW="/tmp/pgbouncer.database.ini"
for HOST in $PGBOUNCER_HOSTS
do
# Recreate the pgbouncer config file
echo -e "[databases]n" > $PGBOUNCER_DATABASE_INI_NEW
psql -d $REPMGR_DB -U $REPMGR_USER -t -A 
-c "SELECT '${PGBOUNCER_DATABASE}-rw= ' || conninfo ||  '
application_name=pgbouncer_${HOST}' 
FROM repmgr.nodes 
WHERE active = TRUE AND type='primary'" 
>> $PGBOUNCER_DATABASE_INI_NEW
psql -d $REPMGR_DB -U $REPMGR_USER -t -A 
-c "SELECT '${PGBOUNCER_DATABASE}-ro= ' || conninfo || 
' application_name=pgbouncer_${HOST}' 
FROM repmgr.nodes 
WHERE node_name='${HOST}'"
>> $PGBOUNCER_DATABASE_INI_NEW
rsync $PGBOUNCER_DATABASE_INI_NEW $HOST:$PGBOUNCER_DATABASE_INI
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
Script (4) – reload and resume
● Reload and resume PgBouncer
psql -tc "reload" -h $HOST -p $PGBOUNCER_PORT -U postgres pgbouncer
psql -tc "resume" -h $HOST -p $PGBOUNCER_PORT -U postgres pgbouncer
done
# Clean up generated file
rm $PGBOUNCER_DATABASE_INI_NEW
echo "Reconfiguration of pgbouncer complete"
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
Notes
● This is an example implementation
● Use provisioning!
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
Advantages/disadvantages
● Advantages
– can be set up on an existing cluster
– application level solution
● Disadvantages
– depends on SSH being available
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
Outlook
● Make replication simpler
● Support for BDR, pglogical
● Further integration between applications
https://www.2ndQuadrant.com
PGConf APAC 2018
Singapore, March 22nd
ご清聴ありがとうございました
Ian Barwick
ian@2ndquadrant.com

More Related Content

What's hot

PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander KukushkinPGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
Equnix Business Solutions
 
20180503 kube con eu kubernetes metrics deep dive
20180503 kube con eu   kubernetes metrics deep dive20180503 kube con eu   kubernetes metrics deep dive
20180503 kube con eu kubernetes metrics deep dive
Bob Cotton
 
Time series denver an introduction to prometheus
Time series denver   an introduction to prometheusTime series denver   an introduction to prometheus
Time series denver an introduction to prometheus
Bob Cotton
 
PGConf.ASIA 2019 Bali - Patroni in 2019 - Alexander Kukushkin
PGConf.ASIA 2019 Bali - Patroni in 2019 - Alexander KukushkinPGConf.ASIA 2019 Bali - Patroni in 2019 - Alexander Kukushkin
PGConf.ASIA 2019 Bali - Patroni in 2019 - Alexander Kukushkin
Equnix Business Solutions
 
Optimizing S3 Write-heavy Spark workloads
Optimizing S3 Write-heavy Spark workloadsOptimizing S3 Write-heavy Spark workloads
Optimizing S3 Write-heavy Spark workloads
datamantra
 
PGConf.ASIA 2019 Bali - Your Business Continuity Matrix and PostgreSQL's Disa...
PGConf.ASIA 2019 Bali - Your Business Continuity Matrix and PostgreSQL's Disa...PGConf.ASIA 2019 Bali - Your Business Continuity Matrix and PostgreSQL's Disa...
PGConf.ASIA 2019 Bali - Your Business Continuity Matrix and PostgreSQL's Disa...
Equnix Business Solutions
 
Kubernetes Colorado - Kubernetes metrics deep dive 10/25/2017
Kubernetes Colorado - Kubernetes metrics deep dive 10/25/2017Kubernetes Colorado - Kubernetes metrics deep dive 10/25/2017
Kubernetes Colorado - Kubernetes metrics deep dive 10/25/2017
Bob Cotton
 
PGConf.ASIA 2019 Bali - How did PostgreSQL Write Load Balancing of Queries Us...
PGConf.ASIA 2019 Bali - How did PostgreSQL Write Load Balancing of Queries Us...PGConf.ASIA 2019 Bali - How did PostgreSQL Write Load Balancing of Queries Us...
PGConf.ASIA 2019 Bali - How did PostgreSQL Write Load Balancing of Queries Us...
Equnix Business Solutions
 
PGConf.ASIA 2019 Bali - Modern PostgreSQL Monitoring & Diagnostics - Mahadeva...
PGConf.ASIA 2019 Bali - Modern PostgreSQL Monitoring & Diagnostics - Mahadeva...PGConf.ASIA 2019 Bali - Modern PostgreSQL Monitoring & Diagnostics - Mahadeva...
PGConf.ASIA 2019 Bali - Modern PostgreSQL Monitoring & Diagnostics - Mahadeva...
Equnix Business Solutions
 
Nginx monitoring with graphite
Nginx monitoring with graphiteNginx monitoring with graphite
Nginx monitoring with graphite
damaex17
 
Query and audit logging in cassandra
Query and audit logging in cassandraQuery and audit logging in cassandra
Query and audit logging in cassandra
Vinay Kumar Chella
 
SF Big Analytics 2019112: Uncovering performance regressions in the TCP SACK...
 SF Big Analytics 2019112: Uncovering performance regressions in the TCP SACK... SF Big Analytics 2019112: Uncovering performance regressions in the TCP SACK...
SF Big Analytics 2019112: Uncovering performance regressions in the TCP SACK...
Chester Chen
 
HTTP Analytics for 6M requests per second using ClickHouse, by Alexander Boc...
HTTP Analytics for 6M requests per second using ClickHouse, by  Alexander Boc...HTTP Analytics for 6M requests per second using ClickHouse, by  Alexander Boc...
HTTP Analytics for 6M requests per second using ClickHouse, by Alexander Boc...
Altinity Ltd
 
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
Aleksander Alekseev
 
Enabling presto to handle massive scale at lightning speed
Enabling presto to handle massive scale at lightning speedEnabling presto to handle massive scale at lightning speed
Enabling presto to handle massive scale at lightning speed
Shubham Tagra
 
Eventually, Scylla Chooses Consistency
Eventually, Scylla Chooses ConsistencyEventually, Scylla Chooses Consistency
Eventually, Scylla Chooses Consistency
ScyllaDB
 
Our Story With ClickHouse at seo.do
Our Story With ClickHouse at seo.doOur Story With ClickHouse at seo.do
Our Story With ClickHouse at seo.do
Metehan Çetinkaya
 
Python and trending_data_ops
Python and trending_data_opsPython and trending_data_ops
Python and trending_data_ops
chase pettet
 
Fluentd: Data streams in Ruby world #rdrc2014
Fluentd: Data streams in Ruby world #rdrc2014Fluentd: Data streams in Ruby world #rdrc2014
Fluentd: Data streams in Ruby world #rdrc2014SATOSHI TAGOMORI
 
Streaming millions of Contact Center interactions in (near) real-time with Pu...
Streaming millions of Contact Center interactions in (near) real-time with Pu...Streaming millions of Contact Center interactions in (near) real-time with Pu...
Streaming millions of Contact Center interactions in (near) real-time with Pu...
Frank Kelly
 

What's hot (20)

PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander KukushkinPGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
PGConf.ASIA 2019 Bali - PostgreSQL on K8S at Zalando - Alexander Kukushkin
 
20180503 kube con eu kubernetes metrics deep dive
20180503 kube con eu   kubernetes metrics deep dive20180503 kube con eu   kubernetes metrics deep dive
20180503 kube con eu kubernetes metrics deep dive
 
Time series denver an introduction to prometheus
Time series denver   an introduction to prometheusTime series denver   an introduction to prometheus
Time series denver an introduction to prometheus
 
PGConf.ASIA 2019 Bali - Patroni in 2019 - Alexander Kukushkin
PGConf.ASIA 2019 Bali - Patroni in 2019 - Alexander KukushkinPGConf.ASIA 2019 Bali - Patroni in 2019 - Alexander Kukushkin
PGConf.ASIA 2019 Bali - Patroni in 2019 - Alexander Kukushkin
 
Optimizing S3 Write-heavy Spark workloads
Optimizing S3 Write-heavy Spark workloadsOptimizing S3 Write-heavy Spark workloads
Optimizing S3 Write-heavy Spark workloads
 
PGConf.ASIA 2019 Bali - Your Business Continuity Matrix and PostgreSQL's Disa...
PGConf.ASIA 2019 Bali - Your Business Continuity Matrix and PostgreSQL's Disa...PGConf.ASIA 2019 Bali - Your Business Continuity Matrix and PostgreSQL's Disa...
PGConf.ASIA 2019 Bali - Your Business Continuity Matrix and PostgreSQL's Disa...
 
Kubernetes Colorado - Kubernetes metrics deep dive 10/25/2017
Kubernetes Colorado - Kubernetes metrics deep dive 10/25/2017Kubernetes Colorado - Kubernetes metrics deep dive 10/25/2017
Kubernetes Colorado - Kubernetes metrics deep dive 10/25/2017
 
PGConf.ASIA 2019 Bali - How did PostgreSQL Write Load Balancing of Queries Us...
PGConf.ASIA 2019 Bali - How did PostgreSQL Write Load Balancing of Queries Us...PGConf.ASIA 2019 Bali - How did PostgreSQL Write Load Balancing of Queries Us...
PGConf.ASIA 2019 Bali - How did PostgreSQL Write Load Balancing of Queries Us...
 
PGConf.ASIA 2019 Bali - Modern PostgreSQL Monitoring & Diagnostics - Mahadeva...
PGConf.ASIA 2019 Bali - Modern PostgreSQL Monitoring & Diagnostics - Mahadeva...PGConf.ASIA 2019 Bali - Modern PostgreSQL Monitoring & Diagnostics - Mahadeva...
PGConf.ASIA 2019 Bali - Modern PostgreSQL Monitoring & Diagnostics - Mahadeva...
 
Nginx monitoring with graphite
Nginx monitoring with graphiteNginx monitoring with graphite
Nginx monitoring with graphite
 
Query and audit logging in cassandra
Query and audit logging in cassandraQuery and audit logging in cassandra
Query and audit logging in cassandra
 
SF Big Analytics 2019112: Uncovering performance regressions in the TCP SACK...
 SF Big Analytics 2019112: Uncovering performance regressions in the TCP SACK... SF Big Analytics 2019112: Uncovering performance regressions in the TCP SACK...
SF Big Analytics 2019112: Uncovering performance regressions in the TCP SACK...
 
HTTP Analytics for 6M requests per second using ClickHouse, by Alexander Boc...
HTTP Analytics for 6M requests per second using ClickHouse, by  Alexander Boc...HTTP Analytics for 6M requests per second using ClickHouse, by  Alexander Boc...
HTTP Analytics for 6M requests per second using ClickHouse, by Alexander Boc...
 
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
 
Enabling presto to handle massive scale at lightning speed
Enabling presto to handle massive scale at lightning speedEnabling presto to handle massive scale at lightning speed
Enabling presto to handle massive scale at lightning speed
 
Eventually, Scylla Chooses Consistency
Eventually, Scylla Chooses ConsistencyEventually, Scylla Chooses Consistency
Eventually, Scylla Chooses Consistency
 
Our Story With ClickHouse at seo.do
Our Story With ClickHouse at seo.doOur Story With ClickHouse at seo.do
Our Story With ClickHouse at seo.do
 
Python and trending_data_ops
Python and trending_data_opsPython and trending_data_ops
Python and trending_data_ops
 
Fluentd: Data streams in Ruby world #rdrc2014
Fluentd: Data streams in Ruby world #rdrc2014Fluentd: Data streams in Ruby world #rdrc2014
Fluentd: Data streams in Ruby world #rdrc2014
 
Streaming millions of Contact Center interactions in (near) real-time with Pu...
Streaming millions of Contact Center interactions in (near) real-time with Pu...Streaming millions of Contact Center interactions in (near) real-time with Pu...
Streaming millions of Contact Center interactions in (near) real-time with Pu...
 

Similar to PGConf APAC 2018 - Managing replication clusters with repmgr, Barman and PgBouncer

Swapping Pacemaker Corosync with repmgr
Swapping Pacemaker Corosync with repmgrSwapping Pacemaker Corosync with repmgr
Swapping Pacemaker Corosync with repmgr
PGConf APAC
 
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)Wei Shan Ang
 
TechEvent Performance Analyses on Standby Database
TechEvent Performance Analyses on Standby DatabaseTechEvent Performance Analyses on Standby Database
TechEvent Performance Analyses on Standby Database
Trivadis
 
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
 
Monitoring Kafka w/ Prometheus
Monitoring Kafka w/ PrometheusMonitoring Kafka w/ Prometheus
Monitoring Kafka w/ Prometheus
kawamuray
 
Percona XtraDB 集群安装与配置
Percona XtraDB 集群安装与配置Percona XtraDB 集群安装与配置
Percona XtraDB 集群安装与配置
YUCHENG HU
 
Backups
BackupsBackups
Backups
Payal Singh
 
Percona Live 2022 - PBM - The Backup Open Source Tool for MongoDB
Percona Live 2022 - PBM - The Backup Open Source Tool for MongoDBPercona Live 2022 - PBM - The Backup Open Source Tool for MongoDB
Percona Live 2022 - PBM - The Backup Open Source Tool for MongoDB
Jean Da Silva
 
How To Install Openbravo ERP 2.50 MP43 in Ubuntu
How To Install Openbravo ERP 2.50 MP43 in UbuntuHow To Install Openbravo ERP 2.50 MP43 in Ubuntu
How To Install Openbravo ERP 2.50 MP43 in Ubuntu
Wirabumi Software
 
Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)
Anastasia Lubennikova
 
Schema replication using oracle golden gate 12c
Schema replication using oracle golden gate 12cSchema replication using oracle golden gate 12c
Schema replication using oracle golden gate 12c
uzzal basak
 
Automate Oracle database patches and upgrades using Fleet Provisioning and Pa...
Automate Oracle database patches and upgrades using Fleet Provisioning and Pa...Automate Oracle database patches and upgrades using Fleet Provisioning and Pa...
Automate Oracle database patches and upgrades using Fleet Provisioning and Pa...
Nelson Calero
 
Let the Tiger Roar! - MongoDB 3.0 + WiredTiger
Let the Tiger Roar! - MongoDB 3.0 + WiredTigerLet the Tiger Roar! - MongoDB 3.0 + WiredTiger
Let the Tiger Roar! - MongoDB 3.0 + WiredTiger
Jon Rangel
 
configuring a warm standby, the easy way
configuring a warm standby, the easy wayconfiguring a warm standby, the easy way
configuring a warm standby, the easy way
Command Prompt., Inc
 
A Step-By-Step Disaster Recovery Blueprint & Best Practices for Your NetBacku...
A Step-By-Step Disaster Recovery Blueprint & Best Practices for Your NetBacku...A Step-By-Step Disaster Recovery Blueprint & Best Practices for Your NetBacku...
A Step-By-Step Disaster Recovery Blueprint & Best Practices for Your NetBacku...
Symantec
 
BeeGFS Training.pdf
BeeGFS Training.pdfBeeGFS Training.pdf
BeeGFS Training.pdf
ssusercbaa33
 
Troubleshooting common oslo.messaging and RabbitMQ issues
Troubleshooting common oslo.messaging and RabbitMQ issuesTroubleshooting common oslo.messaging and RabbitMQ issues
Troubleshooting common oslo.messaging and RabbitMQ issues
Michael Klishin
 
Pitr Made Easy
Pitr Made EasyPitr Made Easy
Pitr Made Easy
Joshua Drake
 
Introduction to apache kafka
Introduction to apache kafkaIntroduction to apache kafka
Introduction to apache kafka
Samuel Kerrien
 
Troubleshooting containerized triple o deployment
Troubleshooting containerized triple o deploymentTroubleshooting containerized triple o deployment
Troubleshooting containerized triple o deployment
Sadique Puthen
 

Similar to PGConf APAC 2018 - Managing replication clusters with repmgr, Barman and PgBouncer (20)

Swapping Pacemaker Corosync with repmgr
Swapping Pacemaker Corosync with repmgrSwapping Pacemaker Corosync with repmgr
Swapping Pacemaker Corosync with repmgr
 
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)
pgDay Asia 2016 - Swapping Pacemaker-Corosync for repmgr (1)
 
TechEvent Performance Analyses on Standby Database
TechEvent Performance Analyses on Standby DatabaseTechEvent Performance Analyses on Standby Database
TechEvent Performance Analyses on Standby Database
 
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...
 
Monitoring Kafka w/ Prometheus
Monitoring Kafka w/ PrometheusMonitoring Kafka w/ Prometheus
Monitoring Kafka w/ Prometheus
 
Percona XtraDB 集群安装与配置
Percona XtraDB 集群安装与配置Percona XtraDB 集群安装与配置
Percona XtraDB 集群安装与配置
 
Backups
BackupsBackups
Backups
 
Percona Live 2022 - PBM - The Backup Open Source Tool for MongoDB
Percona Live 2022 - PBM - The Backup Open Source Tool for MongoDBPercona Live 2022 - PBM - The Backup Open Source Tool for MongoDB
Percona Live 2022 - PBM - The Backup Open Source Tool for MongoDB
 
How To Install Openbravo ERP 2.50 MP43 in Ubuntu
How To Install Openbravo ERP 2.50 MP43 in UbuntuHow To Install Openbravo ERP 2.50 MP43 in Ubuntu
How To Install Openbravo ERP 2.50 MP43 in Ubuntu
 
Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)
 
Schema replication using oracle golden gate 12c
Schema replication using oracle golden gate 12cSchema replication using oracle golden gate 12c
Schema replication using oracle golden gate 12c
 
Automate Oracle database patches and upgrades using Fleet Provisioning and Pa...
Automate Oracle database patches and upgrades using Fleet Provisioning and Pa...Automate Oracle database patches and upgrades using Fleet Provisioning and Pa...
Automate Oracle database patches and upgrades using Fleet Provisioning and Pa...
 
Let the Tiger Roar! - MongoDB 3.0 + WiredTiger
Let the Tiger Roar! - MongoDB 3.0 + WiredTigerLet the Tiger Roar! - MongoDB 3.0 + WiredTiger
Let the Tiger Roar! - MongoDB 3.0 + WiredTiger
 
configuring a warm standby, the easy way
configuring a warm standby, the easy wayconfiguring a warm standby, the easy way
configuring a warm standby, the easy way
 
A Step-By-Step Disaster Recovery Blueprint & Best Practices for Your NetBacku...
A Step-By-Step Disaster Recovery Blueprint & Best Practices for Your NetBacku...A Step-By-Step Disaster Recovery Blueprint & Best Practices for Your NetBacku...
A Step-By-Step Disaster Recovery Blueprint & Best Practices for Your NetBacku...
 
BeeGFS Training.pdf
BeeGFS Training.pdfBeeGFS Training.pdf
BeeGFS Training.pdf
 
Troubleshooting common oslo.messaging and RabbitMQ issues
Troubleshooting common oslo.messaging and RabbitMQ issuesTroubleshooting common oslo.messaging and RabbitMQ issues
Troubleshooting common oslo.messaging and RabbitMQ issues
 
Pitr Made Easy
Pitr Made EasyPitr Made Easy
Pitr Made Easy
 
Introduction to apache kafka
Introduction to apache kafkaIntroduction to apache kafka
Introduction to apache kafka
 
Troubleshooting containerized triple o deployment
Troubleshooting containerized triple o deploymentTroubleshooting containerized triple o deployment
Troubleshooting containerized triple o deployment
 

More from PGConf APAC

PGConf APAC 2018: Sponsored Talk by Fujitsu - The growing mandatory requireme...
PGConf APAC 2018: Sponsored Talk by Fujitsu - The growing mandatory requireme...PGConf APAC 2018: Sponsored Talk by Fujitsu - The growing mandatory requireme...
PGConf APAC 2018: Sponsored Talk by Fujitsu - The growing mandatory requireme...
PGConf APAC
 
PGConf APAC 2018 - Lightening Talk #3: How To Contribute to PostgreSQL
PGConf APAC 2018 - Lightening Talk #3: How To Contribute to PostgreSQLPGConf APAC 2018 - Lightening Talk #3: How To Contribute to PostgreSQL
PGConf APAC 2018 - Lightening Talk #3: How To Contribute to PostgreSQL
PGConf APAC
 
PGConf APAC 2018 - Lightening Talk #2 - Centralizing Authorization in PostgreSQL
PGConf APAC 2018 - Lightening Talk #2 - Centralizing Authorization in PostgreSQLPGConf APAC 2018 - Lightening Talk #2 - Centralizing Authorization in PostgreSQL
PGConf APAC 2018 - Lightening Talk #2 - Centralizing Authorization in PostgreSQL
PGConf APAC
 
Sponsored Talk @ PGConf APAC 2018 - Choosing the right partner in your Postgr...
Sponsored Talk @ PGConf APAC 2018 - Choosing the right partner in your Postgr...Sponsored Talk @ PGConf APAC 2018 - Choosing the right partner in your Postgr...
Sponsored Talk @ PGConf APAC 2018 - Choosing the right partner in your Postgr...
PGConf APAC
 
PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018
PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018
PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018
PGConf APAC
 
PGConf APAC 2018 - Where's Waldo - Text Search and Pattern in PostgreSQL
PGConf APAC 2018 - Where's Waldo - Text Search and Pattern in PostgreSQLPGConf APAC 2018 - Where's Waldo - Text Search and Pattern in PostgreSQL
PGConf APAC 2018 - Where's Waldo - Text Search and Pattern in PostgreSQL
PGConf APAC
 
PGConf APAC 2018 - PostgreSQL HA with Pgpool-II and whats been happening in P...
PGConf APAC 2018 - PostgreSQL HA with Pgpool-II and whats been happening in P...PGConf APAC 2018 - PostgreSQL HA with Pgpool-II and whats been happening in P...
PGConf APAC 2018 - PostgreSQL HA with Pgpool-II and whats been happening in P...
PGConf APAC
 
PGConf APAC 2018 - PostgreSQL performance comparison in various clouds
PGConf APAC 2018 - PostgreSQL performance comparison in various cloudsPGConf APAC 2018 - PostgreSQL performance comparison in various clouds
PGConf APAC 2018 - PostgreSQL performance comparison in various clouds
PGConf APAC
 
Sponsored Talk @ PGConf APAC 2018 - Migrating Oracle to EDB Postgres Approach...
Sponsored Talk @ PGConf APAC 2018 - Migrating Oracle to EDB Postgres Approach...Sponsored Talk @ PGConf APAC 2018 - Migrating Oracle to EDB Postgres Approach...
Sponsored Talk @ PGConf APAC 2018 - Migrating Oracle to EDB Postgres Approach...
PGConf APAC
 
PGConf APAC 2018 - Tale from Trenches
PGConf APAC 2018 - Tale from TrenchesPGConf APAC 2018 - Tale from Trenches
PGConf APAC 2018 - Tale from Trenches
PGConf APAC
 
Amazon (AWS) Aurora
Amazon (AWS) AuroraAmazon (AWS) Aurora
Amazon (AWS) Aurora
PGConf APAC
 
Use Case: PostGIS and Agribotics
Use Case: PostGIS and AgriboticsUse Case: PostGIS and Agribotics
Use Case: PostGIS and Agribotics
PGConf APAC
 
How to teach an elephant to rock'n'roll
How to teach an elephant to rock'n'rollHow to teach an elephant to rock'n'roll
How to teach an elephant to rock'n'roll
PGConf APAC
 
PostgreSQL on Amazon RDS
PostgreSQL on Amazon RDSPostgreSQL on Amazon RDS
PostgreSQL on Amazon RDS
PGConf APAC
 
PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs
PGConf APAC
 
Lightening Talk - PostgreSQL Worst Practices
Lightening Talk - PostgreSQL Worst PracticesLightening Talk - PostgreSQL Worst Practices
Lightening Talk - PostgreSQL Worst Practices
PGConf APAC
 
Lessons PostgreSQL learned from commercial databases, and didn’t
Lessons PostgreSQL learned from commercial databases, and didn’tLessons PostgreSQL learned from commercial databases, and didn’t
Lessons PostgreSQL learned from commercial databases, and didn’t
PGConf APAC
 
Query Parallelism in PostgreSQL: What's coming next?
Query Parallelism in PostgreSQL: What's coming next?Query Parallelism in PostgreSQL: What's coming next?
Query Parallelism in PostgreSQL: What's coming next?
PGConf APAC
 
Why we love pgpool-II and why we hate it!
Why we love pgpool-II and why we hate it!Why we love pgpool-II and why we hate it!
Why we love pgpool-II and why we hate it!
PGConf APAC
 
PostgreSQL: Past present Future
PostgreSQL: Past present FuturePostgreSQL: Past present Future
PostgreSQL: Past present Future
PGConf APAC
 

More from PGConf APAC (20)

PGConf APAC 2018: Sponsored Talk by Fujitsu - The growing mandatory requireme...
PGConf APAC 2018: Sponsored Talk by Fujitsu - The growing mandatory requireme...PGConf APAC 2018: Sponsored Talk by Fujitsu - The growing mandatory requireme...
PGConf APAC 2018: Sponsored Talk by Fujitsu - The growing mandatory requireme...
 
PGConf APAC 2018 - Lightening Talk #3: How To Contribute to PostgreSQL
PGConf APAC 2018 - Lightening Talk #3: How To Contribute to PostgreSQLPGConf APAC 2018 - Lightening Talk #3: How To Contribute to PostgreSQL
PGConf APAC 2018 - Lightening Talk #3: How To Contribute to PostgreSQL
 
PGConf APAC 2018 - Lightening Talk #2 - Centralizing Authorization in PostgreSQL
PGConf APAC 2018 - Lightening Talk #2 - Centralizing Authorization in PostgreSQLPGConf APAC 2018 - Lightening Talk #2 - Centralizing Authorization in PostgreSQL
PGConf APAC 2018 - Lightening Talk #2 - Centralizing Authorization in PostgreSQL
 
Sponsored Talk @ PGConf APAC 2018 - Choosing the right partner in your Postgr...
Sponsored Talk @ PGConf APAC 2018 - Choosing the right partner in your Postgr...Sponsored Talk @ PGConf APAC 2018 - Choosing the right partner in your Postgr...
Sponsored Talk @ PGConf APAC 2018 - Choosing the right partner in your Postgr...
 
PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018
PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018
PGConf APAC 2018 - A PostgreSQL DBAs Toolbelt for 2018
 
PGConf APAC 2018 - Where's Waldo - Text Search and Pattern in PostgreSQL
PGConf APAC 2018 - Where's Waldo - Text Search and Pattern in PostgreSQLPGConf APAC 2018 - Where's Waldo - Text Search and Pattern in PostgreSQL
PGConf APAC 2018 - Where's Waldo - Text Search and Pattern in PostgreSQL
 
PGConf APAC 2018 - PostgreSQL HA with Pgpool-II and whats been happening in P...
PGConf APAC 2018 - PostgreSQL HA with Pgpool-II and whats been happening in P...PGConf APAC 2018 - PostgreSQL HA with Pgpool-II and whats been happening in P...
PGConf APAC 2018 - PostgreSQL HA with Pgpool-II and whats been happening in P...
 
PGConf APAC 2018 - PostgreSQL performance comparison in various clouds
PGConf APAC 2018 - PostgreSQL performance comparison in various cloudsPGConf APAC 2018 - PostgreSQL performance comparison in various clouds
PGConf APAC 2018 - PostgreSQL performance comparison in various clouds
 
Sponsored Talk @ PGConf APAC 2018 - Migrating Oracle to EDB Postgres Approach...
Sponsored Talk @ PGConf APAC 2018 - Migrating Oracle to EDB Postgres Approach...Sponsored Talk @ PGConf APAC 2018 - Migrating Oracle to EDB Postgres Approach...
Sponsored Talk @ PGConf APAC 2018 - Migrating Oracle to EDB Postgres Approach...
 
PGConf APAC 2018 - Tale from Trenches
PGConf APAC 2018 - Tale from TrenchesPGConf APAC 2018 - Tale from Trenches
PGConf APAC 2018 - Tale from Trenches
 
Amazon (AWS) Aurora
Amazon (AWS) AuroraAmazon (AWS) Aurora
Amazon (AWS) Aurora
 
Use Case: PostGIS and Agribotics
Use Case: PostGIS and AgriboticsUse Case: PostGIS and Agribotics
Use Case: PostGIS and Agribotics
 
How to teach an elephant to rock'n'roll
How to teach an elephant to rock'n'rollHow to teach an elephant to rock'n'roll
How to teach an elephant to rock'n'roll
 
PostgreSQL on Amazon RDS
PostgreSQL on Amazon RDSPostgreSQL on Amazon RDS
PostgreSQL on Amazon RDS
 
PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs
 
Lightening Talk - PostgreSQL Worst Practices
Lightening Talk - PostgreSQL Worst PracticesLightening Talk - PostgreSQL Worst Practices
Lightening Talk - PostgreSQL Worst Practices
 
Lessons PostgreSQL learned from commercial databases, and didn’t
Lessons PostgreSQL learned from commercial databases, and didn’tLessons PostgreSQL learned from commercial databases, and didn’t
Lessons PostgreSQL learned from commercial databases, and didn’t
 
Query Parallelism in PostgreSQL: What's coming next?
Query Parallelism in PostgreSQL: What's coming next?Query Parallelism in PostgreSQL: What's coming next?
Query Parallelism in PostgreSQL: What's coming next?
 
Why we love pgpool-II and why we hate it!
Why we love pgpool-II and why we hate it!Why we love pgpool-II and why we hate it!
Why we love pgpool-II and why we hate it!
 
PostgreSQL: Past present Future
PostgreSQL: Past present FuturePostgreSQL: Past present Future
PostgreSQL: Past present Future
 

Recently uploaded

How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 

Recently uploaded (20)

How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 

PGConf APAC 2018 - Managing replication clusters with repmgr, Barman and PgBouncer

  • 1. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd Managing replication clusters with repmgr, Barman and PgBouncer
  • 2. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd Disclaimer/copyright All content and images are created by/owned by 2ndQuadrant.
  • 3. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd TOPICS Using these three applications to manage PostgreSQL replication and HA: ● Barman ● repmgr ● PgBouncer
  • 4. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd What is HA? ● Recovery Point Objective (RPO) ● Recovery Time Objective (RTO) Both as close to zero as possible/feasible ● HA needs: ● planning ● documentation ● practice ● monitoring ● HA involves tradeoffs ● Many ways of implementing it ● Keep systems up-to-date!!!
  • 5. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd Replication and all that ● replication: not HA by itself ● replication: sounds simple, is complicated ● archiving: sounds boring, but essential
  • 6. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd Types of replication ● streaming replication ● logical replication ● multi-master replication
  • 7. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd Terminology ● archive-centric SELECT pg_is_in_recovery() ● Master, primary... ● Standby, slave, replica... ● Streaming replication, binary replication, physical replication...
  • 8. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd Overview What are – repmgr – barman – pgbouncer
  • 9. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd repmgr ● replication manager ● two main roles – set up and manage a replication cluster – automatic failover and monitoring ● License: GPL ● current version: 4.0.4 ● https://repmgr.org
  • 12. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd repmgr commands ● primary register/unregister ● standby clone ● standby register/unregister ● standby promote ● standby follow ● standby switchover ● node rejoin ● node status ● witness register ● witness unregister ● cluster show
  • 13. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd barman ● backup and recovery manager ● among others: – takes (incremental) backups – archives WAL – serves WAL ● License: GPL ● current version: 2.3 ● http://www.pgbarman.org/
  • 14. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd Main Barman commands ● archive-wal ● backup ● check ● cron ● delete ● get-wal ● list-backup ● list-files ● list-server ● receive-wal ● recover ● show-backup ● show-server ● replication-status
  • 15. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd pgbouncer ● lightweight connection pooler ● useful functionality – lowers performance impact of PostgreSQL connections – can divert connections to other servers ● License: ISC (BSD-ish) ● current version: 1.8.1 (Dec 2018) ● https://pgbouncer.github.io/
  • 16. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd barman - a quick demo (1) ● sample configuration file (Barman server only) [barman] barman_home = /home/barman barman_user = barman log_file = /var/log/barman/barman.log compression = gzip reuse_backup = link minimum_redundancy = 2 retention_policy = RECOVERY WINDOW OF 4 WEEKS streaming_archiver = on [test_cluster] description = "Repmgr Test Cluster" ssh_command = ssh -q localhost conninfo = host=127.0.0.1 user=postgres port=5501
  • 17. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd barman - a quick demo (2) ● take a backup: $ barman backup test_cluster Starting backup using rsync-exclusive method for server test in /home/barman/test_cluster/base/ 20161028T151425 Backup start at xlog location: 0/5000028 (000000010000000000000005, 00000028) Copying files. Copy done. Asking PostgreSQL server to finalize the backup. Backup size: 29.2 MiB. Actual size on disk: 158.4 KiB (-99.47% deduplication ratio). Backup end at xlog location: 0/5000130 (000000010000000000000005, 00000130) Backup completed Processing xlog segments from file archival for test 000000010000000000000004 000000010000000000000005 000000010000000000000005.00000028.backup
  • 18. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd barman - a quick demo (3) ● list backup(s) $ barman list-backup test_cluster test_cluster 20180301T124344 - Thu Mar 1 12:43:47 2018 - Size: 28.5 MiB - WAL Size: 0 B test_cluster 20180301T121110 - Thu Mar 1 12:11:21 2018 - Size: 28.4 MiB - WAL Size: 54.8 KiB
  • 19. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd barman - a quick demo (4) ● backup detail $ barman show-backup test 20180301T124344 Backup 20180301T124344: Server Name : test Status : DONE PostgreSQL Version : 90605 PGDATA directory : /tmp/repmgr-test/node_1/data Base backup information: Disk usage : 28.4 MiB (28.5 MiB with WALs) Incremental size : 142.3 KiB (-99.51%) Timeline : 1 Begin WAL : 000000010000000000000005 End WAL : 000000010000000000000005 WAL number : 1 WAL compression ratio: 99.84% Begin time : 2018-03-01 12:43:44.721340+09:00 End time : 2018-03-01 12:43:47.314113+09:00 Begin Offset : 40 End Offset : 248 Begin XLOG : 0/5000028 End XLOG : 0/50000F8 WAL information: No of files : 0 Disk usage : 0 B Last available : 000000010000000000000005 Catalog information: Retention Policy : VALID Previous Backup : 20180301T121110 Next Backup : - (this is the latest base backup)
  • 20. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd barman - a quick demo (5) ● restore from backup ● various kinds of PITR recovery also available $ barman recover --remote-ssh-command "ssh postgres@remotehost" test_cluster last /var/lib/postgresql/data Starting remote restore for server test using backup 20180301T124344 Destination directory: /var/lib/postgresql/data Copying the base backup. Copying required WAL segments. Generating archive status files Identify dangerous settings in destination directory. WARNING You are required to review the following options as potentially dangerous postgresql.conf line 643: include = 'postgresql.replication.conf' postgresql.conf line 644: include = 'postgresql.local.conf' Your PostgreSQL server has been successfully prepared for recovery!
  • 21. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd repmgr - a quick demo (1) ● sample configuration file (per-node) node_id=2 node_name=node2 conninfo='host=localhost dbname=repmgr user=repmgr port=5502' data_directory='/var/lib/pgsql/data' # barman settings barman_server=barman.local
  • 22. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd repmgr - a quick demo (2) ● clone a standby... from the Barman backup! ● recovery.conf looks like this: $ repmgr -D /tmp/repmgr-test/node_2/data -f /tmp/repmgr-test/node_2/repmgr.conf -h localhost -p 5501 -d repmgr -U repmgr --verbose -LINFO standby clone [2016-11-01 12:12:25] [NOTICE] using configuration file "/tmp/repmgr-test/node_2/repmgr.conf" [2016-11-01 12:12:25] [NOTICE] destination directory '/tmp/repmgr-test/node_2/data' provided [2016-11-01 12:12:25] [INFO] Connecting to Barman server to verify backup for test_cluster Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts. [2016-11-01 12:12:25] [INFO] creating directory "/tmp/repmgr-test/node_2/data/repmgr"... [2016-11-01 12:12:25] [INFO] Connecting to Barman server to fetch server parameters Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts. [2016-11-01 12:12:26] [INFO] connecting to upstream node [2016-11-01 12:12:26] [INFO] connected to upstream node, checking its state [2016-11-01 12:12:26] [INFO] Successfully connected to upstream node. Current installation size is 28 MB [2016-11-01 12:12:26] [NOTICE] getting backup from Barman... Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts. Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts. Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts. [2016-11-01 12:12:28] [NOTICE] standby clone (from Barman) complete [2016-11-01 12:12:28] [NOTICE] you can now start your PostgreSQL server [2016-11-01 12:12:28] [HINT] for example : pg_ctl -D /tmp/repmgr-test/node_2/data start [2016-11-01 12:12:28] [HINT] After starting the server, you need to register this standby with "repmgr standby register"
  • 23. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd repmgr - a quick demo (3) ● recovery.conf looks like this: ● barman-wal-restore script does the “ heavy lifting” of fetching WAL – from barman 2.0 part of the barman-cli package standby_mode = 'on' primary_conninfo = 'user=repmgr port=5501 host=localhost application_name=node2' recovery_target_timeline = 'latest' restore_command = 'barman-wal-restore barman.local test_cluster %f %p'
  • 24. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd back to barman - keep the WAL flowing ● WAL retention management - tricky ● use barman in the restore command ● removes need to manage: – wal_keep_segments – replication slots – archive_cleanup_command
  • 25. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd repmgrd demo (1) ● repmgrd-specific configuration in repmgr.conf node_id=2 node_name=node2 conninfo='host=node2 dbname=repmgr user=repmgr connect_timeout=2' data_directory='/var/lib/pgsql/data' # barman settings barman_server=barman #repmgrd settings failover=automatic promote_command='repmgr standby promote' follow_command='repmgr standby follow --wait --upstream-node-id=%n'
  • 26. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd repmgrd demo (2) ● Time to say goodbye to the primary... ● Standby promotes itself pg_ctl -D /var/lib/pgsql/data/ -m immediate stop [2018-03-20 13:54:02] [INFO] node "node2" (node ID: 2) monitoring upstream node "node1" (node ID: 1) in normal state [2018-03-20 13:54:14] [WARNING] unable to connect to upstream node "node1" (node ID: 1) [2018-03-20 13:54:14] [INFO] checking state of node 1, 1 of 5 attempts [2018-03-20 13:54:14] [INFO] sleeping 1 seconds until next reconnection attempt [2018-03-20 13:54:15] [INFO] checking state of node 1, 2 of 5 attempts [2018-03-20 13:54:15] [INFO] sleeping 1 seconds until next reconnection attempt [2018-03-20 13:54:16] [INFO] checking state of node 1, 3 of 5 attempts [2018-03-20 13:54:16] [INFO] sleeping 1 seconds until next reconnection attempt [2018-03-20 13:54:17] [INFO] checking state of node 1, 4 of 5 attempts [2018-03-20 13:54:17] [INFO] sleeping 1 seconds until next reconnection attempt [2018-03-20 13:54:18] [INFO] checking state of node 1, 5 of 5 attempts [2018-03-20 13:54:18] [WARNING] unable to reconnect to node 1 after 5 attempts [2018-03-20 13:54:18] [NOTICE] this node is the only available candidate and will now promote itself NOTICE: promoting standby to primary DETAIL: promoting server "node2" (ID: 2) using "/home/ibarwick/devel/builds/94/bin/pg_ctl -l /tmp/postgres.5502.log -m fast -w -D '/space/sda1/ibarwick/repmgr-test/node_2/data' promote" NOTICE: STANDBY PROMOTE successful DETAIL: server "node2" (ID: 2) was successfully promoted to primary [2018-03-20 13:54:19] [NOTICE] 0 followers to notify [2018-03-20 13:54:19] [INFO] switching to primary monitoring mode
  • 27. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd repmgrd failover mechanism ● quorum vote ● individual standbys can have different priorities ● witness server to establish qualified majority ● concept of “locations”
  • 28. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd repmgrd event notifications ● repmgr/repmgrd generate “event notifications” ● “after” trigger for certain events ● recorded in the repmgr metadatabase ● can be used to execute custom scripts ● following events can generated when repmgrd is running: – repmgrd_start – repmgrd_shutdown – repmgrd_failover_promote – repmgrd_failover_follow – standby_promote – standby_follow – standby_disconnect_manual
  • 29. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd repmgr event log ● Logs info about events of note $ repmgr cluster event --terse Node ID | Name | Event | OK | Timestamp ---------+-------+--------------------------+----+--------------------- 2 | node2 | repmgrd_reload | t | 2018-03-20 13:54:19 2 | node2 | repmgrd_failover_promote | t | 2018-03-20 13:54:19 2 | node2 | standby_promote | t | 2018-03-20 13:54:19 2 | node2 | repmgrd_start | t | 2018-03-20 13:53:30 1 | node1 | repmgrd_start | t | 2018-03-20 13:53:27 2 | node2 | standby_register_sync | t | 2018-03-20 13:53:24 2 | node2 | standby_register | t | 2018-03-20 13:53:24 2 | node2 | standby_clone | t | 2018-03-20 13:53:23 1 | node1 | primary_register | t | 2018-03-20 13:53:11 1 | node1 | cluster_created | t | 2018-03-20 13:53:11
  • 30. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd PgBouncer - concepts ● PgBouncer intercepts incoming PostgreSQL connections ● Re-routes these to local or remote databases – acts as both pooler and proxy ● Provides a “virtual database” for issuing commands
  • 31. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd PgBouncer - configuration ● simple example [pgbouncer] listen_addr = * listen_port = 6432 [databases] appdb-rw= host=node1 dbname=repmgr appdb-ro= host=node2 dbname=repmgr
  • 32. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd pgbouncer console $ psql 'host=localhost user=postgres port=6501 dbname=pgbouncer' psql (9.6.0, server 1.7.2/bouncer) Type "help" for help. pgbouncer=# show help; NOTICE: Console usage DETAIL: SHOW HELP|CONFIG|DATABASES|POOLS|CLIENTS|SERVERS|VERSION SHOW STATS|FDS|SOCKETS|ACTIVE_SOCKETS|LISTS|MEM SHOW DNS_HOSTS|DNS_ZONES SET key = arg RELOAD PAUSE [<db>] RESUME [<db>] DISABLE <db> ENABLE <db> KILL <db> SUSPEND SHUTDOWN SHOW Time: 0.140 ms
  • 33. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd pgbouncer connections ● connect to the primary: ● connect to the standby: $ psql 'host=node2 user=repmgr port=6432 dbname=repmgr-rw' psql (9.6.5) Type "help" for help. repmgr-rw=# CREATE TABLE foo (id INT); CREATE TABLE Time: 4.636 ms $ psql 'host=node2 user=repmgr port=6432 dbname=repmgr-ro' psql (9.6.5) Type "help" for help. repmgr-ro=# CREATE TABLE foo (id INT); ERROR: cannot execute CREATE TABLE in a read-only transaction Time: 0.867 ms
  • 34. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd Putting it all together ● Custom promote_command ● Performs following steps: – pauses PgBouncer – promotes the standby – dynamically rewrites PgBouncer config file – reloads PgBouncer config – resumes PgBouncer ● barman reconfiguration not implemented
  • 35. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd PgBouncer – use include file ● [database] section as include file: Note: %include directive available from PgBouncer 1.6 [pgbouncer] listen_addr = * listen_port = 6432 %include /etc/pgbouncer.database.ini
  • 36. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd Script (1) - variables ● Assuming PgBouncer running on DB node: #!/usr/bin/env bash set -u set -e # Configurable items PGBOUNCER_HOSTS="node1 node2 node3" PGBOUNCER_DATABASE_INI="/etc/pgbouncer.database.ini" PGBOUNCER_DATABASE="appdb" PGBOUNCER_PORT=6432 REPMGR_DB="repmgr" REPMGR_USER="repmgr"
  • 37. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd Script (2) – pause/promote ● PgBouncer paused while standby promoted # 1. Pause running pgbouncer instances for HOST in $PGBOUNCER_HOSTS do psql -t -c "pause" -h $HOST -p $PGBOUNCER_PORT -U postgres pgbouncer done # 2. Promote this node from standby to primary repmgr standby promote -f /etc/repmgr.conf
  • 38. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd Script (3) – reconfigure ● Rewrite [databases] section # 3. Reconfigure pgbouncer instances PGBOUNCER_DATABASE_INI_NEW="/tmp/pgbouncer.database.ini" for HOST in $PGBOUNCER_HOSTS do # Recreate the pgbouncer config file echo -e "[databases]n" > $PGBOUNCER_DATABASE_INI_NEW psql -d $REPMGR_DB -U $REPMGR_USER -t -A -c "SELECT '${PGBOUNCER_DATABASE}-rw= ' || conninfo || ' application_name=pgbouncer_${HOST}' FROM repmgr.nodes WHERE active = TRUE AND type='primary'" >> $PGBOUNCER_DATABASE_INI_NEW psql -d $REPMGR_DB -U $REPMGR_USER -t -A -c "SELECT '${PGBOUNCER_DATABASE}-ro= ' || conninfo || ' application_name=pgbouncer_${HOST}' FROM repmgr.nodes WHERE node_name='${HOST}'" >> $PGBOUNCER_DATABASE_INI_NEW rsync $PGBOUNCER_DATABASE_INI_NEW $HOST:$PGBOUNCER_DATABASE_INI
  • 39. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd Script (4) – reload and resume ● Reload and resume PgBouncer psql -tc "reload" -h $HOST -p $PGBOUNCER_PORT -U postgres pgbouncer psql -tc "resume" -h $HOST -p $PGBOUNCER_PORT -U postgres pgbouncer done # Clean up generated file rm $PGBOUNCER_DATABASE_INI_NEW echo "Reconfiguration of pgbouncer complete"
  • 40. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd Notes ● This is an example implementation ● Use provisioning!
  • 41. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd Advantages/disadvantages ● Advantages – can be set up on an existing cluster – application level solution ● Disadvantages – depends on SSH being available
  • 42. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd Outlook ● Make replication simpler ● Support for BDR, pglogical ● Further integration between applications
  • 43. https://www.2ndQuadrant.com PGConf APAC 2018 Singapore, March 22nd ご清聴ありがとうございました Ian Barwick ian@2ndquadrant.com