replication¶
version 9.6¶
on primary¶
postgresql.conf
hot_standby = 'on'
hot_standby_feedback = 'on'
wal_level = 'logical'
wal_compression = 'on'
max_wal_senders = '20'
max_replication_slots = '40'
wal_keep_segments = '100'
reload configuration
or
create new replication slot
verify the slot creation
if you need to remove the created slot
on secondary¶
after install the same postgresql version from primary, do the initdb
.
/usr/pgsql-9.6/bin/initdb --pgdata=/var/lib/pgsql/9.6/data
# or
/usr/pgsql-9.6/bin/postgresql96-setup initdb
stop postgres and remove the data directory
create replicated db, with postgres
user. use tmux
for this.
/usr/pgsql-9.6/bin/pg_basebackup --pgdata=/var/lib/pgsql/9.6/data --write-recovery-conf --slot=the_slot_name --progress --host=10.0.3.33 --xlog-method=stream --checkpoint=fast
start the postgres service, with root
user, and using screen
too.
verify the status
go back to the primary and verify the stot status (active
field must be true
)