postgres使用pg_resetxlog命令重置一个数据库集群的预写日志以及其它控制内容
2016-12-23 13:36
1706 查看
情景:
今天像平常一样连接数据库,出现了一下信息,
[postgres@cqs postgresql-9.5]$ psql
psql: could not connect to server: 拒绝连接
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
这时候再看看本地的postgres是不是没打开,此环境之前设置了开机自启动pg服务,使用命令“ps -ef | grep postgres”
[postgres@cqs postgresql-9.5]$ ps -ef | grep postgres
root 1640 1630 0 03:30 pts/0 00:00:00 su postgres
postgres 1641 1640 0 03:30 pts/0 00:00:00 bash
postgres 1725 1641 7 03:40 pts/0 00:00:00 ps -ef
postgres 1726 1641 0 03:40 pts/0 00:00:00 grep postgres
发现服务真的没启动起来。。。
启动服务,
[postgres@cqs postgresql-9.5]$ pg_ctl start
server starting
[postgres@cqs postgresql-9.5]$ LOG: redirecting log output to logging collector process
HINT: Future log output will appear in directory "pg_log".
一直卡在这里,这时候得看一下对应的日志档查看是不是出了问题。
对应的日志档存在pg_log中
[root@cqs pg_log]# cd /home/postgres/data/pg_log
[root@cqs pg_log]# cat postgresql-2016-12-23_035509.csv
2016-12-23 03:55:09.754 CST,,,1765,,585c2f9d.6e5,1,,2016-12-23 03:55:09 CST,,0,LOG,00000,"ending log output to stderr",,"Future log output will go to log destination ""csvlog"".",,,,,,,""
2016-12-23 03:55:09.758 CST,,,1767,,585c2f9d.6e7,1,,2016-12-23 03:55:09 CST,,0,LOG,00000,"database system shutdown was interrupted; last known up at 2016-12-23 03:40:27 CST",,,,,,,,,""
2016-12-23 03:55:09.843 CST,,,1767,,585c2f9d.6e7,2,,2016-12-23 03:55:09 CST,,0,LOG,00000,"database system was not properly shut down; automatic recovery in progress",,,,,,,,,""
2016-12-23 03:55:09.847 CST,,,1767,,585c2f9d.6e7,3,,2016-12-23 03:55:09 CST,,0,LOG,00000,"redo starts at 1/F6005B20",,,,,,,,,""
2016-12-23 03:55:09.847 CST,,,1767,,585c2f9d.6e7,4,,2016-12-23 03:55:09 CST,,0,LOG,00000,"redo done at 1/F6005C00",,,,,,,,,""
2016-12-23 03:55:09.911 CST,,,1767,,585c2f9d.6e7,5,,2016-12-23 03:55:09 CST,,0,PANIC,53100,"could not write to file ""pg_xlog/xlogtemp.1767"": No space left on device",,,,,,,,,""
2016-12-23 03:55:09.911 CST,,,1765,,585c2f9d.6e5,2,,2016-12-23 03:55:09 CST,,0,LOG,00000,"startup process (PID 1767) was terminated by signal 6: Aborted",,,,,,,,,""
2016-12-23 03:55:09.911 CST,,,1765,,585c2f9d.6e5,3,,2016-12-23 03:55:09 CST,,0,LOG,00000,"aborting startup due to startup process failure",,,,,,,,,""
log提示数据库系统关闭时收到干扰,主要原因应该是由于数据库日志档出现问题了。
翻了好多资料,抱着试一试尝试了pg_resetxlog
pg_resetxlog相关用法
名称
pg_resetxlog -- 重置一个数据库集群的预写日志以及其它控制内容
语法
pg_resetxlog [-f] [-n] [-ooid ] [-x xid ] [-e xid_epoch ] [-m mxid ] [-O mxoff ] [-l timelineid, fileid, seg ] datadir
描述
pg_resetxlog 清理预写日志(WAL)并且可以有选择地重置其它一些存储在 pg_control 文件中的控制信息。有时候,如果这些文件崩溃了,就需要这个功能。一定只把它用作最后的方法,就是说只有因为这样的崩溃导致服务器无法启动的时候才使用。
[postgres@cqs bin]$ pg_resetxlog /home/postgres/data/
The database server was not shut down cleanly.
Resetting the transaction log might cause data to be lost.
If you want to proceed anyway, use -f to force reset.
[postgres@cqs bin]$ pg_resetxlog -f /home/postgres/data/
Transaction log reset
好了,完成清理预写日志命令,启动pg数据库服务器
[postgres@cqs bin]$ pg_ctl start
server starting
[postgres@cqs bin]$ LOG: redirecting log output to logging collector process
HINT: Future log output will appear in directory "pg_log".
[root@cqs pg_log]# ps -ef | grep postgres
root 1640 1630 0 03:30 pts/0 00:00:00 su postgres
postgres 1641 1640 0 03:30 pts/0 00:00:00 bash
postgres 1805 1 0 04:46 pts/0 00:00:00 /usr/local/postgresql-9.5/bin/postgres
postgres 1806 1805 0 04:46 ? 00:00:00 postgres: logger process
postgres 1808 1805 0 04:46 ? 00:00:00 postgres: checkpointer process
postgres 1809 1805 0 04:46 ? 00:00:00 postgres: writer process
postgres 1810 1805 0 04:46 ? 00:00:00 postgres: wal writer process
postgres 1811 1805 0 04:46 ? 00:00:00 postgres: autovacuum launcher process
postgres 1812 1805 0 04:46 ? 00:00:00 postgres: archiver process failed on 000000010000000000000002.00000028.backup
postgres 1813 1805 0 04:46 ? 00:00:00 postgres: stats collector process
postgres 1819 1641 0 04:47 pts/0 00:00:00 psql
postgres 1820 1805 0 04:47 ? 00:00:00 postgres: postgres postgres 127.0.0.1(33254) idle
root 1952 1666 0 05:15 pts/1 00:00:00 grep postgres
这时候相关的postgres服务正常启动了,连接数据库
[postgres@cqs bin]$ psql
psql (9.5alpha2)
Type "help" for help.
postgres=#
postgres=#
成功连上数据库,又可以愉快地操作对应的数据库了。
今天像平常一样连接数据库,出现了一下信息,
[postgres@cqs postgresql-9.5]$ psql
psql: could not connect to server: 拒绝连接
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
这时候再看看本地的postgres是不是没打开,此环境之前设置了开机自启动pg服务,使用命令“ps -ef | grep postgres”
[postgres@cqs postgresql-9.5]$ ps -ef | grep postgres
root 1640 1630 0 03:30 pts/0 00:00:00 su postgres
postgres 1641 1640 0 03:30 pts/0 00:00:00 bash
postgres 1725 1641 7 03:40 pts/0 00:00:00 ps -ef
postgres 1726 1641 0 03:40 pts/0 00:00:00 grep postgres
发现服务真的没启动起来。。。
启动服务,
[postgres@cqs postgresql-9.5]$ pg_ctl start
server starting
[postgres@cqs postgresql-9.5]$ LOG: redirecting log output to logging collector process
HINT: Future log output will appear in directory "pg_log".
一直卡在这里,这时候得看一下对应的日志档查看是不是出了问题。
对应的日志档存在pg_log中
[root@cqs pg_log]# cd /home/postgres/data/pg_log
[root@cqs pg_log]# cat postgresql-2016-12-23_035509.csv
2016-12-23 03:55:09.754 CST,,,1765,,585c2f9d.6e5,1,,2016-12-23 03:55:09 CST,,0,LOG,00000,"ending log output to stderr",,"Future log output will go to log destination ""csvlog"".",,,,,,,""
2016-12-23 03:55:09.758 CST,,,1767,,585c2f9d.6e7,1,,2016-12-23 03:55:09 CST,,0,LOG,00000,"database system shutdown was interrupted; last known up at 2016-12-23 03:40:27 CST",,,,,,,,,""
2016-12-23 03:55:09.843 CST,,,1767,,585c2f9d.6e7,2,,2016-12-23 03:55:09 CST,,0,LOG,00000,"database system was not properly shut down; automatic recovery in progress",,,,,,,,,""
2016-12-23 03:55:09.847 CST,,,1767,,585c2f9d.6e7,3,,2016-12-23 03:55:09 CST,,0,LOG,00000,"redo starts at 1/F6005B20",,,,,,,,,""
2016-12-23 03:55:09.847 CST,,,1767,,585c2f9d.6e7,4,,2016-12-23 03:55:09 CST,,0,LOG,00000,"redo done at 1/F6005C00",,,,,,,,,""
2016-12-23 03:55:09.911 CST,,,1767,,585c2f9d.6e7,5,,2016-12-23 03:55:09 CST,,0,PANIC,53100,"could not write to file ""pg_xlog/xlogtemp.1767"": No space left on device",,,,,,,,,""
2016-12-23 03:55:09.911 CST,,,1765,,585c2f9d.6e5,2,,2016-12-23 03:55:09 CST,,0,LOG,00000,"startup process (PID 1767) was terminated by signal 6: Aborted",,,,,,,,,""
2016-12-23 03:55:09.911 CST,,,1765,,585c2f9d.6e5,3,,2016-12-23 03:55:09 CST,,0,LOG,00000,"aborting startup due to startup process failure",,,,,,,,,""
log提示数据库系统关闭时收到干扰,主要原因应该是由于数据库日志档出现问题了。
翻了好多资料,抱着试一试尝试了pg_resetxlog
pg_resetxlog相关用法
名称
pg_resetxlog -- 重置一个数据库集群的预写日志以及其它控制内容
语法
pg_resetxlog [-f] [-n] [-ooid ] [-x xid ] [-e xid_epoch ] [-m mxid ] [-O mxoff ] [-l timelineid, fileid, seg ] datadir
描述
pg_resetxlog 清理预写日志(WAL)并且可以有选择地重置其它一些存储在 pg_control 文件中的控制信息。有时候,如果这些文件崩溃了,就需要这个功能。一定只把它用作最后的方法,就是说只有因为这样的崩溃导致服务器无法启动的时候才使用。
[postgres@cqs bin]$ pg_resetxlog /home/postgres/data/
The database server was not shut down cleanly.
Resetting the transaction log might cause data to be lost.
If you want to proceed anyway, use -f to force reset.
[postgres@cqs bin]$ pg_resetxlog -f /home/postgres/data/
Transaction log reset
好了,完成清理预写日志命令,启动pg数据库服务器
[postgres@cqs bin]$ pg_ctl start
server starting
[postgres@cqs bin]$ LOG: redirecting log output to logging collector process
HINT: Future log output will appear in directory "pg_log".
[root@cqs pg_log]# ps -ef | grep postgres
root 1640 1630 0 03:30 pts/0 00:00:00 su postgres
postgres 1641 1640 0 03:30 pts/0 00:00:00 bash
postgres 1805 1 0 04:46 pts/0 00:00:00 /usr/local/postgresql-9.5/bin/postgres
postgres 1806 1805 0 04:46 ? 00:00:00 postgres: logger process
postgres 1808 1805 0 04:46 ? 00:00:00 postgres: checkpointer process
postgres 1809 1805 0 04:46 ? 00:00:00 postgres: writer process
postgres 1810 1805 0 04:46 ? 00:00:00 postgres: wal writer process
postgres 1811 1805 0 04:46 ? 00:00:00 postgres: autovacuum launcher process
postgres 1812 1805 0 04:46 ? 00:00:00 postgres: archiver process failed on 000000010000000000000002.00000028.backup
postgres 1813 1805 0 04:46 ? 00:00:00 postgres: stats collector process
postgres 1819 1641 0 04:47 pts/0 00:00:00 psql
postgres 1820 1805 0 04:47 ? 00:00:00 postgres: postgres postgres 127.0.0.1(33254) idle
root 1952 1666 0 05:15 pts/1 00:00:00 grep postgres
这时候相关的postgres服务正常启动了,连接数据库
[postgres@cqs bin]$ psql
psql (9.5alpha2)
Type "help" for help.
postgres=#
postgres=#
成功连上数据库,又可以愉快地操作对应的数据库了。
相关文章推荐
- ADO 实例《创建一个临时数据库 创建一个临时数据表 GridView1绑定内容 以及Dataset_的使用》
- 还原Wss3.0内容数据库时遇到:"ComputerName\Microsoft##SSEE 上的 WSS_Content 包含用户定义的架构。数据库在能够使用之前必须为空。请删除所有表、存储过程以及其他对象,或使用其他数据库。 " 的提示,无法加载内容数据库
- 数据库安全性之使用命令来实现用户管理以及角色.十五
- 使用sed在一个文件中指定位置插入另外一个文件的内容-r命令的使用
- shell编程之条件测试表达,命令间的逻辑关系式和控制结构的使用以及算术运算
- logcat命令使用方法和查看android系统日志缓冲区内容的方法
- 地磅称量系统之(37~39) 直接向数据库的数据表WtBill添加测试数据以及绑定用户控件和使用编码的方式控制dataGridView控件的每列属性和添加数据数据库的表中不存在的字段(非绑定列)
- 移动一个网站集所使用的内容数据库
- 在cmd下运行mysql以及使用mysqldump命令导出数据库中的脚本
- 【dbfsize】使用dbfsize命令得到数据文件、控制文件及日志文件的Block Size
- vim 的复制粘贴命令,以及使用寄存器来存放要复制的内容
- 配置一个使用plproxy的PostgreSQL数据库集群
- CMD文件中用FOR命令读取文本文件内容到变量,以及和PsExec搭配使用的方法和例子
- log4net 如何跨域或者跨进程日志记录在同一个日志文件中以及数据库中
- 如何在Openstack的控制节点使用命令手动创建一个虚拟机
- 移动一个网站集所使用的内容数据库
- 弹出应用程序: 服务控制管理器 : 在系统启动时至少有一个服务或驱动程序产生错误。详细信息,请使用事件查看器查看事件日志
- Python:通过自定义系统级快捷键来控制程序开始或停止记录日志(使用小技巧解决一个貌似无解的问题)
- Python:通过自定义系统级快捷键来控制程序开始或停止记录日志(使用小技巧解决一个貌似无解的问题)
- Linux 视频设备驱动V4L2最常用的控制命令使用说明(1.02)以及我收藏的网址