pg_basebackup恢复:unrecognized configuration parameter "restore_command"
阅读原文时间:2023年07月08日阅读:1

问题描述:2022年最后一个工作日,时间过的真快,一晃又一年过去了,祝愿看到的各位元旦快乐。

使用pg_basebackup进行pg的备份恢复,在恢复的过程中,配置文件添加恢复的参数,一直启动报错。

在postgre.conf和postgres.auto.conf中都添加尝试了。类似下列报错,都启动失败

PG版本:pg_ctl (PostgreSQL) 10.1

LOG: unrecognized configuration parameter "restore_command" in file "/var/lib/postgresql/9.6/main/postgresql.auto.conf" line 5
LOG: unrecognized configuration parameter "recovery_target_name" in file "/var/lib/postgresql/9.6/main/postgresql.auto.conf" line 6
FATAL: configuration file "/var/lib/postgresql/9.6/main/postgresql.auto.conf" contains errors

$ pg_ctl -D /u01/app/pgsql/data start
waiting for server to start….2022-06-01 17:42:41.472 GMT [7645] LOG: unrecognized configuration parameter "restore_command" in file "/u01/app/pgsql/11/data/postgresql.conf" line 64
2022-06-01 17:42:41.472 GMT [7645] LOG: unrecognized configuration parameter "recovery_target_timeline" in file "/u01/app/pgsql/data/postgresql.conf" line 65
2022-06-01 17:42:41.472 GMT [7645] FATAL: configuration file "/u01/app/pgsql/11/data/postgresql.conf" contains errors
stopped waiting

后来更换了pg版本,换成(PostgreSQL) 13.6,跟10的版本区别就是13的postgres.conf文件中可以找到相关的恢复参数,但是被注释掉了,10的postgres.conf文件中就没有相关的参数,不支持相关的恢复参数。

而且postgres.auto.conf上边系统给到的注释,就是不要手动去编辑这个文件,他会在alter system command命令中生成配置。

但是很多恢复文档都是直接去修改这个文件,没有测试,不知道原理是什么。

# vim postgres.conf

基于时间线恢复

基于备份点恢复

基于时间点进行恢复