forked from trbs/repmgr
-
Notifications
You must be signed in to change notification settings - Fork 2
QuickStart
xmm edited this page Aug 13, 2012
·
3 revisions
This is the QuickStart for using repmgr with pacemaker.
PostgreSQL version 9.0 is installed from pitti ppa.
Native Hot Standby Replication feature of PostgreSQl v9.0 is used for db replication.
Pacemaker (cluster resource manager) is used for automatic postgresql migration.
RepMgr package is modified for using as OCF ResourceAgent of Pacemaker.
Notice:
(Pri) - do this on primary server.
(Sec) - on secondary server.
(ALL) - on both servers.
- Prepare PostgreSQL
- (ALL) Install postgresql and run it.
- (Pri) Load databases and make optimization of postgresql. (optional. recommended for huge data.)
- (Pri) Shutdown PG.
- (ALL) update-rc.d -f postgresql remove
- (ALL) Rename /var/lib/postgresql/9.0 to /var/lib/postgresql/ha
- (ALL) Move config files postgresql.conf, pg_hba.conf, pg_ident.conf from /etc/postgresql/9.0/main to /var/lib/postgresql/ha/main
- Configure replication
- Set up trusted copy between postgres accounts
- (Pri) Create ssh key for postgres user
- (Pri) Put the public key into file ~postgres/.ssh/authorized_keys
- (Pri) Copy files authorized_keys id_rsa.pub id_rsa from primary to secondary server in dir /var/lib/postgresql/.ssh
- (All) Test that ssh in both directions works.
- (ALL) install my version of repmgr from https://github.com/downloads/xmm/repmgr/postgresql-repmgr-9.0_1.1.1.deb
- [https://github.com/xmm/repmgr Here's] good install guide. But don't run repmgrd daemon.
- (Pri) /var/lib/postgresql/ha/repmgr.conf:
cluster=main node=1 conninfo='host=srv01 user=repmgr dbname=postgres'
- (Pri) repmgr -f /var/lib/postgresql/ha/repmgr.conf --verbose master register
- (Sec) repmgr -D /var/lib/postgresql/ha/main -d postgres -U repmgr -R postgres --force standby clone srv01
- (Sec) /var/lib/postgresql/ha/repmgr.conf
cluster=main node=3 conninfo='host=srv03 user=repmgr dbname=postgres'
- (Sec) repmgr -f /var/lib/postgresql/ha/repmgr.conf --verbose standby register
- Add PostgreSQL to pacemaker
(ALL)mkdir /usr/lib/ocf/resource.d/<your_resource_dir> wget -O /usr/lib/ocf/resource.d//pgsql https://github.com/xmm/repmgr/blob/master/ocf-ra-pgsql
(Pri) Example of pacemaker's configuration with repmgr:
primitive dbip ocf:heartbeat:IPaddr2 \ params ip="10.0.0.200" cidr_netmask="24" nic="br1" primitive pgdb ocf::pgsql \ params repmgr_conf="/var/lib/postgresql/ha/repmgr.conf" pgctl="/usr/lib/postgresql/9.0/bin/pg_ctl" pgdata="/var/lib/postgresql/ha/main" logfile="/var/log/postgresql/postgresql-ha-main.log" \ op start interval="0" timeout="90s" \ op stop interval="0" timeout="60s" \ op promote interval="0" timeout="120s" \ op monitor interval="53s" role="Master" \ op monitor interval="60s" role="Slave" ms MS_pgdb pgdb \ meta clone-max="2" target-role="Started" resource-stickiness="100" notify="true" location LC-cl_pdns-srv01 CL_pdns -inf: srv01 location LC-ms_pgdb-srv01 MS_pgdb 200: srv01 location LC-ms_pgdb-srv03 MS_pgdb 150: srv02 colocation CO_pgdb_ip_master inf: dbip MS_pgdb:Master order OR-promote-pgdb-then-dbip inf: MS_pgdb:promote dbip:start property $id="cib-bootstrap-options" \ dc-version="1.0.8-042548a451fce8400660f6031f4da6f0223dd5dd" \ cluster-infrastructure="openais" \ stonith-enabled="false" \ expected-quorum-votes="3" \ symmetric-cluster="true" \ no-quorum-policy="freeze"