gpt4 book ai didi

PostgreSQL - 如何恢复非常大的数据库

转载 作者:行者123 更新时间:2023-11-29 11:19:09 24 4
gpt4 key购买 nike

当我尝试在我的开发数据库节点(这个节点的 RAM、CPU... 比我的生产服务器少)上恢复一个大型数据库(自定义格式几乎 32Go)时我遇到了一个小问题。

我的数据库转储是使用类似于以下的命令生成的:

pg_dump -F custom -b myDB -Z 9 > /backup/myDB-`date +%y%m%d`.pg91

当我恢复它时,我使用了以下命令:

pg_restore -F custom -j 5 -d myDB /backup/myDB-20130331.pg91

但在这里,每次恢复命令失败时都会出现如下错误:

pg_restore: [archiver (db)] error returned by PQputCopyData: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
pg_restore: [archiver] worker process failed: exit code 1
pg_restore: [archiver (db)] error returned by PQputCopyData: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
pg_restore: [archiver (db)] error returned by PQputCopyData: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
pg_restore: [archiver (db)] error returned by PQputCopyData: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.

当我检查我的 postgresql 日志时,我可以读到:

   HINT:  In a moment you should be able to reconnect to the database and repeat your command.
LOG: all server processes terminated; reinitializing
LOG: database system was interrupted; last known up at 2013-04-02 11:41:48 UTC
LOG: database system was not properly shut down; automatic recovery in progress
LOG: redo starts at 86/26F302B0
LOG: unexpected pageaddr 85/E3F52000 in log file 134, segment 38, offset 16064512
LOG: redo done at 86/26F51FC0
LOG: last completed transaction was at log time 2013-04-02 11:50:47.663599+00
LOG: database system is ready to accept connections
LOG: autovacuum launcher started

很奇怪,我的 postgresql 服务器仅仅因为我的恢复就单独“重启”了。我尽量减少作业数量(-j 5 选项)但仍然遇到同样的问题。但是在具有更好规范的节点上,我可以毫无问题地恢复该数据库。我不确定,但也许我的索引更新(其中一个确实太大)可能是理解这个问题的线索?

所以我有一些问题:是否有更好的方法来恢复非常大的数据库?我在我的 pg_restore 命令中遗漏了什么吗?可能是我的开发服务器设置太低了吗?

任何线索将不胜感激。提前致谢。

环境:PostgreSQL 9.1(通过 Debian 软件包安装)

最佳答案

对于这种大型工作,建议禁用 autovacuum(在 postgresql.conf 中将其设置为 off)在修复过程中。

看来它终于对我有用了。

关于PostgreSQL - 如何恢复非常大的数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15765606/

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