Skip to content

Instantly share code, notes, and snippets.

@tarunbhardwaj
Created January 6, 2017 05:45
Show Gist options
  • Save tarunbhardwaj/939a018c62cd1414ca4bf6a4437c0dd0 to your computer and use it in GitHub Desktop.
Save tarunbhardwaj/939a018c62cd1414ca4bf6a4437c0dd0 to your computer and use it in GitHub Desktop.

SET UP POSTGRESQL 9.6 MASTER-SLAVE REPLICATION USING REPMGR

Follow this blog for 9.6 https://edwardsamuel.wordpress.com/2016/04/28/set-up-postgresql-9-5-master-slave-replication-using-repmgr/

Changes

Keep replication config separate as explained here.

While cloning slave use following:

POSTGRES_VERSION=9.6
sudo service postgresql stop
sudo -u postgres rm -r /var/lib/postgresql/${POSTGRES_VERSION}/main
sudo -u postgres repmgr -h repmgr_node1 -U repmgr -d repmgr -D /var/lib/postgresql/${POSTGRES_VERSION}/main -f /etc/repmgr.conf standby clone --copy-external-config-files=pgdata
# Do manually copy `postgresql.replication.conf` file also
sudo mv /var/lib/postgresql/${POSTGRES_VERSION}/main/pg_hba.conf /etc/postgresql/${POSTGRES_VERSION}/main/pg_hba.conf
sudo mv /var/lib/postgresql/${POSTGRES_VERSION}/main/postgresql.conf /etc/postgresql/${POSTGRES_VERSION}/main/postgresql.conf 
sudo mv /var/lib/postgresql/${POSTGRES_VERSION}/main/pg_ident.conf /etc/postgresql/${POSTGRES_VERSION}/main/pg_ident.conf
sudo service postgresql start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment