误删WAL日志后如何启动数据库

作者:瀚高PG实验室 (Highgo PG Lab)- 海无涯

WAL日志是瀚高数据库至关重要的日志文件,数据恢复的重要依靠保障,如果误删了数据库会怎样呢?

模拟情况:
 

[highgo@sds1 data]$ pg_ctl start
server starting
[highgo@sds1 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

[highgo@sds1 data]$ psql
FATAL:  57P03: the database system is starting up
psql: FATAL:  57P03: the database system is starting up
[highgo@sds1 data]$ LOG:  00000: startup process (PID 5967) was terminated by signal 6: Aborted
LOG:  00000: aborting startup due to startup process failure

[highgo@sds1 data]$ 
[highgo@sds1 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文件的话,则只能:

[highgo@sds1 data]$ pg_resetxlog -D $PGDATA
Transaction log reset

启动数据库:

[highgo@sds1 data]$ pg_ctl start
server starting
[highgo@sds1 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

[highgo@sds1 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=# 




 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值