pitrtools is a Python + PostgreSQL application that assists in the provisioning of Hot Standby, Warm Standby, Cold Standby, Streaming Replication clusters and multiple standbys (slaves). It supports all PostgreSQL versions from 8.2+ including 9.2.
Requirements:
Rsync
Python >= 2.6
SSH
PostgreSQL 8.2+
# rpm -qa | grep rsync rsync-3.0.6-9.el6_4.1.x86_64 # python -V Python 2.6.6 $ pg_config --version PostgreSQL 9.3.4
编译安装:
pg_standby
pg_archivecleanup
[root@masterdb ~]# mkdir /opt/pg93/archive [root@masterdb ~]# chown postgres:postgres /opt/pg93/archive/ $ cd /opt/pitrtools-1.3/etc/ $ cp cmd_archiver.ini.sample cmd_archiver.ini $ cp cmd_standby.ini.sample cmd_standby.ini
cmd_standby
The cmd_standby script is a utility that allows easy management of all types of standby PostgreSQL servers, from cold to warm and streaming repliaction. It currently has the following capabilities: * Easily take a base backup, including table spaces * Restore archives * Automatically purge old archives (if PostgreSQL >8.3) * Alert based on failures * Stop and start PostgreSQL standby * Failover to the latest restore point and point-in-time recovery Usage: cmd_standby [options] arg1 arg2 Options: -h, --help show this help message and exit -A start|stop, --action=start|stop Start or Stop PostgreSQL -B, --basebackup Start/Stop a base backup -C FILE, --config=FILE the name of the standby config file -F VALUE, --failover=VALUE Value is a 3 digit number 999 -I, --dbinit Use before -B -P, --ping Is my master alive? -R TIMESTAMP, --recovertotime=TIMESTAMP If you need to restore to a specific point in time -S, --standby Enter standby mode
cmd_archiver
cmd_archiver script is used in conjunction with PostgreSQL's native archive mode functionality to ship WAL segments to configured standby server to replay them. * Automatically ship log files to configured standby server * Enable/disable archiving without the need to restart PostgreSQL * Alert based on failures Usage: cmd_archiver [options] arg1 arg2 Options: -h, --help Show this help message and exit -F FILE, --file=FILE Archive file -C FILE, --config=FILE The name of the archiver config file -f, --flush Flush all remaining archives to slave -I, --init Initialize master environment