postgresql - Patroni,Postgres:无法启动 WAL 流:错误:时间线 X 上请求的起点 Y 不在此服务器的历史记录中
问题描述
我有 3 个节点 Postgres 集群,由赞助人管理,每当我的主节点出现故障并作为副本重新加入时,旧主节点就会面临以下错误:
2021-06-25T00:16:29.856133+00:00 host0 postgres_0[14131]: [7-2] #011DETAIL: This server's history forked from timeline 1 at 0/5208600.
2021-06-25T00:16:29.862228+00:00 host0 postgres_0[112]: [4855-1] pid=112,session=60d4c1b1.70,line=4850,sqlstate=00000,user_app=,user=,db=,client=,txId=0 LOG: new timeline 2 forked off current database system timeline 1 before current recovery point 0/60000A0
2021-06-25T00:16:34.857325+00:00 host0 postgres_0[14141]: [7-1] pid=14141,session=60d52062.373d,line=1,sqlstate=XX000,user_app=,user=,db=,client=,txId=0 FATAL: could not start WAL streaming: ERROR: requested starting point 0/6000000 on timeline 1 is not in this server's history
这是我使用的配置:
"hot_standby": "on",
"wal_log_hints": "on",
"restore_command": "cp /bp2/wal/psql/wal_archive/%f %p",
"archive_mode": "on",
"archive_command": "mkdir -p /bp2/wal/psql/wal_archive && test ! -f /bp2/wal/psql/wal_archive/%f && cp %p /bp2/wal/psql/wal_archive/%f",
"remove_data_directory_on_diverged_timelines":"true",
"remove_data_directory_on_rewind_failure": "true",
"use_pg_rewind": "true",
"recovery_target_timeline": "latest"
已经尝试将所有节点的 WAL 日志存储到共享目录,然后从那里恢复。
但错误仍然相同。
解决方案
我认为您需要做的是,pg_rewind
在您的新副本中手动使用命令。发生的情况是,当时间线从 1 更改为 2 时,旧 master 与新 master 处于不同的 wal 位置。
pg_rewind --source-server "user=<user> password=<user_password> host=<dns_or_ip_address> port=<server_port>" --target-pgdata <data-directory>
推荐阅读
- java - 将 Java 从 1.7.0_201 更新到最新版本并出现错误
- spring - Bean 验证 - 验证可选字段
- r - R:如何在方法中设置成员变量?
- java - 在 JavaFX 中将节点的形状和大小绑定到剪贴蒙版
- python - 在函数中使用全局变量而不将其显式传递给函数时是否可能会收到警告?
- c++ - 模块 (DLL) 的类大小不同。如何以及为什么?
- mysql - 相同的 ID 不同的值变成一行
- c# - 为什么我在mysql中的count命令返回错误的值-1?
- kubernetes - 在 Kubernetes 中实现 WebSocket 时出错
- javascript - 错误未知类型“webform__webform”使用 gatsby-drupal-webform & GraphQL