如何修复Postgres,使其在突然关机后启动?

编程入门 行业动态 更新时间:2024-10-23 07:37:38
本文介绍了如何修复Postgres,使其在突然关机后启动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

由于突然断电,在本地计算机上运行的 PostGres 服务器突然关闭。重新启动后,我尝试重新启动postgres并得到以下错误:

Due to a sudden power outage, the PostGres server running on my local machine shut down abruptly. After rebooting, I tried to restart postgres and I get this error:

$ pg_ctl -D / usr / local / pgsql / data重新启动

$ 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 转储它,重新创建并重新导入。

You'd need to pg_resetxlog. Your database can be in an inconsistent state after this though, so dump it with pg_dumpall, recreate and import back.

原因可能是:

  • 您尚未关闭硬件在磁盘上的写缓存阻止操作系统在报告成功写入应用程序之前确保已写入数据。

  • You have not turned off hardware write cache on disk, which often prevents the OS from making sure data is written before it reports successful write to application. Check with

hdparm -I / dev / sda

如果在写入缓存之前显示 *,则可能是这种情况。 PostgreSQL的源具有程序src / tools / fsync / test_fsync.c,测试与磁盘同步数据的速度。运行它-如果它报告的所有时间都比磁盘对操作系统的等待时间短(例如3秒)-在7500rpm的磁盘上,对同一位置进行1000次写入的测试至少需要8秒才能完成(1000 /(7500rpm / 60s)),因为每个路由只能写入一次。如果您的数据库位于/ var / tmp分区以外的其他磁盘上,则需要编辑此test_fsync.c-更改

If it shows "*" before "Write cache" then this could be the case. Source of PostgreSQL has a program src/tools/fsync/test_fsync.c, which tests speed of syncing data with disk. Run it - if it reports all times shorter than, say, 3 seconds than your disk is lying to OS - on a 7500rpm disks a test of 1000 writes to the same place would need at least 8 seconds to complete (1000/(7500rpm/60s)) as it can only write once per route. You'd need to edit this test_fsync.c if your database is on another disk than /var/tmp partition - change

#define FSYNC_FILENAME /var/tmp/test_fsync.out

#define FSYNC_FILENAME /usr/local/pgsql/data/test_fsync.out

您的磁盘出现故障,并且有坏块,请检查坏块。

Your disk is failing and has a bad block, check with badblocks.

您的RAM不好,请检查 memtest86 + 至少8小时。

You have a bad RAM, check with memtest86+ for at least 8 hours.

更多推荐

如何修复Postgres,使其在突然关机后启动?

本文发布于:2023-10-16 16:20:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1498080.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:使其   Postgres

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!