流复制

postgresql 流复制:

master(127.0.0.1:5432):

数据目录:/home/pg93/test_rep/data

initdb -D $PGDATA -E UTF8 --locale=C -U postgres -W

修改pg_hba.conf:

host all all 0.0.0.0/0 trust

host replication rep 127.0.0.1/32 md5

修改postgresql.conf:

listen_addresses = '*'

port = 5432

wal_level = hot_standby

checkpoint_segments = 16

max_wal_senders = 13

wal_keep_segments = 16

log_destination = 'csvlog'

logging_collector = on

archive_mode = on

archive_command = 'cp %p /home/pg93/test_rep/arch/%f'

pg_ctl start -D /home/pg93/test_rep/data

create USER rep REPLICATION LOGIN CONNECTION LIMIT 2 ENCRYPTED PASSWORD 'rep123us345er';

slave(127.0.0.1:5433):

数据目录:/home/pg93/test_rep/bak

chmod 0700 /home/pg93/test_rep/bak

pg_basebackup -D /home/pg93/test_rep/bak -Fp -Xs -v -P -h 127.0.0.1 -p 5432 -U rep

vi postgresql.conf:

port= 5433

hot_standby=on

cp /opt/pgsql934/share/recovery.conf.sample recovery.conf

vi recovery.conf

standby_mode = on

primary_conninfo = 'host=127.0.0.1 port=5432 user=rep password=rep123us345er'

trigger_file = '/home/pg93/test_rep/postgresql.trigger.5432'

master(127.0.0.1:5432):

psql -h 127.0.0.1 -p 5432 -U postgres postgres

create table aaxx(a int);

insert into aaxx values(1);

slave(127.0.0.1:5433):

pg_ctl start -D /home/pg93/test_rep/bak

psql -h 127.0.0.1 -p 5433 -U postgres postgres

select * from aaxx;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值