postgresql 数据库 报错 FATAL: the database system is shutting down 解决方法
目录
问题原因
解决过程
查看主机进程
关闭数据库
创建 postmaster.pid 文件
再次尝试关闭数据库
启动数据库
总结
问题原因
服务器在同一个数据目录上启动了两个PostgreSQL实例(它已经删除postmaster.pid
并使用了新的端口号,因此绕过了这种行为的正常保护措施被绕过),导致PostgreSQL的误操作
解决过程
查看主机进程
[root@localhost ~]# ps -ef[root@localhost ~]# su - postgres
执行命令可以看出,PostgreSQL 进程还在,但是psql查看端口发现没有端口:
查看端口命令:netstat -a | grep PGSQL
尝试链接也提示端口未启动.
连接psql
# psql -h 127.0.0.1 -d postgres -U postgres
psql: could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?
# psql -p 1921
psql: FATAL: the database system is shutting down
数据库连接不上,报 “the database system is shutting down” , 意思是数据库正在关闭, 而 PostgreSQL 进程明明都还在,再仔细观察了上面步骤的进程,发现有十几个“ 127.0.0.1(40181) idle in transaction” 难道是这些进程发生了异常.
关闭数据库
[postgre@localhost data]$ pg_ctl stop -m fast
pg_ctl: PID file "/opt/postgresql-9.0.1/data/postmaster.pid" does not exist
Is server running?
数据库无法关闭, 文件 postmaster.pid 不存在
创建 postmaster.pid 文件
参照其它库的 postmaster,pid 文件,构造了一个,创建文件 /opt/postgresql-9.0.1/data/postmaster.pid , 并增加以下内容:
27639
/opt/postgresql-9.0.1/data
备注: 第一行: “27639” 表示 PostgreSQL 的父进程,根据步骤一的红色标识可以看到;
第二行: “/opt/postgresql-9.0.1/data” 表示数据目录;
第三行:正常情况下,第三行还有两个字段,但具体信息不详,无法构造。
再次尝试关闭数据库
[postgre@localhost data]$ pg_ctl stop -m fast -D $PGDATA
waiting for server to shut down.... done
server stopped
启动数据库
[postgre@localhost data]$ pg_ctl start -D $PGDATA
server starting
再次检查端口,并尝试链接;
查看端口命令:netstat -a | grep PGSQL
链接psql:psql -h 127.0.0.1 -d postgres -U postgres
一切都正常了,搞定!
总结
至今 postmaster.pid 文件丢失原因尚不明确,但这次通过构造 postmaster.pid 文件从而将数据库成功恢复!
postgresql 数据库 报错 FATAL: the database system is shutting down 解决方法相关推荐
- git合并代码报错 fatal: refusing to merge unrelated histories,解决方法
git merge upstream/master --allow-unrelated-histories 在合并分支提示"refusing to merge unrelated histo ...
- VS Code 报错 local-server-1> ssh child died, shutting down解决方法
解决方法: Remote SSH -> Extension Setting -> "remote.SSH.useLocalServer": false 下面勾掉
- SQL Server 删除数据库报错 Cannot drop database dbname because it is currently in use
SQL Server 删除数据库报错 Cannot drop database "dbname" because it is currently in use SQL Server ...
- mysql table plugin,MySql报错Table mysql.plugin doesn’t exist的解决方法
MySql报错Table mysql.plugin doesn't exist的解决方法 一般产生原因是手工更改my.ini的数据库文件存放地址导致的 mysql服务启动时候找不到内置数据库" ...
- vue 报错 Cannot read property ‘__ob__‘ of undefined的解决方法
vue 报错 Cannot read property '__ob__' of undefined的解决方法 参考文章: (1)vue 报错 Cannot read property '__ob__' ...
- python 报错 AttributeError: module ‘time‘ has no attribute ‘clock 解决方法
源码如下: #引入所需要的时间库 import datetime import time#程序计时器,启动计时器 start = time.clock()#中间是放置需要测试运行时间的程序代码#计算启 ...
- php 正则报错,PHP正则替换函数preg_replace()报错:Notice Use of undefined constant的解决方法分析...
本文实例讲述了PHP正则替换函数preg_replace()报错:Notice Use of undefined constant的解决方法.分享给大家供大家参考,具体如下: 环境错误级别:error ...
- 支付宝 报错 rsa_private read error : private key is NULL解决方法
原因: 真机调试IOS支付宝功能GDB出现 rsa_private read error : private key is NULL提示 调试iOS 支付宝SDK的时候,执行demo.把 Partn ...
- zabbix报错cannot set resource limit: [13] Permission denied解决方法
zabbix报错cannot set resource limit: [13] Permission denied解决方法 参考文章: (1)zabbix报错cannot set resource l ...
最新文章
- RPA+AI这个278亿市场规模的赛道,IDC的这份报告讲清楚了
- servlrt程序的入口点是_小程序深度报告:全网数量约550万,日活跃超4.4亿
- xml解析: dom4j
- 0与1世界的初级编程篇之C语言
- hdfs fsck命令查看HDFS文件对应的文件块信息(Block)和位置信息(Locations)
- 应用机器学习(八):线性模型
- Android 10 深色模式适配
- 计算机专业 在职跨英语,英语在职研究生跨专业可以吗?
- HDU 4234 Moving Points
- 读书笔记:《关于上班这件事--自序·朱德庸》
- 最好用的分组数据可视化工具--Seaborn调色盘
- CRC校验原理及CRC-8简单校验函数设计
- outlook邮箱邮件大小限制_Office Outlook 2010、2013附件大小超过了允许的范围限制三种解决方法图解...
- Node.js结合wechaty实现个人微信机器人助手
- python 语言属于_python语言属于以下哪种语言?
- 数据库:MySQL 修改密码
- copy() 与 clone() 的区别
- Delphi procedure and function
- StringTie用法详解
- 一些适合刷算法的网站