首页 > 其他分享 >复制流报错:Latest checkpoint is at 2/7C3079A0 on timeline 1, but in the history of the requested timeline

复制流报错:Latest checkpoint is at 2/7C3079A0 on timeline 1, but in the history of the requested timeline

时间:2022-09-26 09:36:36浏览次数:52  
标签:20 postgres 23 timeline 09 7C3079A0 报错 2022 CST

我的测试环境从PostgreSQL 9.6.0异步复制流通过pg_upgrade方式升级到14.5,通过rsync将primary数据传输到standby端

[postgres]]# rsync -avz postgres@standby:/data/postgres_14.5/ /data/postgres_14.5

 

在调整好相关standby相关配置后,启动standby端postgres报如下的错误:

[postgres@standby ]# pg_ctl start
pg_ctl: another server might be running; trying to start server anyway
waiting for server to start....2022-09-23 20:47:07.420 CST [45674] LOG:  redirecting log output to logging collector process
2022-09-23 20:47:07.420 CST [45674] HINT:  Future log output will appear in directory "log".
 stopped waiting
pg_ctl: could not start server
Examine the log output.

 

查看错误日志,发现history文件中记录的timeline与最后一次checkpoint的timeline有出入:

[postgres@standby log]# $PGDATA/log/cat postgresql-2022-09-23_204707.log 
2022-09-23 20:47:07.420 CST [45674] LOG:  starting PostgreSQL 14.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2022-09-23 20:47:07.420 CST [45674] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2022-09-23 20:47:07.420 CST [45674] LOG:  listening on IPv6 address "::", port 5432
2022-09-23 20:47:07.422 CST [45674] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2022-09-23 20:47:07.425 CST [45676] LOG:  database system was interrupted; last known up at 2022-09-23 19:28:07 CST
2022-09-23 20:47:07.441 CST [45676] LOG:  entering standby mode
2022-09-23 20:47:07.442 CST [45676] FATAL:  requested timeline 2 is not a child of this server's history
2022-09-23 20:47:07.442 CST [45676] DETAIL:  Latest checkpoint is at 2/7C3079A0 on timeline 1, but in the history of the requested timeline, the server forked off from that timeline at 0/12000000.
2022-09-23 20:47:07.442 CST [45674] LOG:  startup process (PID 45676) exited with exit code 1
2022-09-23 20:47:07.442 CST [45674] LOG:  aborting startup due to startup process failure
2022-09-23 20:47:07.446 CST [45674] LOG:  database system is shut down

 

查看wal相关日志,发现在wal日志目录下多了一个.history的文件,里面的内容说是没记有指定恢复的目的端,我确定我配置的没有问题

[postgres@standby pg_wal]$ ll $PGDATA/pg_wal
total 196612
-rw------- 1 postgres postgres 67108864 Sep 23 19:47 00000001000000020000001F
-rw------- 1 postgres postgres 67108864 Sep 23 19:17 000000010000000200000020
-rw------- 1 postgres postgres 67108864 Sep 23 19:26 000000020000000100000004
-rw------- 1 postgres postgres       42 Sep 22 17:55 00000002.history
drwx------ 2 postgres postgres       72 Sep 23 19:47 archive_status

[postgres@standby pg_wal]# cat $PGDATA/pg_wal/00000002.history
1	0/12000000	no recovery target specified

 

删除.history文件,重新启动standby端postgres,此时可以正常启动了

[postgres@standby pg_wal]# rm -fr $PGDATA/pg_wal/00000002.history

[postgres@host72 postgres]$ pg_ctl start
waiting for server to start....2022-09-23 20:53:39.286 CST [46398] LOG:  redirecting log output to logging collector process
2022-09-23 20:53:39.286 CST [46398] HINT:  Future log output will appear in directory "log".
 done
server started

 

 查看primary端复制流信息

postgres=# \x on;
Expanded display is on.
postgres=# select * from pg_stat_replication;
-[ RECORD 1 ]----+------------------------------
pid              | 31700
usesysid         | 16384
usename          | repl
application_name | walreceiver
client_addr      | 192.168.1.72
client_hostname  | 
client_port      | 43210
backend_start    | 2022-09-23 20:53:39.313239+08
backend_xmin     | 
state            | streaming
sent_lsn         | 2/80000000
write_lsn        | 2/80000000
flush_lsn        | 2/80000000
replay_lsn       | 2/80000000
write_lag        | 
flush_lag        | 
replay_lag       | 
sync_priority    | 0
sync_state       | async
reply_time       | 2022-09-23 20:53:59.57744+08

 

标签:20,postgres,23,timeline,09,7C3079A0,报错,2022,CST
From: https://www.cnblogs.com/haha029/p/16729759.html

相关文章