[postgres@test ~]$ pg_basebackup --help pg_basebackup takes a base backup of a running PostgreSQL server. Usage: pg_basebackup [OPTION]... Options controlling the output: -D, --pgdata=DIRECTORY receive base backup into directory -F, --format=p|t output format (plain (default), tar) -R, --write-recovery-conf write recovery.conf after backup -x, --xlog include required WAL files in backup (fetch mode) -X, --xlog-method=fetch|stream include required WAL files with specified method -z, --gzip compress tar output -Z, --compress=0-9 compress tar output with given compression level General options: -c, --checkpoint=fast|spread set fast or spread checkpointing -l, --label=LABEL set backup label -P, --progress show progress information -v, --verbose output verbose messages -V, --version output version information, then exit -?, --help show this help, then exit Connection options: -d, --dbname=CONNSTR connection string -h, --host=HOSTNAME database server host or socket directory -p, --port=PORT database server port number -s, --status-interval=INTERVAL time between status packets sent to server (in seconds) -U, --username=NAME connect as specified database user -w, --no-password never prompt for password -W, --password force password prompt (should happen automatically) Report bugs to .二、准备
[postgres@test ~]$ pg_basebackup -D /database/pgdata/ -Fp -Xs -v -P -h 10.1.11.73 -U repuser -p 5678 transaction log start point: 2/DF000028 on timeline 3 pg_basebackup: starting background WAL receiver 177422/177422 kB (100%), 1/1 tablespace transaction log end point: 2/DF015EE0 pg_basebackup: waiting for background process to finish streaming ... pg_basebackup: base backup completed四、同步后配置
standby_mode = 'on' trigger_file = '/database/pgdata/postgresql.trigger.1949' primary_conninfo = 'host=10.1.11.73 port=5678 user=repuser password=123456 keepalives_idle=60'
五、启动验证
pg_ctl -$PGDATA start
六、参考
http://my.oschina.net/Kenyon/blog/54967
http://www.depesz.com/2011/01/24/waiting-for-9-1-pg_basebackup/
http://francs3.blog.163.com/blog/static/4057672720136210240967/
七、其他
这个工具印象上是linux的rsync功能外加支持DB在线部署,简化了之前的三步操作,另外支持在线数据同步,不需要另外关闭服务保证数据统一