由于突然断电,在我的本地机器上运行的PostGres服务器突然关闭.重新启动后,我尝试重新启动postgres,我收到此错误:
$pg_ctl -D /usr/local / pgsql / data restart
pg_ctl: PID file "/usr/local/pgsql/data/postmaster.pid" does not exist Is server running? starting server anyway server starting $:/usr/local/pgsql/data$LOG: database system shutdown was interrupted at 2009-02-28 21:06:16 LOG: checkpoint record is at 2/8FD6F8D0 LOG: redo record is at 2/8FD6F8D0; undo record is at 0/0; shutdown FALSE LOG: next transaction ID: 0/1888104; next OID: 1711752 LOG: next MultiXactId: 2; next MultiXactOffset: 3 LOG: database system was not properly shut down; automatic recovery in progress LOG: redo starts at 2/8FD6F918 LOG: record with zero length at 2/8FFD94A8 LOG: redo done at 2/8FFD9480 LOG: could not fsync segment 0 of relation 1663/1707047/1707304: No such file or directory FATAL: storage sync Failed on magnetic disk: No such file or directory LOG: startup process (PID 5465) exited with exit code 1 LOG: aborting startup due to startup process failure
数据目录中没有postmaster.pid文件.什么可能是这种行为的原因,当然还有出路?
您需要
pg_resetxlog.虽然此后您的数据库可能处于不一致状态,因此请使用pg_dumpall转储它,重新创建并导回.
原因可能是:
>您还没有关闭硬件
经常在磁盘上写缓存
防止操作系统在报告成功写入应用程序之前确保写入数据.检查
hdparm -I / dev / sda
如果它在“写入缓存”之前显示“*”,则可能是这种情况. Source of PostgreSQL有一个程序src / tools / fsync / test_fsync.c,它测试与磁盘同步数据的速度.运行它 – 如果它报告的所有时间都比磁盘所在的时间短3秒 – 在7500rpm的磁盘上,1000次写入相同位置的测试需要至少8秒才能完成(1000 /(7500rpm /) 60s))因为每条路线只能写一次.如果您的数据库位于/ var / tmp分区之外的另一个磁盘上,则需要编辑此test_fsync.c – 更改
#define FSYNC_FILENAME“/var/tmp/test_fsync.out”
至
#define FSYNC_FILENAME“/usr/local/pgsql/data/test_fsync.out”
>您的磁盘出现故障并且存在坏块,请查看badblocks.
>你的内存不好,请在memtest86+查询至少8小时.