This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
streaming_replication [2011/07/25 15:48] k2patel created |
streaming_replication [2020/08/10 02:35] (current) |
||
---|---|---|---|
Line 10: | Line 10: | ||
==== postgresql.conf ==== | ==== postgresql.conf ==== | ||
- | <code ini> | + | <code bash> |
listen_addresses = '*' | listen_addresses = '*' | ||
- | port = 5435 // Only Define if you running on non default port. | + | port = 5435 #### Only Define if you running on non default port. |
escape_string_warning = off | escape_string_warning = off | ||
shared_buffers = 8192MB | shared_buffers = 8192MB | ||
Line 18: | Line 18: | ||
wal_level = hot_standby | wal_level = hot_standby | ||
archive_mode = on | archive_mode = on | ||
- | archive_command = 'cp %p /usr/local/postgres/data/pg_xlogarch/%f' | + | archive_command = 'rsync -a /usr/local/pg-9.0.3/Archive/%p <IP>:Archive/%f' |
max_wal_senders = 5 ####( this setting for 1 slave can connect with Master) | max_wal_senders = 5 ####( this setting for 1 slave can connect with Master) | ||
wal_keep_segments = 32 | wal_keep_segments = 32 | ||
Line 30: | Line 30: | ||
</code> | </code> | ||
- | pg_hba.conf | + | Setup access rule. |
- | ^^^^^^^^^^^ | + | |
+ | <code bash | pg_hba.conf> | ||
#Replication Trust | #Replication Trust | ||
hostssl replication all <IP>/32 trust | hostssl replication all <IP>/32 trust | ||
+ | </code> | ||
+ | Postgres restart on Master | ||
+ | <code bash> | ||
bin/pg_ctl -p bin/postmaster -D data -l pgstartup.log start | bin/pg_ctl -p bin/postmaster -D data -l pgstartup.log start | ||
bin/pg_ctl -p bin/postmaster -D data -l pgstartup.log stop | bin/pg_ctl -p bin/postmaster -D data -l pgstartup.log stop | ||
+ | </code> | ||
+ | Sync current data over Rsync. | ||
+ | <code bash> | ||
bin/psql -c "SELECT pg_start_backup('label', true)" | bin/psql -c "SELECT pg_start_backup('label', true)" | ||
rsync -av data/ <IP>:standby/ --exclude postmaster.pid | rsync -av data/ <IP>:standby/ --exclude postmaster.pid | ||
bin/psql -c "SELECT pg_stop_backup()" | bin/psql -c "SELECT pg_stop_backup()" | ||
+ | </code> | ||
+ | |||
+ | ==== Recovery.conf ==== | ||
+ | <code> | ||
+ | standby_mode = 'on' # to enable the standby (read-only) mode. | ||
+ | primary_conninfo = 'host=<IP> port=5432 user=postgres' | ||
+ | # primary_conninfo = 'host=127.0.0.1 port=5436 user=postgres' | ||
+ | # to specify a connection info to the master node. | ||
+ | trigger_file = '/var/lib/pgsql/tmp/pg_failover_trigger' | ||
+ | # to specify a trigger file to recognize a fail over. | ||
+ | restore_command = 'cp /var/lib/pgsql/Archive/%f "%p"' | ||
+ | # to specify a recovery command. | ||
+ | archive_cleanup_command = '/usr/local/pg-9.0.3/bin/pg_archivecleanup -d /usr/local/pg-9.0.3/Archive %r 2>>pg_log/cleanup.log' | ||
+ | </code> | ||
http://ketan.lithiumfox.com/doku.php?id=postgresql_replication_monitor | http://ketan.lithiumfox.com/doku.php?id=postgresql_replication_monitor |