我正在尝试使用两台服务器创建postgres复制配置。步骤类似于PostgreSQL 9.4 Replication with RepMgr and PgBouncer on Ubuntu 14.04
。我使用repmgr + pgbouncer作为我的复制配置。假设我有两个主机dhost1和dhost2。 Repmgr元数据db为 repmgrdb ,用户为 repmgr_user 。
dhost1有pgbouncer和Repmgr的配置,它是主服务器。 dbhost1中的Repmgr配置如下所述:
cluster = test
node = 1
node_name = dhost1
use_replication_slots = 1
conninfo='host=dhost1 user=repmgr_user dbname=repmgrdb'
pg_bindir=/usr/lib/postgresql/9.5/bin
## repmgr.conf at master ##
dhost2也有Repmgr的配置,它处于从属模式。它的配置如下所述
cluster = test
node = 2
node_name = dhost2
use_replication_slots = 1
conninfo='host=dhost2 user=repmgr_user dbname=repmgrdb'
pg_bindir=/usr/lib/postgresql/9.5/bin
## repmgr.conf at slave ##
我能够成功注册到master,并且可以在cluster show命令中看到master。
从属端的我使用pg_basebackup
方法用命令
repmgr -f /etc/repmgr/repmgr.conf --force -h dhost1_ip_address_goes_here> -U repmgr_user -d repmgrdb -v standby clone
对于上面的命令,我得到以下错误:
[2016-08-08 10:05:26] [NOTICE] using configuration file "/etc/repmgr/repmgr.conf"
[2016-08-08 10:05:26] [NOTICE] setting data directory to: /var/lib/postgresql/9.5/main
[2016-08-08 10:05:26] [HINT] use -D/--data-dir to explicitly specify a data directory
[2016-08-08 10:05:26] [NOTICE] starting backup (using pg_basebackup)...
[2016-08-08 10:05:26] [HINT] this may take some time; consider using the -c/--fast-checkpoint option
[2016-08-08 10:05:31] [NOTICE] copying configuration files from master
[2016-08-08 10:05:31] [ERROR] aborting, remote host <dhost1_ip_address_goes_here> is not reachable.
[2016-08-08 10:05:31] [ERROR] unable to take a base backup of the master server>
[2016-08-08 10:05:31] [WARNING] destination directory (/var/lib/postgresql/9.5/main) may need to be cleaned up manually
我还在postgres
和dhost1
之间为dhost2
用户设置了无密码ssh。
我也可以从命令
中取出pg_basebackup
pg_basebackup -h <dhost1_ip_address_goes_here> -P -v -U repmgr_user -X stream -D 9.5/main -R
我是postgresql复制的初学者,请给我答案。
答案 0 :(得分:0)
我现在正在研究这个问题。你可能想用
再次运行命令
--log-level DEBUG --verbose
那应该给出更多关于那里发生的事情的信息......
答案 1 :(得分:-1)
1-ST
rm -rf /var/lib/postgresql/9.5/main / *
2-ND
repmgr -h masterhostname -p 5433 -U repmgr -d repmgr -D main -f /etc/repmgr.conf --copy-external-config-files = pgdata --verbose standby clone
3-RD
pg_ctl -D /var/lib/postgresql/9.5/main --log = / var / log / postgresql / postgres_screen.log start 4个
repmgr -f /etc/repmgr/repmgr.conf备用寄存器;
repmgr -f /etc/repmgr/repmgr.conf群集显示