【PgSQL流复制管理】流复制部署

master端:

创建流复制用户

postgres=# CREATE USER repuser replication LOGIN CONNECTION LIMIT 3 ENCRYPTED PASSWORD 'ze0321';
CREATE ROLE

slave端:

/usr/local/pgsql/bin/pg_basebackup -h p0-db01-primary -p 5432 -U repuser -w -Fp -Xs -Pv -R -D /data/pgsql_5432/pgdata/

/usr/local/pgsql/bin/pg_basebackup -h p0-pg03 -p 5432 -U repuser -w -Fp -Xs -Pv -R -D /data/pgsql_5432/pgdata/

pg_basebackup: initiating base backup, waiting for checkpoint to complete
pg_basebackup: checkpoint completed
pg_basebackup: write-ahead log start point: 0/7000028 on timeline 1
pg_basebackup: starting background WAL receiver
pg_basebackup: created temporary replication slot "pg_basebackup_16185"
40536/40536 kB (100%), 3/3 tablespaces
pg_basebackup: write-ahead log end point: 0/7000100
pg_basebackup: waiting for background process to finish streaming ...
pg_basebackup: syncing data to disk ...
pg_basebackup: base backup completed

  • 复制用户配置密码的情况

主库:pg_hba.conf新增条目

host     replication     repuser         p0-db01-slave                 md5

备库同步的时候,采用-W,输入密码

pg_basebackup -h p0-db01-primary -p 5432 -U repuser -W -Fp -Xs -Pv -R -D /data/pgsql_5432/pgdata/

posted on 2020-08-05 11:37  HelonTian  阅读(198)  评论(0编辑  收藏  举报