暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

启动PostgreSQL提示startup process (PID 1501) was terminated by signal 6: 已放弃


场景还原:

主机突然断电,此时PG服务未正常关闭的情况下,再次启动PG服务,提示:startup process (PID 1501) was terminated by signal 6: 已放弃


1、尝试启动PG服务

  • 代码如下:
[postgres@PostgreSQL_Beta ~]$ pg_ctl start
waiting for server to start....2024-06-17 21:08:01.090 CST [1498] LOG:  starting PostgreSQL 17beta1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2024-06-17 21:08:01.090 CST [1498] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2024-06-17 21:08:01.090 CST [1498] LOG:  listening on IPv6 address "::", port 5432
2024-06-17 21:08:01.093 CST [1498] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2024-06-17 21:08:01.098 CST [1501] LOG:  database system was shut down at 2024-06-17 17:24:00 CST
2024-06-17 21:08:01.099 CST [1501] LOG:  invalid checkpoint record
2024-06-17 21:08:01.099 CST [1501] PANIC:  could not locate a valid checkpoint record at 0/1B000028
2024-06-17 21:08:01.339 CST [1498] LOG:  startup process (PID 1501) was terminated by signal 6: 已放弃
2024-06-17 21:08:01.339 CST [1498] LOG:  aborting startup due to startup process failure
2024-06-17 21:08:01.340 CST [1498] LOG:  database system is shut down
 stopped waiting
pg_ctl: could not start server
Examine the log output.
[postgres@PostgreSQL_Beta ~]$

2、重置WAL日志

说明: pg_resetwal命令是用于重置PostgreSQL数据库集群的写前日志(WAL)和其他控制信息的工具。这个命令通常在数据损坏或者需要回滚到特定状态时使用。

  • 代码如下:
[postgres@PostgreSQL_Beta ~]$ 
[postgres@PostgreSQL_Beta ~]$ pg_resetwal  -f $PGDATA
Write-ahead log reset

3、启动 PG服务

  • 代码如下:
[postgres@PostgreSQL_Beta ~]$ pg_ctl start
waiting for server to start....2024-06-17 21:14:33.582 CST [1507] LOG:  starting PostgreSQL 17beta1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2024-06-17 21:14:33.583 CST [1507] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2024-06-17 21:14:33.583 CST [1507] LOG:  listening on IPv6 address "::", port 5432
2024-06-17 21:14:33.585 CST [1507] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2024-06-17 21:14:33.590 CST [1510] LOG:  database system was shut down at 2024-06-17 21:14:18 CST
2024-06-17 21:14:33.598 CST [1507] LOG:  database system is ready to accept connections
 done
server started

4、测试登录,检查数据是否丢失

  • 代码如下: 代码如下:
[postgres@PostgreSQL_Beta ~]$ psql
psql (17beta1)
Type "help" for help.

postgres=#

5、补充资料:

pg_resetwal命令是PostgreSQL数据库中用于重置WAL(Write-Ahead Log)的工具,它在某些极端情况下可以帮助恢复数据库的一致性。然而,使用pg_resetwal命令也伴随着一系列潜在风险:
  • 数据丢失:pg_resetwal命令会删除所有未完成的事务,这可能导致这些事务中的数据永久丢失。
  • 数据一致性问题:如果数据库中存在部分提交的事务,pg_resetwal可能会导致数据不一致的情况。 在某些情况下,pg_resetwal可能会导致数据库损坏,特别是如果在执行命令之前没数据库损坏:有正确设置所有必要的参数。
  • 依赖关系破坏:pg_resetwal可能会破坏数据库与其他系统组件之间的依赖关系,例如流复制或归档策略。
  • 安全风险:pg_resetwal命令可能会被恶意使用,从而绕过正常的数据库安全措施,导致安全漏洞。

总结:

在使用pg_resetwal命令之前,应当充分了解其潜在风险,并采取适当的预防措施,例如备份数据库、确保没有活跃的事务、仔细检查所有必要的参数设置,并在有经验的管理员的指导下进行操作。
最后修改时间:2024-06-18 16:53:27
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论