[postgres@king01 ~]$ cd /var/lib/pgsql/9.6/data [postgres@king01 data]$ vi pg_hba.conf host replication postgres 192.168.1.0/24 md5 [postgres@king01 data]$ vi postgresql.conf listen_addresses = '0.0.0.0' max_wal_senders = 5 wal_level = hot_standby [postgres@king01 data]$ pg_ctl restart waiting for server to shut down.... done server stopped server starting [root@king02 ~]# wget https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-centos96-9.6-3.noarch.rpm --no-check-certificate [root@king02 ~]# rpm -ivh pgdg-centos96-9.6-3.noarch.rpm [root@king02 ~]# useradd postgres [root@king02 ~]# id postgres uid=501(postgres) gid=501(postgres) groups=501(postgres) [root@king02 ~]# rpm -e postgresql postgresql-devel [root@king02 ~]# yum install -y postgresql96-server.x86_64 postgresql96-contrib.x86_64 [root@king02 ~]# vi /etc/profile PATH=$PATH:/usr/pgsql-9.6/bin [root@king02 ~]# su - postgres [postgres@king02 ~]$ pg_basebackup -h 192.168.1.201 -U postgres -F p -P -x -R -D /var/lib/pgsql/9.6/data Password: 2161085/2161085 kB (100%), 1/1 tablespace [postgres@king02 ~]$ cd /var/lib/pgsql/9.6/data [postgres@king02 data]$ ls -l total 124 -rw------- 1 postgres postgres 208 Apr 14 18:26 backup_label drwx------ 6 postgres postgres 4096 Apr 14 18:28 base drwx------ 2 postgres postgres 4096 Apr 14 18:28 global drwx------ 2 postgres postgres 4096 Apr 14 18:26 pg_clog drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_commit_ts drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_dynshmem -rw------- 1 postgres postgres 4290 Apr 14 18:28 pg_hba.conf -rw------- 1 postgres postgres 1636 Apr 14 18:28 pg_ident.conf drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_log drwx------ 4 postgres postgres 4096 Apr 14 18:28 pg_logical drwx------ 4 postgres postgres 4096 Apr 14 18:28 pg_multixact drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_notify drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_replslot drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_serial drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_snapshots drwx------ 2 postgres postgres 4096 Apr 14 18:26 pg_stat drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_stat_tmp drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_subtrans drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_tblspc drwx------ 2 postgres postgres 4096 Apr 14 18:28 pg_twophase -rw------- 1 postgres postgres 4 Apr 14 18:28 PG_VERSION drwx------ 3 postgres postgres 4096 Apr 14 18:28 pg_xlog -rw------- 1 postgres postgres 88 Apr 14 18:26 postgresql.auto.conf -rw------- 1 postgres postgres 22369 Apr 14 18:28 postgresql.conf -rw-rw-r-- 1 postgres postgres 154 Apr 14 18:28 recovery.conf [postgres@king02 data]$ cat recovery.conf standby_mode = 'on' primary_conninfo = 'user=postgres password=postgres host=192.168.1.201 port=5432 sslmode=disable sslcompression=1 krbsrvname=postgres' [postgres@king02 data]$ vi postgresql.conf hot_standby = on [postgres@king02 ~]$ pg_ctl start server starting
【PostgreSQL】数据库复制
猜你喜欢
转载自blog.51cto.com/13598811/2378520
今日推荐
周排行