Synchronous Postgresql
1. Install and initialize postgres
2. Create Postgres replication user
a. CREATE ROLE replication WITH REPLICATION PASSWORD
'password' LOGIN;
3. Open the appropriate ports
4. Allow replication Connection
a. Vi /var/lib/pgsql/9.4/data/pg_hba.conf
i. host replication replication slave_IP/32 trust
5. configure Streaming Parameters on master
a. vi /var/lib/pgsql/9.4/data/[Link]
i. WRITE AHEAD LOG section
1. wal_level = hot_standby # This sets slave server in
read-only mode
2. fsync = on # Force synchronization
3. synchronous_commit = on # Enable synchronous
commit
4. wal_sync_method = open_sync # Write WAL files
with open() option O_SYNC
ii. REPLICATION section
1. max_wal_senders = 1 # Max number of WAL senders
- one slave, one sender
2. synchronous_standby_names = 'slave_node1' #
Make this up, but remember it, will be used on slave
instance configuration file
6. Restart master server
7. Copy all data from master to slave **exclude [Link] and pg_hba.conf
a. rsync -avr --exclude [Link] --exclude pg_hba.conf
/var/lib/pgsql/ [Link]:/var/lib/pgsql/
Slave Parameters:
1. Configure streaming parameters on slave server
a. var/lib/pgsql/9.4/data/[Link]
i. hot_standby = on
ii. hot_standby_feedback = on
2. Create [Link] file
a. Vi /var/lib/pgsql/[Link]
i. standby_mode = 'on'
ii. primary_conninfo = 'host=master_IP port=5432
user=replication application_name=slave_node1'
iii.
b. change file ownership to postgres
i. chown postgres:postgres
/var/lib/pgsql/9.4/data/[Link]
ii. chmod 600 /var/lib/pgsql/9.4/data/[Link]
3. start slave server
4. check if recovering process is running
a. ps auxf |grep postgres
On Master
1. start master server
2. check if WAL process is running
3. check replication status
a. SELECT * FROM pg_stat_replication;
b.
On slave: