当PG_WAL目录的文件被删除时的处理

当PG_WAL目录的文件被删除时的处理

环境:pg14.13

模拟删除wal日志:

pg_ctl stop -m fast
cd pg_wal
rm 00*

启动数据库:

pg_ctl -l logfile start

输出:

waiting for server to start.... stopped waiting
pg_ctl: could not start server
Examine the log output.

查看日志文件logfile:

15:45:40.518 CST [48241] LOG:  starting PostgreSQL 14.13 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
15:45:40.519 CST [48241] LOG:  listening on IPv6 address "::1", port 5432
15:45:40.519 CST [48241] LOG:  listening on IPv4 address "127.0.0.1", port 5432
15:45:40.520 CST [48241] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
15:45:40.545 CST [48242] LOG:  database system was shut down at 2024-10-10 15:44:21 CST
15:45:40.545 CST [48242] LOG:  invalid primary checkpoint record
15:45:40.545 CST [48242] PANIC:  could not locate a valid checkpoint record
15:45:40.854 CST [48241] LOG:  startup process (PID 48242) was terminated by signal 6: Aborted
15:45:40.854 CST [48241] LOG:  aborting startup due to startup process failure
15:45:40.868 CST [48241] LOG:  database system is shut down

故障处理:

当pg_wal目录的文件被删除导致checkpoint损坏时,可以使用postgres用户身份执行pg_resetwal命令,来修复问题并重新启动数据库。

pg_resetwal -f /data/postgres/14.13/data/

随后成功启动数据库:

pg_ctl -l logfile start
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

shulu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值