[英]PostgreSQL - how to restore very large database
當我嘗試在我的devel數據庫節點上恢復一個大型數據庫(幾乎是32Go自定義格式)時,我遇到了一個小問題(這個節點的RAM,CPU比我的生產服務器少)。
我的數據庫轉儲使用類似於以下的命令生成:
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命令中是否遺漏了一些內容? 可能是我的devel服務器的設置太低了?
任何線索將不勝感激。 預先感謝。
環境:PostgreSQL 9.1(通過Debian軟件包安裝)
對於這種大工作,建議在恢復過程中禁用autovacuum
(在postgresql.conf中將其設置為off
)。
它似乎終於適合我了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.