1. 程式人生 > >誤刪WAL日誌後如何啟動資料庫

誤刪WAL日誌後如何啟動資料庫

WAL日誌是瀚高資料庫至關重要的日誌檔案,資料恢復的重要依靠保障,如果誤刪了資料庫會怎樣呢?

模擬情況:
 

[[email protected] data]$ pg_ctl start
server starting
[[email protected] data]$ LOG:  00000: database system was shut down at 2018-11-14 23:31:31 CST
LOG:  00000: creating missing WAL directory "pg_xlog/archive_status"
LOG:  00000: invalid primary checkpoint record
LOG:  00000: invalid secondary checkpoint record
PANIC:  XX000: could not locate a valid checkpoint record

[
[email protected]
data]$ psql FATAL: 57P03: the database system is starting up psql: FATAL: 57P03: the database system is starting up [[email protected] data]$ LOG: 00000: startup process (PID 5967) was terminated by signal 6: Aborted LOG: 00000: aborting startup due to startup process failure [[email protected]
data]$ [[email protected] data]$ 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.5866"?

可以發現數據庫已經起不來了,找不到相應的WAL日誌檔案。如果我們沒有對應的wal檔案的話,則只能:

[[email protected] data]$ pg_resetxlog -D $PGDATA
Transaction log reset

啟動資料庫:

[[email protected] data]$ pg_ctl start
server starting
[[email protected] data]$ LOG:  00000: database system was shut down at 2018-11-14 23:39:15 CST
LOG:  00000: MultiXact member wraparound protections are now enabled
LOG:  00000: database system is ready to accept connections
LOG:  00000: autovacuum launcher started

[[email protected] data]$ psql
psql (4.7.6)

PSQL: Release 4.7.6
Connected to:
HighGo Database V4.7 Enterprise Edition Release 4.7.6 - 64-bit Production

Type "help" for help.

highgo=# 




BY 海無涯