table of contents
other versions
- wheezy 2.1.13-2
WALMGR(1) | WALMGR(1) |
NAME¶
walmgr - tools for managing WAL-based replication for PostgreSQL.SYNOPSIS¶
walmgr.py <config.ini> command
DESCRIPTION¶
It is both admin and worker script for PostgreSQL PITR replication.QUICK START¶
1.Set up passwordless ssh authentication from
master to slave
master$ test -f ~/.ssh/id_dsa.pub || ssh-keygen -t dsa master$ cat ~/.ssh/id_dsa.pub | ssh slave cat \>\> .ssh/authorized_keys
2.Configure paths
master$ edit master.ini slave$ edit slave.ini
Make sure that walmgr.py executable has same pathname on slave and master.
3.Start archival process and create a base
backup
master$ ./walmgr.py master.ini setup master$ ./walmgr.py master.ini backup
Note: starting from PostgreSQL 8.3 the archiving is enabled by setting archive_mode GUC to on. However changing this parameter requires the server to be restarted.
4.Prepare postgresql.conf and pg_hba.conf on
slave and start replay
master$ scp $PGDATA/*.conf slave: slave$ ./walmgr.py slave.ini restore
For debian based distributions the standard configuration files are located in /etc/postgresql/x.x/main directory. If another scheme is used the postgresql.conf and pg_hba.conf should be copied to slave full_backup directory. Make sure to disable archive_command in slave config.
'walmgr.py restore' moves data in place, creates recovery.conf and starts postmaster in recovery mode.
5.In-progress WAL segments can be backup by
command:
master$ ./walmgr.py master.ini sync
6.If need to stop replay on slave and boot
into normal mode, do:
slave$ ./walmgr.py slave.ini boot
GENERAL OPTIONS¶
Common options to all walmgr.py commands. -h, --helpshow this help message and exit
-q, --quiet
make program silent
-v, --verbose
make program more verbose
-n, --not-really
Show what would be done without actually doing
anything.
MASTER COMMANDS¶
setup¶
Sets up postgres archiving, creates necessary directory structures on slave.sync¶
Synchronizes in-progress WAL files to slave.syncdaemon¶
Start WAL synchronization in daemon mode. This will start periodically synching the in-progress WAL files to slave.stop¶
Deconfigures postgres archiving.periodic¶
Runs periodic command, if configured. This enables to execute arbitrary commands on interval, useful for synchronizing scripts, config files, crontabs etc.listbackups¶
List backup sets available on slave node.backup¶
Creates a new base backup from master database. Will purge expired backups and WAL files on slave if keep_backups is specified. During a backup a lock file is created in slave completed_wals directory. This is to prevent simultaneous backups and resulting corruption. If running backup is terminated, the BACKUPLOCK file may have to be removed manually.restore <set> <dst>¶
EXPERIMENTAL. Attempts to restore the backup from slave to master.SLAVE COMMANDS¶
boot¶
Stop log playback and bring the database up.pause¶
Pauses WAL playback.continue¶
Continues previously paused WAL playback.listbackups¶
Lists available backups.backup¶
EXPERIMENTAL. Creates a new backup from slave data. Log replay is paused, slave data directory is backed up to full_backup directory and log replay resumed. Backups are rotated as needed. The idea is to move the backup load away from production node. Usable from postgres 8.2 and up.restore [src][dst]¶
Restores the specified backup set to target directory. If specified without arguments the latest backup is moved to slave data directory (doesn’t obey retention rules). If src backup is specified the backup is copied (instead of moving). Alternative destination directory can be specified with dst.CONFIGURATION¶
Common settings¶
job_nameMaster settings¶
pidfileSample master.ini¶
[wal-master] logfile = master.log pidfile = master.pid master_db = dbname=template1 master_data = /var/lib/postgresql/8.0/main master_config = /etc/postgresql/8.0/main/postgresql.conf slave = slave:/var/lib/postgresql/walshipping completed_wals = %(slave)s/logs.complete partial_wals = %(slave)s/logs.partial full_backup = %(slave)s/data.master loop_delay = 10.0 use_xlog_functions = 1 compression = 1
Slave settings¶
slave_dataSample slave.ini¶
[wal-slave] logfile = slave.log slave_data = /var/lib/postgresql/8.0/main slave_stop_cmd = /etc/init.d/postgresql-8.0 stop slave_start_cmd = /etc/init.d/postgresql-8.0 start slave = /var/lib/postgresql/walshipping completed_wals = %(slave)s/logs.complete partial_wals = %(slave)s/logs.partial full_backup = %(slave)s/data.master keep_backups = 5 backup_datadir = yes
03/13/2012 |