PostgreSQL 12复制失败

问题描述

我正在尝试复制仍在运行/正在主动接受来自用户的请求(例如插入和更新)的数据库服务器。

我运行了下面提到的此命令,开始将主服务器复制到复制服务器:

 root@replica:~#sudo -u postgres pg_basebackup -h [PRIMARY_IP] -D /var/lib/postgresql/12/main -U replication -P -v

备份过程没有错误并完成了,但是尝试启动postgresql服务器时遇到如下错误

root@replica:~#tail /var/log/postgresql/postgresql-12-main.log

2020-10-03 01:15:12.198 UTC [552567] FATAL:  database system identifier differs between the primary and standby
2020-10-03 01:15:12.198 UTC [552567] DETAIL:  The primary's identifier is 6805716485467355646,the standby's identifier is 6875279138564418280.
2020-10-03 01:15:17.204 UTC [552568] FATAL:  database system identifier differs between the primary and standby
2020-10-03 01:15:17.204 UTC [552568] DETAIL:  The primary's identifier is 6805716485467355646,the standby's identifier is 6875279138564418280.
2020-10-03 01:15:22.207 UTC [552570] FATAL:  database system identifier differs between the primary and standby
2020-10-03 01:15:22.207 UTC [552570] DETAIL:  The primary's identifier is 6805716485467355646,the standby's identifier is 6875279138564418280.
2020-10-03 01:15:27.212 UTC [552579] FATAL:  database system identifier differs between the primary and standby
2020-10-03 01:15:27.212 UTC [552579] DETAIL:  The primary's identifier is 6805716485467355646,the standby's identifier is 6875279138564418280.
2020-10-03 01:15:32.216 UTC [552581] FATAL:  database system identifier differs between the primary and standby
2020-10-03 01:15:32.216 UTC [552581] DETAIL:  The primary's identifier is 6805716485467355646,the standby's identifier is 6875279138564418280.

有人知道如何解决此问题而无需再次尝试pg_basebackup处理吗?因为这花了我很多时间和带宽。

解决方法

是的,我以前从未复制过它。我遵循@jjanes的建议,我删除了以前的副本,然后运行:

sudo -u postgres pg_basebackup -h [PRIMARY_IP] -D /var/lib/postgresql/12/main -U replication -P -v -R -X stream -C -S pgbackup1

及其工作。