Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PostgreSQL时间点恢复不工作_Postgresql_Postgresql 9.6_Pitr - Fatal编程技术网

PostgreSQL时间点恢复不工作

PostgreSQL时间点恢复不工作,postgresql,postgresql-9.6,pitr,Postgresql,Postgresql 9.6,Pitr,我们将2台PostgreSQL服务器设置为主从服务器 我想测试下面的场景 我在master上进行了一次基本备份,然后删除了一个表,并使用命令select pg_switch_xlog()切换了xlog文件。然后我阻止了主人。将从属服务器升级为主服务器,并删除了另一个表和交换的日志文件 现在,我已经在一台新服务器上恢复了这两台服务器的基本备份和wal文件,并使用恢复时间来测试PITR。我能够恢复到没有从旧主控中删除任何表或删除1个表的时间。但我无法恢复到从新主控中删除表时的某个时间点 下面是同一系

我们将2台PostgreSQL服务器设置为主从服务器

我想测试下面的场景

我在master上进行了一次基本备份,然后删除了一个表,并使用命令
select pg_switch_xlog()切换了xlog文件。然后我阻止了主人。将从属服务器升级为主服务器,并删除了另一个表和交换的日志文件

现在,我已经在一台新服务器上恢复了这两台服务器的基本备份和wal文件,并使用恢复时间来测试PITR。我能够恢复到没有从旧主控中删除任何表或删除1个表的时间。但我无法恢复到从新主控中删除表时的某个时间点

下面是同一系统的日志输出

2018-08-06 14:49:39.564 UTC  [19772] LOG:  starting point-in-time recovery to 2018-08-06 14:20:00+00
cp: cannot stat ‘/var/lib/pgsql/pg_log_archive/00000005.history’: No such file or directory
2018-08-06 14:49:39.579 UTC  [19772] LOG:  restored log file "000000050000000200000046" from archive
2018-08-06 14:49:39.630 UTC  [19772] LOG:  redo starts at 2/46000028
2018-08-06 14:49:39.635 UTC  [19772] LOG:  consistent recovery state reached at 2/460ABCE8
2018-08-06 14:49:39.636 UTC  [19770] LOG:  database system is ready to accept read only connections
2018-08-06 14:49:39.648 UTC  [19772] LOG:  restored log file "000000050000000200000047" from archive
2018-08-06 14:49:39.732 UTC  [19772] LOG:  restored log file "000000050000000200000048" from archive
cp: cannot stat ‘/var/lib/pgsql/pg_log_archive/000000050000000200000049’: No such file or directory
2018-08-06 14:49:39.780 UTC  [19772] LOG:  redo done at 2/48003410
2018-08-06 14:49:39.780 UTC  [19772] LOG:  last completed transaction was at log time 2018-08-06 13:27:00.442816+00
2018-08-06 14:49:39.796 UTC  [19772] LOG:  restored log file "000000050000000200000048" from archive
2018-08-06 14:49:39.843 UTC  [19772] LOG:  restored log file "00000006.history" from archive
cp: cannot stat ‘/var/lib/pgsql/pg_log_archive/00000007.history’: No such file or directory
2018-08-06 14:49:39.845 UTC  [19772] LOG:  selected new timeline ID: 7
cp: cannot stat ‘/var/lib/pgsql/pg_log_archive/00000005.history’: No such file or directory
2018-08-06 14:49:39.903 UTC  [19772] LOG:  archive recovery complete
2018-08-06 14:49:40.006 UTC  [19772] LOG:  MultiXact member wraparound protections are now enabled
2018-08-06 14:49:40.008 UTC  [19770] LOG:  database system is ready to accept connections
2018-08-06 14:49:40.009 UTC  [19786] LOG:  autovacuum launcher started
以下是
recovery.conf
文件的内容:

restore_command = 'cp /var/lib/pgsql/pg_log_archive/%f %p'
recovery_target_time = '2018-08-06 14:20:00.0'
recovery_target_inclusive = 'true'
recovery_target_action = 'promote'

我在这里做错了什么?

恢复不会继续到时间线6,因为您没有添加

recovery_target_timeline = 'latest'
recovery.conf
。正如上面所说:

默认情况下,恢复时间与进行基本备份时的时间相同


到目前为止,我正在recovery.conf中使用restore_命令、recovery_target_time、recovery_target_inclusive、recovery_target_action。现在我正在添加恢复目标时间表。现在时间点恢复是否完美?我应该这么说。你能自己编辑你的问题来添加正确的信息吗?