once the trigger is created on the master machine
standby_mode = on
primary_conninfo = 'host=22.214.171.124 port=5432 user=repl password=some_pass_here'
trigger_file = '/var/lib/postgresql/9.3/main/failover_trigger'
you need to create the file in the slave machine (replica) in-order to reconfigure itself to lunch your trigger
lets check the configuration after the installation is completed:
1) you need a ssh key,if you don't have one you can generate one for testing, but it will give you certificate error later by using
2)copy the certificate you had in step one to the other server:
3) create replica user by using
psql -c "CREATE USER rep REPLICATION LOGIN CONNECTION LIMIT 1 ENCRYPTED PASSWORD ' enter_your_password';
**Note the following steps need to be done while the service is down if you want to do it at the sometime otherwise you can repeat the steps for replica machine (slave).
4)open PostgreSQL directory
5)edit (pg_hba.conf) file note: take a backup from (
6) add the following line but make sure you font add it to the bottom of the file:
host replication rep IP_address_of_slave/32 md5
7) save and close
8) edit (
postgresql.conf) note you need to take backup first
9) search for the following parameters and um-comment them
listen_addresses = 'localhost,IP_address_of_THIS_host'
wal_level = 'hot_standby'
archive_mode = on
archive_command = 'cd .'
max_wal_senders = 1
hot_standby = on
10) save and close
11) start the master machine (main server that has the database make sure the replica service still down)
12) now you need to take backup from the master machine by using
psql -p $PORT -c "select pg_start_backup('$BACKUP_LABEL');"
rsync -cva --inplace --exclude=*pg_xlog* $PGDATA/ <IP_OF_OTHER_HOST>:$PGDATA/
psql -p $PORT -c "select pg_stop_backup();"
13) now open
recovery.conf on the replica server
standby_mode = 'on'
primary_conninfo = 'host=master_IP_address port=[unter port number] user=rep password=[enter rep password]'
trigger_file = '/tmp/postgresql.trigger.port'
14) start the replica server
15) make sure the ports are opened in the firewall.
16) to open the turn over you need to touch the trigger file that mentioned in the