gpt4 book ai didi

PostgreSQL PITR 无法正常工作

转载 作者:行者123 更新时间:2023-11-29 11:35:49 26 4
gpt4 key购买 nike

我正在尝试将 PostgreSQL 数据库恢复到某个时间点。

当我在 recovery.conf 中仅使用 restore_command 时,它工作正常。

restore_command = 'cp /var/lib/pgsql/pg_log_archive/%f %p'

当我使用recovery_target_time 参数 时,它没有恢复到目标时间。

restore_command = 'cp /var/lib/pgsql/pg_log_archive/%f %p'
recovery_target_time='2018-06-05 06:43:00.0'

日志文件内容如下:

2018-06-05 07:31:39.166 UTC [22512] LOG:  database system was interrupted; last known up at 2018-06-05 06:35:52 UTC
2018-06-05 07:31:39.664 UTC [22512] LOG: starting point-in-time recovery to 2018-06-05 06:43:00+00
2018-06-05 07:31:39.671 UTC [22512] LOG: restored log file "00000005.history" from archive
2018-06-05 07:31:39.769 UTC [22512] LOG: restored log file "00000005000000020000008F" from archive
2018-06-05 07:31:39.816 UTC [22512] LOG: redo starts at 2/8F000028
2018-06-05 07:31:39.817 UTC [22512] LOG: consistent recovery state reached at 2/8F000130
2018-06-05 07:31:39.818 UTC [22510] LOG: database system is ready to accept read only connections
2018-06-05 07:31:39.912 UTC [22512] LOG: restored log file "000000050000000200000090" from archive
2018-06-05 07:31:39.996 UTC [22512] LOG: recovery stopping before abort of transaction 9525, time 2018-06-05 06:45:02.088502+00
2018-06-05 07:31:39.996 UTC [22512] LOG: recovery has paused

我正在尝试将数据库实例恢复到 06:43:00。为什么恢复到 06:45:02?

编辑

在第一种情况下 recovery.conf 转换为 recovery.done 但在第二种情况下没有发生

这可能是什么原因?

最佳答案

你忘了设置

recovery_target_action = 'promote'

时间点恢复后, recovery_target_action 确定 PostgreSQL 将如何进行。

默认值为 pause这意味着 PostgreSQL 什么都不做,等待您告诉它如何继续。

要完成恢复,连接到数据库并运行

SELECT pg_wal_replay_resume();

似乎在 06:43:00 和 06:45:02 之间没有记录数据库事件。观察日志显示 recovery stopping <strong>before</strong> abort of transaction 9525 .

关于PostgreSQL PITR 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50695880/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com