postgresql - 在 PostgreSQL 9.4.1 的切换和切回中是强制参数recover_target_timeline='latest'吗?
问题描述
我已按照以下步骤进行切换和切回。
第 1 步:- 从 10.xx10 断开应用程序服务并执行以下操作
@大师(10.xx10)
pg_ctl -D /DATA_VEC/pgdata stop --mode=fast
@DR(20.xx20)
将 DR 提升为读写模式
第 2 步:- 从新的主节点启动主节点作为 DR
@Master(10.xx10)
创建recovery.conf
standby_mode = 'on'
primary_conninfo = 'user= password= host=20.x.x.20 port=9999
trigger_file = '/tmp/node1'
restore_command = 'cp /DATA_VEC/restore/%f "%p"'
pg_ctl -D /DATA_VEC/pgdata start
升级新备用后,旧主服务器未与新主服务器(旧备用)同步 来自主服务器的 DR 服务器的日志。
2019-12-01 18:46:56 IST LOG: database system was shut down in recovery at 2019-12-01 18:46:53 IST
2019-12-01 18:46:56 IST LOG: entering standby mode
cp: cannot stat `/DATA_VEC/restore/00000002.history': No such file or directory
2019-12-01 18:46:56 IST LOG:
2019-12-01 18:46:56 IST LOG: restored log file "00000002000000000000000C" from archive
2019-12-01 18:46:57 IST LOG: consistent recovery state reached at 0/C000090
2019-12-01 18:46:57 IST LOG: record with zero length at 0/C000090
2019-12-01 18:46:57 IST LOG: database system is ready to accept read only connections
2019-12-01 18:46:57 IST LOG: started streaming WAL from primary at 0/C000000 on timeline 2
2019-12-01 18:46:57 IST LOG: replication terminated by primary server
2019-12-01 18:46:57 IST DETAIL: End of WAL reached on timeline 2 at 0/C000090.
2019-12-01 18:46:57 IST LOG: restored log file "00000002000000000000000C" from archive
2019-12-01 18:46:57 IST LOG: record with zero length at 0/C000090
2019-12-01 18:46:57 IST LOG: restarted WAL streaming at 0/C000000 on timeline 2
2019-12-01 18:46:57 IST LOG: replication terminated by primary server
2019-12-01 18:46:57 IST DETAIL: End of WAL reached on timeline 2 at 0/C000090.
@大师(10.xx10)
pg_xlog 内容
-bash-4.1$ cd pg_xlog
-bash-4.1$ ll
total 65552
-rw------- 1 postgres postgres 302 Dec 1 12:52 00000002000000000000000A.00000028.backup
-rw------- 1 postgres postgres 16777216 Dec 1 13:52 00000002000000000000000B
-rw------- 1 postgres postgres 16777216 Dec 1 14:28 00000002000000000000000C
-rw------- 1 postgres postgres 16777216 Dec 1 12:52 00000002000000000000000D
-rw------- 1 postgres postgres 16777216 Dec 1 12:52 00000002000000000000000E
-rw------- 1 postgres postgres 41 Dec 1 13:57 00000002.history
-rw------- 1 postgres postgres 83 Dec 1 13:57 00000003.history
drwx------ 2 postgres postgres 4096 Dec 1 13:57 archive_status
@in restore_command 位置内容:-
-bash-4.1$ cd /DATA_VEC/restore/
-bash-4.1$ ll
total 49156
-rw------- 1 postgres postgres 16777216 Dec 1 18:45 00000002000000000000000A
-rw------- 1 postgres postgres 16777216 Nov 30 21:22 00000002000000000000000B
-rw------- 1 postgres postgres 16777216 Dec 1 18:45 00000002000000000000000C
-rw------- 1 postgres postgres 83 Dec 1 18:45 00000003.history
-bash-4.1$
由于 per_pg_xlog 时间线历史文件00000003.history
到达备用服务器,但仍未从新的主服务器开始流式传输。
问题:-recover_target_timeline='latest'
1.文件中的
强制参数recovery.conf
”是否通过流从新主节点获取最新的时间线ID以开始流复制?
2.如果是,是否适用于所有 PostgreSQL 版本?比如从 9.3 到 11.5
解决方案
如果您想要切换回功能,则必须设置recovery_target_timeline='latest'
,因为任何促销都会增加时间线。使用固定的目标时间线通常是为非常特殊的情况保留的(即,您需要在脑裂、时间线分歧的情况下恢复更改)。
要回答您的具体问题:
- 是的
- 是的
推荐阅读
- javascript - TensorFlowJS fails to load a JS generated image
- python - Python - Is it possible to wait_for one event or another in Discord.py-v1.0?
- python - 多处理日志记录 - 如何将 loguru 与 joblib Parallel 一起使用
- python - Mapping a function to a dataframe
- mongodb - How can I run mongorestore from my Dockerfile?
- c# - 电子邮件验证服务如何工作以及如何操作?
- django - 如何进行正确的身份验证?
- php - 从 SQL 查询中检索值
- c# - 如何在 ASP.NET Core 中自定义 UserManager 的 GeneratePasswordResetTokenAsync 和 ResetPasswordAsync 方法
- javascript - 如何使用 mongoose 将数据对象发布到 mongodb 中的数组中