【PostgreSQL】数据库复制-创新互联
异步流复制
[root@wallet01 ~]# su - postgres
[postgres@wallet01 ~]$ vi /var/lib/pgsql/9.6/data/pg_hba.conf
host replication postgres 192.168.1.0/24 md5
[postgres@wallet01 ~]$ vi /var/lib/pgsql/9.6/data/postgresql.conf
listen_addresses = '0.0.0.0'
max_wal_senders = 5
wal_level = hot_standby
[postgres@wallet01 ~]$ pg_ctl restart
waiting for server to shut down.... done
server stopped
server starting
[root@wallet02 ~]# su - postgres
[postgres@wallet02 ~]$ 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@wallet02 ~]$ vi /var/lib/pgsql/9.6/data/postgresql.conf
hot_standby = on
[postgres@wallet02 ~]$ vi /var/lib/pgsql/9.6/data/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@wallet02 ~]$ pg_ctl start
server starting
[postgres@wallet01 ~]$ psql
psql (9.6.12)
Type "help" for help.
postgres=# select pid,state,client_addr,sync_priority,sync_state from pg_stat_replication;
pid | state | client_addr | sync_priority | sync_state
------+-----------+---------------+---------------+------------
2055 | streaming | 192.168.1.202 | 0 | async
(1 row)目前创新互联已为上1000+的企业提供了网站建设、域名、虚拟主机、网站托管、服务器租用、企业网站设计、德化网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。同步流复制
[root@wallet01 ~]# su - postgres
[postgres@wallet01 ~]$ vi /var/lib/pgsql/9.6/data/pg_hba.conf
host replication postgres 192.168.1.0/24 md5
[postgres@wallet01 ~]$ vi /var/lib/pgsql/9.6/data/postgresql.conf
max_wal_senders = 5
wal_level = hot_standby
synchronous_standby_names = 'wallet02,wallet03'
[root@wallet01 ~]# su - postgres
[postgres@wallet01 ~]$ pg_ctl reload
server signaled
[root@wallet02 ~]# su - postgres
[postgres@wallet02 ~]$ 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@wallet02 ~]$ vi /var/lib/pgsql/9.6/data/postgresql.conf
hot_standby = on
[postgres@wallet02 ~]$ vi /var/lib/pgsql/9.6/data/recovery.conf
standby_mode = 'on'
primary_conninfo = 'application_name=wallet02 user=postgres password=postgres host=192.168.1.201 port=5432 sslmode=disable sslcompression=1'
[postgres@wallet02 ~]$ pg_ctl start
server starting
[root@wallet03 ~]# su - postgres
[postgres@wallet03 ~]$ pg_basebackup -h 192.168.1.201 -U postgres -F p -P -x -R -D /var/lib/pgsql/9.6/data
Password:
2161215/2161215 kB (100%), 1/1 tablespace
[postgres@wallet03 ~]$ vi /var/lib/pgsql/9.6/data/postgresql.conf
hot_standby = on
[postgres@wallet03 ~]$ vi /var/lib/pgsql/9.6/data/recovery.conf
standby_mode = 'on'
primary_conninfo = 'application_name=wallet03 user=postgres password=postgres host=192.168.1.201 port=5432 sslmode=disable sslcompression=1'
[postgres@wallet03 ~]$ pg_ctl start
server starting
[postgres@wallet01 ~]$ psql
psql (9.6.12)
Type "help" for help.
postgres=# select pid,state,client_addr,sync_priority,sync_state from pg_stat_replication;
pid | state | client_addr | sync_priority | sync_state
------+-----------+---------------+---------------+------------
1968 | streaming | 192.168.1.202 | 1 | sync
2018 | streaming | 192.168.1.203 | 2 | potential
当前文章:【PostgreSQL】数据库复制-创新互联
文章出自:http://myzitong.com/article/csdhop.html
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
当前文章:【PostgreSQL】数据库复制-创新互联
文章出自:http://myzitong.com/article/csdhop.html