PostgreSQL Synchronous Stream Replication Setup

Source: Internet
Author: User
Tags postgresql

Node Ip Role
Master 10.10.100.1 Master
Standby1 10.10.100.2 Standby1
Standby2 10.10.100.3 Standby2

The user that is required to create the stream replication on master.

CREATE ROLE replication with replication PASSWORD ' replication ' LOGIN;

Modify Master's pg_hba.conf file to set replication user remote access permissions

# # vim/data/pgsql/data/pg_hba.conf, append the following line host replication replication 10.10.0.0/16 MD5

Setting parameters related to replication on master

Wal_level = Hot_standbymax_wal_senders = 5wal_keep_segments = 32synchronous_standby_names = ' standby01,standby02 '

Restart Pgsql on Master

/etc/init.d/postgresql-9.5 restart

All two standby need to get a basic, fully prepared

Pg_basebackup-h 10.10.100.1-d/var/lib/pgsql/9.5/data/-p-u replication-r--xlog-method=stream

The postgresql.conf file on the standby node needs to be modified on all two standby to set the state of standby for the repository.

# # Vim/data/pgsql/data/postgresql.confhot_standby = On

Modify the Standby1 recovery.c file, set the synchronization information of the master node and the trigger file

Standby_mode = ' on ' primary_conninfo = ' application_name=standby01 user=replication password=replication host= 10.10.100.1 port=5432 sslmode=prefer sslcompression=1 krbsrvname=postgres ' trigger_file = '/data/pgsql/data/ postgresql.trigger.1973 '

Modify the Standby1 recovery.conf file, set the synchronization information of the master node and the trigger file

Standby_mode = ' on ' primary_conninfo = ' application_name=standby02 user=replication password=replication host= 10.10.100.1 port=5432 sslmode=prefer sslcompression=1 krbsrvname=postgres '

Restart Pgsql on standby

/etc/init.d/postgresql-9.5 restart

You can create a test table on master and insert data to verify that the data is synchronized on the standby. When Master is hung up, the trigger_file parameter declaration file is created on standby, triggering standby activation, which automatically promotes standby to master.

This article from "Brave forward, resolutely left" blog, declined reprint!

PostgreSQL Synchronous Stream Replication Setup

Related Article

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.