linux fsck exited with status code 4,linux – 在硬盘崩溃后启动PostgreSQL服务器导致FAILED STATE...
我正在使用Fedora 15和PostgreSQL 9.1.4. Fedora最近崩潰了,之后:
嘗試啟動PostgreSQL服務器:
service postgresql-9.1 start
給
Starting postgresql-9.1 (via systemctl): Job failed. See system logs and 'systemctl status' for details.
[FAILED]
雖然,在系統重啟后第一次啟動服務器時服務器正常啟動.
但是,嘗試使用psql會出現此錯誤:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
.s.PGSQL.5432文件不存在于系統的任何位置.
找到.s.PGSQL.5432什么都不輸出.
系統日志有:
Aug 14 17:31:58 localhost systemd[1]: postgresql-9.1.service: control process exited, code=exited status=1
Aug 14 17:31:58 localhost systemd[1]: Unit postgresql-9.1.service entered failed state.
一個
systemctl status postgresql-9.1.service
給
postgresql-9.1.service - SYSV: PostgreSQL database server.
Loaded: loaded (/etc/rc.d/init.d/postgresql-9.1)
Active: failed since Tue, 14 Aug 2012 17:31:58 +0530; 58s ago
Process: 2811 ExecStop=/etc/rc.d/init.d/postgresql-9.1 stop (code=exited, status=1/FAILURE)
Process: 12423 ExecStart=/etc/rc.d/init.d/postgresql-9.1 start (code=exited, status=1/FAILURE)
Main PID: 2551 (code=exited, status=1/FAILURE)
CGroup: name=systemd:/system/postgresql-9.1.service
我沒有改變fsync的默認設置,所以我猜,它被設置為開啟.我在硬盤上.硬盤崩潰了.
硬盤崩潰
硬盤崩潰導致在提示符上運行手動fsck而不是基于gui.隨著它修復gazillion inode等..之后我用Ctrl Alt Delete重新啟動系統.
PostgreSQL的日志有這個:
LOG: database system was interrupted; last known up at 2012-08-14 17:31:57 IST
LOG: database system was not properly shut down; automatic recovery in progress
LOG: record with zero length at 0/41A4E58
LOG: redo is not required
FATAL: could not access status of transaction 1
DETAIL: Could not open file "pg_multixact/offsets/0000": No such file or directory.
LOG: startup process (PID 13016) exited with exit code 1
LOG: aborting startup due to startup process failure
更新
嘗試在獲取/ var / lib / pgsql目錄的文件系統級副本并運行./pg_resetxlog -f /var/lib/pgsql/9.1/data/并使用結果xlog -f / var / lib后啟動服務器/pgsql/9.1/data/仍然產生于:
LOG: database system was interrupted; last known up at 2012-08-14 18:46:36 IST
LOG: database system was not properly shut down; automatic recovery in progress
LOG: record with zero length at 0/6000078
LOG: redo is not required
FATAL: could not access status of transaction 1
DETAIL: Could not open file "pg_multixact/offsets/0000": No such file or directory.
LOG: startup process (PID 13766) exited with exit code 1
LOG: aborting startup due to startup process failure
解決方法:
真正的答案將在PostgreSQL日志中,在/ var / lib / pgsql / data / pg_log中.
但是,在您采取任何措施之前:如果您的任何數據對您有價值,那么在嘗試修復之前獲取數據庫的文件系統級副本至關重要.見http://wiki.postgresql.org/wiki/Corruption.您必須復制整個數據目錄.在Fedora上默認是/ var / lib / pgsql / data,但驗證安裝是否正確.
根據您發布的日志,您肯定會有一定程度的數據庫損壞.數據庫所在的存儲(硬盤驅動器或文件系統)很可能已損壞.立即復制,并將其放在不同的硬盤或系統上.
只有在創建了數據目錄的完整文件系統級副本后,才能嘗試使用pg_resetxlog清除損壞的事務日志并啟動數據庫.即使它開始它也很可能是腐敗的;你應該pg_dump然后重新initdb它并將轉儲恢復到新的實例.
如果在pg_resetxlog之后仍無法啟動它,則在resetxlog之后發布啟動嘗試的更新日志.您可能需要在獨立模式下啟動Pg:
sudo -u postgres postgres --single -D /var/lib/pgsql/data -P -f i postgres
如果有效,給你一個后端>提示,在使用您要連接的數據庫的名稱替換最后一個“postgres”后再試一次.您應該能夠從表格中選擇,復制數據等.
如果這不起作用,即你無法啟動一個獨立的后端,那么可能是時候從備份恢復了 – 因為你有足夠的知識來擁有它們.如果讀取此內容的其他人處于相同位置,請查看contact an experienced PostgreSQL consultant是否可以從數據庫中恢復數據.準備好支付他們的時間和專業知識.
您的文件系統可能已損壞
PostgreSQL安裝損壞的嚴重性表明您的整個文件系統可能已損壞.您可能希望考慮從備份還原整個系統或重新安裝它.
我不相信這個文件系統,fsck或沒有fsck.
對驅動器進行SMART測試
我還建議您使用smartmontools的smartctl對硬盤進行SMART檢查;假設它是/ dev / hda,它是smartctl -d ata -a / dev / sda |減 .查找失敗的運行狀況測試,uncorrectable_sectors,高讀取錯誤率,reallocated_sector_count超過2或3,或者非零current_pending_sector.運行smartctl -d ata -t long / dev / sda對硬盤執行非破壞性自檢;它不會中斷系統的正常運行.當估計的時間過去后,再次運行smartctl -d ata / dev / sda并查看自檢日志以查看它是否通過.
如果看起來不完美,請更換驅動器.
將來,請考慮通過smartd自動執行此測試,以便對驅動器故障進行預警.
(此帖子中的內容已被問題更新廢棄.如果您要解決類似問題,請查看此答案的編輯歷史記錄).
標簽:linux,postgresql
來源: https://codeday.me/bug/20190805/1589420.html
總結
以上是生活随笔為你收集整理的linux fsck exited with status code 4,linux – 在硬盘崩溃后启动PostgreSQL服务器导致FAILED STATE...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c 语言贪心钓鱼思路,2020届九年级中
- 下一篇: android 输入过滤,Android