I am reading tutorials on how to setup streaming replication in Postgres from master to slave.
Some tutorials recommend setting up archiving in the master (and restoring in slave) . In the master, this needs to be set in the conf file:
wal_level = hot_standby
archive_mode = on
archive_command = 'some rsync command to rsync logfile segments from master to slave'
What is the purpose of this archiving? When is it not necessary when setting up streaming replication?
1 Answer 1
WAL archiving is useful when you're running streaming replication, because there's a limit to how much WAL the master will retain.
If you don't archive WAL, and the replica gets s far behind that the master has discarded WAL it still needs, it cannot recover and must be replaced with a fresh base backup from the master.
It's also useful for PITR for disaster recovery purposes.
-
is it too late to setup archiving when I already had the replication from master to slave running for a long time? If I can, should I restart the slave first?Henley Wing Chiu– Henley Wing Chiu2014年02月10日 03:23:06 +00:00Commented Feb 10, 2014 at 3:23
-
@HenleyChiu You can start WAL archiving at any time. You'll need to restart the replica to set a
recovery.conf
entry for therestore_command
. The master may also need restarting to set anarchive_command
.Craig Ringer– Craig Ringer2014年02月10日 03:24:29 +00:00Commented Feb 10, 2014 at 3:24 -
should I restart the slave first then the master?Henley Wing Chiu– Henley Wing Chiu2014年02月10日 03:46:58 +00:00Commented Feb 10, 2014 at 3:46
-
@HenleyChiu WAL archiving is asynchronous, so it doesn't really matter, does it?Craig Ringer– Craig Ringer2014年02月10日 04:43:50 +00:00Commented Feb 10, 2014 at 4:43