Could not read from file "pg_clog/0003" at offset 163840: Success

来源:互联网 发布:积分商城系统源码 编辑:程序博客网 时间:2024/05/22 18:55

最近做postgresql+drbd+heartbeat,在primary机突然断电后,slave机切换为primary正常,但数据库无法启动,错误如下:

frank@node1:~/cas/bin$ sudo /etc/init.d/postgresql start 
 * Starting PostgreSQL 9.3 database server
 * The PostgreSQL server failed to start. Please check the log output:
2017-11-29 17:12:01 CST LOG:  database system was interrupted; last known up at 2017-11-29 16:55:13 CST
2017-11-29 17:12:01 CST LOG:  database system was not properly shut down; automatic recovery in progress
2017-11-29 17:12:01 CST LOG:  record with zero length at 6/1C8E33B0
2017-11-29 17:12:01 CST LOG:  redo is not required
2017-11-29 17:12:01 CST FATAL:  could not access status of transaction 3805721
2017-11-29 17:12:01 CST DETAIL:  Could not read from file "pg_clog/0003" at offset 163840: Success.
2017-11-29 17:12:01 CST LOG:  startup process (PID 3452) exited with exit code 1
2017-11-29 17:12:01 CST LOG:  aborting startup due to startup process failure

经查询资料,参考网友对类似问题的回复(url: https://www.postgresql.org/message-id/29313.1222261821@sss.pgh.pa.us):

You need to make the files the right size (256K of zeroes).A suitable "dd" from /dev/zero will accomplish this on modernUnixen (ie, anything that has /dev/zero).Note that this is by no means a fix, it simply allows pg_dump tocomplete.  What you are really doing by filling those files withzeroes is saying "assume all these old transactions aborted".You *will* have data loss.  It will only affect rows that haven'tbeen accessed in a very long time (since at least June, looks like)but gone is gone.Another possibility that might be better is to fill the files with0x55, though this is harder since /dev/zero won't help.  That wouldforce all the old transactions to be considered committed rather thanaborted.  This isn't really better from a consistency standpoint, butif you feel that most of your data-altering commands succeed thenthis might give you a closer approximation to the state you want.The whole thing is pretty troubling because 8.2.x is supposed tocontain defenses against this type of problem.  Could we seethe contents of "select datname, datfrozenxid from pg_database"?Also, have you tried dumping individual databases instead ofpg_dumpall?  (It would be good to experiment with that beforeyou start making bogus pg_clog files; once you do that there'sno going back in terms of recovering the true state of your data.)
执行如下命令后问题解决(虽然可能丢失部分数据,但对我来说可以接受):

sudo dd if=/dev/zero of=/rep/postgresql/data/pg_clog/0003 bs=1k count=256

阅读全文
0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 引流管伤口洞红怎么办 甘蔗卡在喉咙里怎么办 棉花被子生虫了怎么办 绗缝羽绒服钻毛怎么办 宝珠笔没墨水了怎么办 衣服上画的笔印怎么办 黑笔芯弄衣服上怎么办 圆珠笔油在皮上怎么办 不小心吞了水银怎么办 小孩吃了洗发露怎么办? 脸上被铅笔戳了怎么办 小孩吃了铅笔芯怎么办 小孩把橡皮吃了怎么办 用棉签掏耳朵里面疼怎么办 棉签头掉耳朵里怎么办 黑裤子老是粘毛怎么办 新买的裤子掉色怎么办 黑裤子容易粘毛怎么办 裤子粘了全部毛怎么办 纯棉裤子粘毛了怎么办 裤子粘毛怎么办怎么洗 黑裤子洗白了怎么办 新买床单有味道怎么办 新买的床单扎人怎么办 刚买的衣服皱了怎么办 橘子沾到衣服上怎么办 橘子水掉衣服上怎么办 菜汁滴在衣服上怎么办 饺子面和硬了怎么办 化纤衣服烫亮了怎么办 衣服穿久了发亮怎么办 买的毛衣长了怎么办 买的毛衣袖子长怎么办 新买的毛衣扎人怎么办 玻璃光纤线断了怎么办 家里光纤线断了怎么办 光纤线断了怎么办 找谁 光纤入户线断了怎么办 哈衣连体衣小了怎么办 毛巾用久了发硬怎么办 毛巾用久了发粘怎么办