linux fsck exited with status code 4,linux – 在硬盘崩溃后启动PostgreSQL服务器导致FAILED STATE...
我正在使用Fedora 15和PostgreSQL 9.1.4. Fedora最近崩潰了,之后:
嘗試啟動(dòng)PostgreSQL服務(wù)器:
service postgresql-9.1 start
給
Starting postgresql-9.1 (via systemctl): Job failed. See system logs and 'systemctl status' for details.
[FAILED]
雖然,在系統(tǒng)重啟后第一次啟動(dòng)服務(wù)器時(shí)服務(wù)器正常啟動(dòng).
但是,嘗試使用psql會(huì)出現(xiàn)此錯(cuò)誤:
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文件不存在于系統(tǒng)的任何位置.
找到.s.PGSQL.5432什么都不輸出.
系統(tǒng)日志有:
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.
一個(gè)
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
我沒(méi)有改變fsync的默認(rèn)設(shè)置,所以我猜,它被設(shè)置為開啟.我在硬盤上.硬盤崩潰了.
硬盤崩潰
硬盤崩潰導(dǎo)致在提示符上運(yùn)行手動(dòng)fsck而不是基于gui.隨著它修復(fù)gazillion inode等..之后我用Ctrl Alt Delete重新啟動(dòng)系統(tǒng).
PostgreSQL的日志有這個(gè):
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目錄的文件系統(tǒng)級(jí)副本并運(yùn)行./pg_resetxlog -f /var/lib/pgsql/9.1/data/并使用結(jié)果xlog -f / var / lib后啟動(dòng)服務(wù)器/pgsql/9.1/data/仍然產(chǎn)生于:
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中.
但是,在您采取任何措施之前:如果您的任何數(shù)據(jù)對(duì)您有價(jià)值,那么在嘗試修復(fù)之前獲取數(shù)據(jù)庫(kù)的文件系統(tǒng)級(jí)副本至關(guān)重要.見http://wiki.postgresql.org/wiki/Corruption.您必須復(fù)制整個(gè)數(shù)據(jù)目錄.在Fedora上默認(rèn)是/ var / lib / pgsql / data,但驗(yàn)證安裝是否正確.
根據(jù)您發(fā)布的日志,您肯定會(huì)有一定程度的數(shù)據(jù)庫(kù)損壞.數(shù)據(jù)庫(kù)所在的存儲(chǔ)(硬盤驅(qū)動(dòng)器或文件系統(tǒng))很可能已損壞.立即復(fù)制,并將其放在不同的硬盤或系統(tǒng)上.
只有在創(chuàng)建了數(shù)據(jù)目錄的完整文件系統(tǒng)級(jí)副本后,才能嘗試使用pg_resetxlog清除損壞的事務(wù)日志并啟動(dòng)數(shù)據(jù)庫(kù).即使它開始它也很可能是腐敗的;你應(yīng)該pg_dump然后重新initdb它并將轉(zhuǎn)儲(chǔ)恢復(fù)到新的實(shí)例.
如果在pg_resetxlog之后仍無(wú)法啟動(dòng)它,則在resetxlog之后發(fā)布啟動(dòng)嘗試的更新日志.您可能需要在獨(dú)立模式下啟動(dòng)Pg:
sudo -u postgres postgres --single -D /var/lib/pgsql/data -P -f i postgres
如果有效,給你一個(gè)后端>提示,在使用您要連接的數(shù)據(jù)庫(kù)的名稱替換最后一個(gè)“postgres”后再試一次.您應(yīng)該能夠從表格中選擇,復(fù)制數(shù)據(jù)等.
如果這不起作用,即你無(wú)法啟動(dòng)一個(gè)獨(dú)立的后端,那么可能是時(shí)候從備份恢復(fù)了 – 因?yàn)槟阌凶銐虻闹R(shí)來(lái)?yè)碛兴鼈?如果讀取此內(nèi)容的其他人處于相同位置,請(qǐng)查看contact an experienced PostgreSQL consultant是否可以從數(shù)據(jù)庫(kù)中恢復(fù)數(shù)據(jù).準(zhǔn)備好支付他們的時(shí)間和專業(yè)知識(shí).
您的文件系統(tǒng)可能已損壞
PostgreSQL安裝損壞的嚴(yán)重性表明您的整個(gè)文件系統(tǒng)可能已損壞.您可能希望考慮從備份還原整個(gè)系統(tǒng)或重新安裝它.
我不相信這個(gè)文件系統(tǒng),fsck或沒(méi)有fsck.
對(duì)驅(qū)動(dòng)器進(jìn)行SMART測(cè)試
我還建議您使用smartmontools的smartctl對(duì)硬盤進(jìn)行SMART檢查;假設(shè)它是/ dev / hda,它是smartctl -d ata -a / dev / sda |減 .查找失敗的運(yùn)行狀況測(cè)試,uncorrectable_sectors,高讀取錯(cuò)誤率,reallocated_sector_count超過(guò)2或3,或者非零current_pending_sector.運(yùn)行smartctl -d ata -t long / dev / sda對(duì)硬盤執(zhí)行非破壞性自檢;它不會(huì)中斷系統(tǒng)的正常運(yùn)行.當(dāng)估計(jì)的時(shí)間過(guò)去后,再次運(yùn)行smartctl -d ata / dev / sda并查看自檢日志以查看它是否通過(guò).
如果看起來(lái)不完美,請(qǐng)更換驅(qū)動(dòng)器.
將來(lái),請(qǐng)考慮通過(guò)smartd自動(dòng)執(zhí)行此測(cè)試,以便對(duì)驅(qū)動(dòng)器故障進(jìn)行預(yù)警.
(此帖子中的內(nèi)容已被問(wèn)題更新廢棄.如果您要解決類似問(wèn)題,請(qǐng)查看此答案的編輯歷史記錄).
標(biāo)簽:linux,postgresql
來(lái)源: https://codeday.me/bug/20190805/1589420.html
總結(jié)
以上是生活随笔為你收集整理的linux fsck exited with status code 4,linux – 在硬盘崩溃后启动PostgreSQL服务器导致FAILED STATE...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: c 语言贪心钓鱼思路,2020届九年级中
- 下一篇: android 输入过滤,Android