CentOS7 PostgreSQL Master-slave configuration (i)

Source: Internet
Author: User

Main Library Configuration

Pg_hba.conf

Host replication All 10.2.0.0/0 Trust

Postgresql.conf

listen_addresses = ' * ' max_wal_senders = 5wal_level = Hot_standby

Restarting the main library

Configure from Library

Installation
Install with Yum (source http://yum.postgresql.org/)

Yum Install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/ Pgdg-centos95-9.5-2.noarch.rpmyum Install Postgresql95-server Postgresql95-contrib

Generate base Backup (primary database IP 10.2.0.14)

Pg_basebackup-h 10.2.0.14-u postgres-f P--x-r-d/var/lib/pgsql/9.5/data/-L postgresbackup20160506

View the build file (note the permissions of the file, user group)

Ls-l/VAR/LIB/PGSQL/9.5/DATA-RW-------. 1 Postgres postgres 197 May 6 13:11 backup_label.olddrwx------. 6 Postgres postgres 50 May 6 13:11 basedrwx------. 2 Postgres postgres 4096 May 6 13:38 globaldrwx------. 2 Postgres postgres 17 May 6 13:11 pg_clogdrwx------. 2 Postgres postgres 6 May 6 13:11 pg_commit_tsdrwx------. 2 Postgres postgres 6 May 6 13:11 pg_dynshmem-rw-------. 1 postgres postgres 4214 May 6 13:11 pg_hba.conf-rw-------. 1 Postgres postgres 1636 May 6 13:11 pg_ident.confdrwx------. 2 Postgres postgres 56 May 6 13:11 pg_logdrwx------. 4 Postgres postgres 37 May 6 13:11 pg_logicaldrwx------. 4 Postgres postgres 34 May 6 13:11 pg_multixactdrwx------. 2 Postgres postgres 17 May 6 13:38 pg_notifydrwx------. 2 Postgres postgres 6 May 6 13:11 pg_replslotdrwx------. 2 Postgres postgres 6 May 6 13:11 pg_serialdrwx------. 2 Postgres postgres 6 May 6 13:11 pg_snapshotsdrwx------. 2 Postgres postgres 6 May 6 13:11 pg_statdrwx------. 2 Postgres postgres 6 May 6 13:11 pg_stat_tmpdrwx------. 2 PostgreS Postgres 17 May 6 13:11 pg_subtransdrwx------. 2 Postgres postgres 6 May 6 13:11 pg_tblspcdrwx------. 2 Postgres postgres 6 May 6 13:11 pg_twophase-rw-------. 1 Postgres postgres 4 May 6 13:11 pg_versiondrwx------. 3 Postgres postgres 89 May 6 13:29 PG_XLOG-RW-------. 1 Postgres postgres 88 May 6 13:11 POSTGRESQL.AUTO.CONF-RW-------. 1 postgres postgres 21756 May 6 13:38 postgresql.conf-rw-------. 1 Postgres postgres 59 May 6 13:38 POSTMASTER.OPTS-RW-------. 1 Postgres postgres 87 May 6 13:38 postmaster.pid-rw-r--r--. 1 Postgres postgres 140 May 6 13:35 recovery.conf
Cat recovery.conf Standby_mode = ' on ' primary_conninfo = ' user=postgres host=10.2.0.14 port=5432 sslmode=disable Sslcompression=1 '

Modify POSTGRESQL.CONF (otherwise startup failure error: Postgresql-9.5.service start operation timed out. terminating.)

Hot_standdby=on

Start from library

Systemctl start Postgresql-9.5.servicesystemctl Enable Postgresql-9.5.service

Test

Main Library Operations view synchronization results from the library

Psql-U postgres Postgres=# \llist of Databasesname| Owner | Encoding | Collate | Ctype |Access Privileges-----------+----------+----------+-------------+-------------+-----------------------Postgres| Postgres | UTF8 | en_US. utf-8| en_US. utf-8|Template0| Postgres | UTF8 | en_US. utf-8| en_US. utf-8| =c/postgres +| | | | | postgres=ctc/postgrestemplate1| Postgres | UTF8 | en_US. utf-8| en_US. utf-8| =c/postgres +| | | | | postgres=ctc/postgrestest| Postgres | UTF8 | en_US. utf-8| en_US. utf-8| (4rows) Postgres=# \c Testest=# CREATE TABLE test01 (IDintprimary key,note text); CREATE tabletest=# \dlist of Relationsschema| Name | Type |Owner--------+--------+-------+---------- Public| test01 | Table |Postgres (1row) test=# INSERT into test01 values (1,'1111'); INSERT0 1Test=# INSERT into test01 values (2,'2222'); INSERT0 1Test=# INSERT into test01 values (4,'4444'); INSERT0 1Test=# INSERT into test01 values (5,'5555'); INSERT0 1Test=# \qSelect* fromTest01;id|Note----+------1|11112|22224|44445|5555

CentOS7 PostgreSQL Master-slave configuration (i)

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.