Pgsql Sync Notes

Source: Internet
Author: User
Tags rsync

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.