2

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?

0

1 Answer 1

5

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.

4
  • 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? 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 the restore_command. The master may also need restarting to set an archive_command. Feb 10, 2014 at 3:24
  • should I restart the slave first then the master? Feb 10, 2014 at 3:46
  • @HenleyChiu WAL archiving is asynchronous, so it doesn't really matter, does it? Feb 10, 2014 at 4:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.