1

我有以下情况。

  • 有一个主/副本设置。
  • 不知何故,数据库被删除了,django 创建了一个同名的新数据库。这种情况下,之前数据库的WAL文件还会存在吗?
  • 我没有使用 pg_basebackup 之类的工具使用以前的数据库创建备份,但在 pg_xlog 中有一些 WAL 文件。

现在,我正在尝试执行以下操作: - 关闭 postgres 服务器。- 使用 PGDATA (/var/lib/postgresql/9.3/main) 目录中的 recovery.conf 文件并在其中输入以下内容:

    restore_command = 'cp /var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/%f %p'
    recovery_target_time = '2016-01-07 03:00:00'

- 再次启动 postgres 服务器。

我在日志文件中看到的是:

postgres:~/9.3/main/pg_log$ tail -100f postgresql-2016-01-07_170256.log
2016-01-07 17:02:56 UTC LOG:  database system was shut down at 2016-01-07 17:02:55 UTC
2016-01-07 17:02:56 UTC LOG:  starting point-in-time recovery to 2016-01-06 00:00:00+00
cp: cannot stat ‘/var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/0000000A.history’: No such file or directory
cp: cannot stat ‘/var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/0000000A00000000000000CC’: No such file or directory
2016-01-07 17:02:56 UTC LOG:  consistent recovery state reached at 0/CC000090
2016-01-07 17:02:56 UTC LOG:  record with zero length at 0/CC000090
2016-01-07 17:02:56 UTC LOG:  redo is not required
2016-01-07 17:02:56 UTC LOG:  database system is ready to accept read only connections
cp: cannot stat ‘/var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/0000000A00000000000000CC’: No such file or directory
cp: cannot stat ‘/var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/0000000B.history’: No such file or directory
2016-01-07 17:02:56 UTC LOG:  selected new timeline ID: 11
cp: cannot stat ‘/var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/0000000A.history’: No such file or directory
2016-01-07 17:02:57 UTC LOG:  archive recovery complete
2016-01-07 17:02:57 UTC LOG:  autovacuum launcher started
2016-01-07 17:02:57 UTC LOG:  database system is ready to accept connections
2016-01-07 17:02:57 UTC LOG:  incomplete startup packet

我的 pg_xlog_backup_jan072016 文件夹有以下内容:

:~/9.3/main/pg_xlog_backup_jan072016$ ls -larth 
total 161M
-rw-------  1 postgres postgres  257 Jan  7 15:57 00000007.history
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000CA
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C9
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C8
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C7
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C6
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C5
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C4
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C3
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C2
-rw-------  1 postgres postgres  16M Jan  7 15:57 0000000700000000000000C1
-rw-------  1 postgres postgres  298 Jan  7 15:57 00000007000000000000005D.00000028.backup
-rw-------  1 postgres postgres  214 Jan  7 15:57 00000006.history
-rw-------  1 postgres postgres  171 Jan  7 15:57 00000005.history
drwx------  3 postgres postgres 4.0K Jan  7 16:54 .
drwx------ 18 postgres postgres 4.0K Jan  7 17:02 ..
drwx------  2 postgres postgres 4.0K Jan  7 17:08 archive_status

我想弄清楚的是:

  • 是否可以在没有 pg_basebackup 命令备份的情况下从 WAL 恢复?我只是想在现有的 postgres 安装中从 WAL 恢复。
  • 为什么日志说找不到 0000000A.history 和 0000000A00000000000000CC 文件?该文件夹不包含任何此类文件。

任何人都可以帮助我们吗?谢谢。萨尔塔克

4

0 回答 0