技术交流QQ群:①185473046   ②190706903   ③203744115   网站地图
登录

下次自动登录
现在的位置: 首页Linux>正文
PostgreSQL数据库pg_wal目录文件损坏修复
2023年12月07日 Linux 暂无评论 ⁄ 被围观 1,007次+

pgsql安装目录:/data/server/pgsql

pgsql数据库存放目录:/data/server/pgsql/data

故障现象:因为磁盘爆满导致数据库目录下pg_wal里的文件丢失或损坏,数据库无法启动,报错。

报错信息:

2023-11-13 17:29:07.005 CST [152671] FATAL: the database system is starting up

2023-11-13 17:29:07.019 CST [152668] LOG: invalid primary checkpoint record

2023-11-13 17:29:07.019 CST [152668] PANIC: could not locate a valid checkpoint record

2023-11-13 17:29:07.070 CST [152667] LOG: startup process (PID 152668) was terminated by signal 6: Aborted

2023-11-13 17:29:07.070 CST [152667] LOG: aborting startup due to startup process failure

2023-11-13 17:29:07.100 CST [152667] LOG: database system is shut down

信息解读:

根据日志信息,发现数据库系统启动过程中遇到了问题。具体原因可能是:

数据库系统异常关闭:在上次已知的正常运行时间(2023-11-12 16:01:09 CST)之后,数据库系统可能遭遇了意外关闭,导致启动过程中出现问题。

检查点记录无效:出现了“invalid primary checkpoint record”和“could not locate a valid checkpoint record”等错误信息,这表明检查点记录可能丢失或损坏,导致数据库无法正确启动。

问题修复:

使用pg_resetwal工具重置 PostgreSQL 数据库集群的预写日志和其他控制信息。

mv /data/server/pgsql/data/pg_wal /data/server/pgsql/data/pg_wal.bak

mkdir -p  /data/server/pgsql/data/pg_wal

cd /data/server/pgsql/bin

./pg_resetwal -f /data/server/pgsql/data #修复

Write-ahead log reset #有提示信息说明修复成功

/data/server/pgsql/bin/pg_ctl -D /data/server/pgsql/data -l /data/server/pgsql/data/pg_server.log start #启动数据库,修复完成。

备注:这种方法一般只能修复主库,从库需要重新同步主库。

#关闭数据库

sh /data/server/pgsql/pgsql.sh stop #停止

rm -rf /data/server/pgsql/data/* #清空目录

#从库执行数据同步

/data/server/pgsql/bin/pg_basebackup -Fp --progress -D /data/server/pgsql/data -R -h 192.168.236.136 -p 5432 -U repl --password

至此,PostgreSQL数据库pg_wal目录文件损坏修复完成。

     

  系统运维技术交流QQ群:①185473046 系统运维技术交流□Ⅰ ②190706903 系统运维技术交流™Ⅱ ③203744115 系统运维技术交流™Ⅲ

给我留言

您必须 [ 登录 ] 才能发表留言!



Copyright© 2011-2024 系统运维 All rights reserved
版权声明:本站所有文章均为作者原创内容,如需转载,请注明出处及原文链接
陕ICP备11001040号-3