Postgresql数据库复制有两个服务器,一个用于主服务器,另一个用于从服务器。由于某些原因,主IP地址被更改,该地址在从服务器中的多个位置使用。对于新的IP地址,将旧的IP地址替换为从服务器中的最新IP地址后,复制不再像以前那样工作。有人能帮忙解决这个问题吗?以下是设置从服务器时使用的步骤:
1.在pg_hba.conf文件中添加用于用户复制的主IP地址
nano /etc/postgresql/11/main/pg_hba.conf host
replication master-IP/24 md5
2.modify the following lines in the PostgreSQL.conf file of slave server where listen_addresses should be the IP of the slave server
nano /etc/postgresql/11/main/postgresql.conf
listen_addresses = 'localhost,slave-IP'
wal_level = replica
max_wal_senders = 10
wal_keep_segments = 64
3. Take the backup of the master server by entering the IP
pg_basebackup -h master-ip -D /var/lib/postgresql/11/main/ -P -U
replication --wal-method=fetch
4.create a recovery file and adding the following commands
standby_mode = 'on'
primary_conninfo = 'host=master-ip port=5432 user=replication password= '
trigger_file = '/tmp/MasterNow'下面是日志文件中的错误:
started streaming WAL from primary at A/B3000000 on timeline 2
FATAL: could not receive data from WAL stream: ERROR: requested WAL segment 000000020000000A000000B3 has already been removed
FATAL: could not connect to the primary server: could not connect to server: Connection timed out
Is the server running on host "master ip" and accepting
TCP/IP connections on port 5432?
record with incorrect prev-link 33018C00/0 at 0/D8E15D18发布于 2020-02-25 14:16:32
备用服务器停机时间足够长,以致主服务器不再具有所需的事务日志信息。
有三种补救办法:
restore_command参数,以便从存档中恢复WAL段(这应该与主服务器上的archive_command相反)。然后重新启动待机。这是唯一允许您在不从头开始重新构建备用服务器的情况下恢复的选项。
wal_keep_segments设置得足够高,足以保留足够的WAL来覆盖中断。primary_slot_name参数中。这不会帮助你现在恢复,但它将避免未来的问题。
注意:在使用复制槽时,监视复制。否则,待机状态下降将导致主站上WAL段堆积,最终填充磁盘。
除了第一个选项之外,所有选项都要求您使用pg_basebackup重新生成备用设备,因为所需的WAL信息不再可用。
发布于 2020-02-25 16:29:36
主机复制主机-IP/24 md5
这一行缺了一个字段。用户字段。
listen_addresses = 'localhost,从IP‘
除了“*”之外,很少有必要这样做。如果你不试图对它进行微观管理,那就少了一件你需要改变的事情。另外,除非您使用级联复制,否则更改副本上的wal_keep_segments不会有多大效果。它需要在主人身上改变。
pg_basebackup -h主-ip -D /var/lib/postgresql/11/main/ -P -U复制--wal-method=fetch
这是否表明它成功了?
致命:无法从WAL流接收数据:错误:请求的WAL段0000000200000A000000B3已被删除
致命:无法连接到主服务器:无法连接到服务器:连接超时是否在主机“主ip”上运行,并在端口5432上接受TCP/IP连接?
这很奇怪。为了得知该档案“已被删除”,它必须已连接。但下一条线说它不能连接。有一个错误的配置会阻止您连接,这并不罕见,但在这种情况下,它将无法在第一次连接。您是否更改了这两条日志消息之间的配置?你的网络连接有问题吗?
https://stackoverflow.com/questions/60389938
复制相似问题