我有3个节点的Postgres集群由patroni管理,每当我的主节点宕机并作为副本重新加入时,旧的主节点就会面临以下错误:
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日志存储到一个共享目录,然后从那里恢复它。
但是错误仍然是一样的。
发布于 2021-06-28 15:16:18
我认为你需要做的是,在你的新复制品中手动使用pg_rewind命令。发生的情况是,当时间线从1更改为2时,旧主机与新主机处于不同的wal位置。
pg_rewind --source-server "user=<user> password=<user_password> host=<dns_or_ip_address> port=<server_port>" --target-pgdata <data-directory>https://stackoverflow.com/questions/68158949
复制相似问题