Postgresql 9.4级联复制故障切换 环境:
以下是我的设置:(“->”表示物理流复制PSR) 这一行为正确-Master1上的更改反映在Slave1中,然后反映在Slave2中 如果禁用Master1,并使用触发器_文件将Slave1升级为Master,则Slave1升级成功-我可以写入Slave1 但是,新升级的Slave1和Slave2之间的复制停止 这是预期的行为吗?我希望复制继续这样进行:Postgresql 9.4级联复制故障切换 环境:,postgresql,replication,cascade,postgresql-9.4,Postgresql,Replication,Cascade,Postgresql 9.4,以下是我的设置:(“->”表示物理流复制PSR) 这一行为正确-Master1上的更改反映在Slave1中,然后反映在Slave2中 如果禁用Master1,并使用触发器_文件将Slave1升级为Master,则Slave1升级成功-我可以写入Slave1 但是,新升级的Slave1和Slave2之间的复制停止 这是预期的行为吗?我希望复制继续这样进行: Slave1 -> Slave2 这样,对Slave1的写入将反映在Slave2中 更新 日志: 奴隶1促进: 奴隶2 从属1 IP:
Slave1 -> Slave2
这样,对Slave1的写入将反映在Slave2中
更新
日志:
奴隶1促进:
奴隶2
从属1 IP:
Slave2 IP:
pg_hba.conf允许Slave2连接到Slave1进行复制:
Slave1 pg_hba.conf段:
Slave1 recovery.done:
Slave2 recovery.conf:
非常感谢您在这方面的帮助
更新和解决方案
多亏了@Vao Tsun
answer,在Slave2 recovery.conf中将恢复目标时间线设置为“latest”,并重新启动Slave2 postgresql server(不重新加载),复制过程得以重新启动:
standby_mode = 'on'
primary_conninfo = 'user=replication host=192.168.20.56 port=5432 sslmode=prefer sslcompression=1 krbsrvname=postgres'
recovery_target_timeline = 'latest'
您可以在slave1日志中看到:
2017-10-03 16:43:30 BST @ LOG: 00000: selected new timeline ID: 2
在奴隶2中:
017-10-03 16:43:30 BST @ DETAIL: End of WAL reached on timeline 1 at 0/190007A8.
所以slave2在升级后没有切换到时间线2
正如我在评论中所说,您需要slave2 recovery.conf中的recovery\u target\u timeline='latest'
恢复\目标\时间线(字符串)指定恢复到
特定的时间线。默认情况下是沿同一时间线恢复
这是进行基本备份时的当前值。将此设置为
最新恢复到存档中找到的最新时间线,即
在备用服务器中很有用。除此之外,您只需设置
在复杂的重新恢复情况下,需要返回
恢复到一个时间点恢复后达到的状态。看见
第25.3.5节供讨论
请使用日志更新帖子,并检查slave2 recovery conf中是否有timeline='latest',以便在升级slave1时切换下一个时间线。我已使用slave1和slave2的日志文件以及我的recovery.conf文件更新了我的问题。非常感谢您的回答。在recovery.conf中设置此字段后重新启动Slave2,重新启动了复制。很高兴它有所帮助!
2017-10-03 16:43:30 BST @ LOG: 00000: replication terminated by primary server
2017-10-03 16:43:30 BST @ DETAIL: End of WAL reached on timeline 1 at 0/190007A8.
2017-10-03 16:43:30 BST @ LOCATION: WalReceiverMain, walreceiver.c:446
2017-10-03 16:43:30 BST @ LOG: 00000: fetching timeline history file for timeline 2 from primary server
2017-10-03 16:43:30 BST @ LOCATION: WalRcvFetchTimeLineHistoryFiles, walreceiver.c:669
2017-10-03 16:43:30 BST @ LOG: 00000: record with zero length at 0/190007A8
2017-10-03 16:43:30 BST @ LOCATION: ReadRecord, xlog.c:4184
2017-10-03 16:43:30 BST @ LOG: 00000: restarted WAL streaming at 0/19000000 on timeline 1
2017-10-03 16:43:30 BST @ LOCATION: WalReceiverMain, walreceiver.c:374
2017-10-03 16:43:30 BST @ LOG: 00000: replication terminated by primary server
2017-10-03 16:43:30 BST @ DETAIL: End of WAL reached on timeline 1 at 0/190007A8.
192.168.20.56
192.168.20.53
host replication replication 192.168.20.53/32 trust
standby_mode = 'on'
primary_conninfo = 'user=replication host=192.168.20.55 port=5432 sslmode=prefer sslcompression=1 krbsrvname=postgres'
trigger_file = '/var/lib/postgresql/9.4/main/failover_trigger.5432'
standby_mode = 'on'
primary_conninfo = 'user=replication host=192.168.20.56 port=5432 sslmode=prefer sslcompression=1 krbsrvname=postgres'
standby_mode = 'on'
primary_conninfo = 'user=replication host=192.168.20.56 port=5432 sslmode=prefer sslcompression=1 krbsrvname=postgres'
recovery_target_timeline = 'latest'
2017-10-03 16:43:30 BST @ LOG: 00000: selected new timeline ID: 2
017-10-03 16:43:30 BST @ DETAIL: End of WAL reached on timeline 1 at 0/190007A8.