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;
流复制
最新推荐文章于 2024-07-16 15:39:21 发布
postgresql 流复制: