Postgresql Master/slaver

Source: Internet
Author: User
Tags gpg md5 postgresql unix domain socket

1.Install PostgreSql9.3

A:yum Install

Copy Repository to:/ETC/YUM/YUM.REPOS.D

Yum-y Install Postgresql93-server Postgresql93-contrib--skip-broken

Yum Install http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-redhat95-9.5-2.noarch.rpm

sudo yum install postgresql95-server postgresql95-contrib

2.Install Postgres

yum  -y install postgresql93-server postgresql93-contrib
3.Master 配置
1.创建PG Data Dir
mkdir –p  /opt/postgresql/datamkdir –p  /opt/postgresql/data/archive chmod  /opt/postgresql/datasudochown postgres:postgres/opt/postgresql/data

2. Set profile

sudo vi /etc/profileexport PATH=/usr/pgsql-9.3/Bin: $PATHexport PGDATA=/opt/ postgresql/data/su  –postgresvi ~/. Bash_profileexport PATH=/usr/pgsql-9.3 /Bin: $PATHexport PGDATA=/opt/postgresql/data/

3.InitDB for Master

su  ---encoding=utf-8  --username=postgres--pwprompt--pgdata=/opt/postgresql/data/

4.配置文件

VI $PGDATA _home/pg_hba.conf
(replace"Ident"With"MD5") (#IPv4 local connections) host all192.168.1.1/ -MD5 (replace ident or peer with Trust) (#"Local"Is forUnix domain socket connections only) Local all-trust# allow REPL                                Ication connections from localhost, by a user with the# replication privilege. #local Replication Postgres Peer#host Replication Postgres127.0.0.1/ +identhost replication Postgres192.168.1.1/ -Trust

VI $PGDATA _home/postgresql.conf

' * '
5432

Wal_level = Hot_standby

Max_wal_senders = 5

Wal_keep_segments = 32

Archive_mode = On

Archive_command = ' cp%p/opt/postgresql/data/%f </dev/null '

checkpoint_segments = 8

5. Start Master DB

su  --d/opt/postgresql/data/-l logfile start
pg_ctl– D/var/lib/pgsql/9.3/data-"CREATE USER postgres REPLICATION LOGIN ENCRYPTED PASSWORD ' Conversant '; "

$psql
Postgres=# alter user postgres with password 'conversant';

4.Slave
4.1 Install Postgres
4.2 Configure Profile
4.3 Copy master data
Su192.168. 1.12 -d/opt/postgresql/data-u replicator-p-v-x

4.4 Configuration

VI $PGDATA _home/postgresql.conf

' * '  ==3 8 8

VI $PGDATA _home/recovery.conf

 sudo  su - CP /usr/pgsql-9.3 /share/ Recovery.conf.sample/opt/postgresql/data/chown   Postgres:postgres recovery.conf.sample  mv  recovery.conf.sample recovery.conf 
VI'host=192.168.1.12 port=5432 user=replicator password=conversant '  /opt/postgressql/data/trigger 'on'

5. Open Firewall 5432 Port



$sudo5432 –J ACCEPT
$sudo /etc/rc.d/init.d/iptables Save
$sudo /etc/init.d/iptables status

6. Start slave

su  --d/opt/postgresql/data/-L logfile Start
1. startpg_ctl-d/opt/postgresql/data/-l/opt/postgresql/data/logfile Start2. stoppg_ctl-d/opt/postgresql/data/-l/opt/postgresql/data/logfile--mode=fast stop3. restartpg_ctl-d/opt/postgresql/data/-l/opt/postgresql/data/logfile Restart

7. List of issues:

1.error Check sum:

Fix Error:yum primary.sqlite.bz2: [Errno-3] Error performing checksum Trying other mirror.

Enabled=0

2.GPG Key retrieval failed: [Errno 5] OSError

[Errno 2] No such file or directory: '/etc/pki/rpm-gpg/rpm-gpg-key-pgdg-93 '

Gpgcheck=0

Postgresql Master/slaver

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.