Database Reference
In-Depth Information
Files are sent when a file becomes full, or archive_timeout seconds have passed since
the transaction log was written by any user. If the server is writing no new transaction log data
for an extended period, then files will switch every checkpoint_timeout seconds; this is
normal, and not a problem.
The preceding configuration assumes that the archive is on the Standby, so the restore_
command shown is a simple copy command (cp). If the archive was on a third system, then we
would either need to mount the filesystem remotely, or use a network copy command.
The archive_cleanup_command ensures that the archive only holds the files the Standby
needs to restart if it should stop for any reason. Files older than the last file required are
deleted regularly to ensure that the archive does not overflow. Note that if the Standby is down
for any extended period, then the number of files in the archive will continue to accumulate
and eventually overflow. The number of files in the archive should also be monitored.
In the configuration shown, a contrib module named pg_archivecleanup is used to remove
files from the archive. This is a supplied module with PostgreSQL 9.0. pg_archivecleanup
is designed to work with one Standby node at a time. Note that pg_archivecleanup
requires two parameters: the archive directory and "%r", with a space between them.
PostgreSQL transforms %r into the cut-off filename.
If you wish to have multiple Standby nodes, then a shared archive would be a single point of
failure and should be avoided, so each Standby should maintain its own archive. We must
modify the archive_command to be a script, rather than executing the command directly.
This allows us to handle archiving to multiple destinations:
archive_command = 'myarchivescript %p %f'
and then we would write myarchivescript that looked somewhat like the following, though with
additional error checking to handle cases with down Standbys more cleanly:
scp $1 $STANDBYNODE1:$PGARCHIVE/$2
scp $1 $STANDBYNODE2:$PGARCHIVE/$2
scp $1 $STANDBYNODE3:$PGARCHIVE/$2
The initial copy, or base backup, is performed using the rsync utility, which may require you
to have direct security authorization, for example, using SSH and key exchange. You may
also choose to perform the base backup a different way; if so, feel free to substitute your
preferred method.
There's more...
Monitoring file-based log shipping can be performed in a number of ways. You can look at the
current files on both Master and Standby as follows:
ps -ef | grep archiver on master
postgres: archiver process last was 000000010000000000000040
 
Search WWH ::




Custom Search