暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

pg_basebackup error: could not send xxx "TIMELINE_HISTORY"

AsherHu 2022-07-22
1778

适用范围

pg 10+

问题概述

在通过pg_basebackup 备份的时候,日志中出现error: could not send replication command “TIMELINE_HISTORY” 错误, 最终备份子进程退出,备份失败。错误日志如下:

postgres@pg02->  pg_basebackup -D u01/postgresql/data  -Ft -Xs -v -P -hXXX.XXX.XXX.XXX -p5432 -Urepluser
pg_basebackup: initiating base backup, waiting for checkpoint to complete
pg_basebackup: checkpoint completed
pg_basebackup: write-ahead log start point: 2/83000028 on timeline 13
pg_basebackup: starting background WAL receiver
pg_basebackup: created temporary replication slot "pg_basebackup_27225"
pg_basebackup: error: could not send replication command "TIMELINE_HISTORY": ERROR: could not open file "pg_wal/0000000D.history": No such file or directory
2148576/2148576 kB (100%), 2/2 tablespaces
pg_basebackup: write-ahead log end point: 2/83000170
pg_basebackup: waiting for background process to finish streaming ...
pg_basebackup: error: child process exited with exit code 1
pg_basebackup: removing contents of data directory "/u01/postgresql/data"

复制

问题原因

问题原因是备份的时候会去找源库上次备份的标识文件,pg_wal/0000000D.history 文件,而该文件已经被人工清理掉。所以导致备份失败。从下例日志中并有找到pg_wal/0000000D.history 文件。

postgres@pg01-> ll
total 81M
-rw-------. 1 postgres postgres 16M Jul 21 11:34 0000000D0000000200000082
-rw-------. 1 postgres postgres 16M Jul 21 11:38 0000000D0000000200000083
-rw-------. 1 postgres postgres 342 Jul 21 11:38 0000000D0000000200000083.00000028.backup
-rw-------. 1 postgres postgres 16M Jul 21 11:50 0000000D0000000200000084
-rw-------. 1 postgres postgres 16M Jul 21 11:51 0000000D0000000200000085
-rw-------. 1 postgres postgres 16M Jul 21 11:51 0000000D0000000200000086
drwx------. 2 postgres postgres 4.0K Jul 21 11:51 archive_status

复制

解决方案

手动创建一个同名的0000000D.history 空文件,然后在重新执行备份即可。

postgres@pg01-> touch 0000000D.history

postgres@pg02-> pg_basebackup -D u01/postgresql/data -Ft -Xs -v -P -h192.168.1.55 -p5432 -Urepluser
pg_basebackup: initiating base backup, waiting for checkpoint to complete
pg_basebackup: checkpoint completed
pg_basebackup: write-ahead log start point: 2/87000028 on timeline 13
pg_basebackup: starting background WAL receiver
pg_basebackup: created temporary replication slot "pg_basebackup_29285"
2148582/2148582 kB (100%), 2/2 tablespaces
pg_basebackup: write-ahead log end point: 2/87000138
pg_basebackup: waiting for background process to finish streaming ...
pg_basebackup: syncing data to disk ...
pg_basebackup: base backup completed

复制


文章转载自AsherHu,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论