Pgsql synchronization mode is based on the master log to do synchronization, there are two ways to synchronize, reference
Http://www.chinaxing.org/articles/Postgres/2012/12/14/2012-12-14-hight-availability-in-postgresql.html
Pgsql logs have an auto-recycle feature, and if some log discoveries are not needed, Pgsql will rename them and overwrite them with the new log; This poses a problem if the logs sent to the standby are not all well-done, but the master does not already have the problem, so Pgsql provides an interface to configure Archive_command in the postgresql.conf, which is used to invoke commands configured here at the time of the stream replication. The official Wiki example is CP to the custom log directory (you can self-rsync to the standby machine, if you use Rsync,master on the wal_keep_segments also to set a larger, to prevent the completion of rsync before the log is not), Modify the recovery.conf on the standby, configure the Restore_command, and the command will be called.
About 9.1 New Pg_basebackup command, with suggested with Rsync, see http://blog.163.com/[email protected]/blog/static/ 16387704020133277305874
Example of archive mode, pro-test pass
Master's postgresql.conf
Wal_level =3='mkdir-p p_archive;cp-i%p Pg_ archive/%f'
Slave's recovery.conf, temporarily find a place to put it.
Standby_mode ='host=192.168.1.111 user=repuser password=123456' cp pg_archive/%f%p'#某个时候会自动调用cleanup清理, default Pg_archivecleanup not installed, requires apt-get Install postgresql-'pg_archivecleanup pg_archive%r'
Test on slave using Pg_basebackup to synchronize
sudo service PostgreSQL stop;sudo rm-rf/var/lib/postgresql/9.4192.168. 1.111 -d/var/lib/postgresql/9.4/main-u repuser-v-p;sudo cp/home/mmc/desktop/ recovery.conf/var/lib/postgresql/9.4/main/;sudo service PostgreSQL start;
Pgsql Sync Notes