PostgreSQL 9.2 服务不断失败



我有一个运行PGSQL的CentOS 7最小虚拟机来做一些测试,但不知何故,过了一段时间,PGSQL服务似乎失败或损坏,我完全无法重新启动它。我基本上正在使用 WAL 文件实现时间点恢复,我已经成功了。我不得不重建安装和数据库三次以上,这似乎总是发生在我设法让 WAL 存档在新版本中再次工作之后。我没有对postgresql.confpg_hba.conf文件进行疯狂的更改,而且数据库也没有那么大(40 个表中的数据不到 2GB(,所以我无法想象我是如何不断损坏数据目录或服务的。我希望有一些关于如何解决或击败此错误的想法。这是我运行systemctl status postgresql-9.2时的输出:

Job for postgresql-9.2.service failed because the control process exited with error code. See "systemctl status postgresql-9.2.service" and "journalctl -xe" for details.
[root@localhost bin]# systemctl status postgresql-9.2
● postgresql-9.2.service - PostgreSQL 9.2 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-9.2.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2020-01-15 13:09:35 EST; 3min 34s ago
Process: 14407 ExecStart=/usr/pgsql-9.2/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=1/FAILURE)
Process: 14578 ExecStartPre=/usr/pgsql-9.2/bin/postgresql92-check-db-dir ${PGDATA} (code=exited, status=1/FAILURE)
Main PID: 10787 (code=exited, status=0/SUCCESS)
Jan 15 13:09:35 localhost.localdomain systemd[1]: Starting PostgreSQL 9.2 database s....
Jan 15 13:09:35 localhost.localdomain systemd[1]: postgresql-9.2.service: control pr...1
Jan 15 13:09:35 localhost.localdomain systemd[1]: Failed to start PostgreSQL 9.2 dat....
Jan 15 13:09:35 localhost.localdomain systemd[1]: Unit postgresql-9.2.service entere....
Jan 15 13:09:35 localhost.localdomain systemd[1]: postgresql-9.2.service failed.

以下是journalctl -xe命令显示的内容:

-- Unit postgresql-9.2.service has begun starting up.
Jan 15 13:09:35 localhost.localdomain postgresql92-check-db-dir[14578]: "/var/lib/pgsql/9.2/data/" is missing or empty.
Jan 15 13:09:35 localhost.localdomain postgresql92-check-db-dir[14578]: Use "/usr/pgsql-9.2/bin/postgresql92-setup initdb" to initialize the database cluster.
Jan 15 13:09:35 localhost.localdomain postgresql92-check-db-dir[14578]: See /usr/share/doc/postgresql92-9.2.24/README.rpm-dist for more information.
Jan 15 13:09:35 localhost.localdomain polkitd[715]: Unregistered Authentication Agent for unix-process:14572:4358382 (system bus name :1.215, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
Jan 15 13:09:35 localhost.localdomain systemd[1]: postgresql-9.2.service: control process exited, code=exited status=1
Jan 15 13:09:35 localhost.localdomain systemd[1]: Failed to start PostgreSQL 9.2 database server.
-- Subject: Unit postgresql-9.2.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit postgresql-9.2.service has failed.
--
-- The result is failed.
Jan 15 13:09:35 localhost.localdomain systemd[1]: Unit postgresql-9.2.service entered failed state.
Jan 15 13:09:35 localhost.localdomain systemd[1]: postgresql-9.2.service failed.
Jan 15 13:16:01 localhost.localdomain anacron[14339]: Job `cron.daily' started
Jan 15 13:16:01 localhost.localdomain run-parts(/etc/cron.daily)[14590]: starting logrotate
Jan 15 13:16:01 localhost.localdomain run-parts(/etc/cron.daily)[14595]: finished logrotate
Jan 15 13:16:01 localhost.localdomain run-parts(/etc/cron.daily)[14597]: starting man-db.cron
Jan 15 13:16:04 localhost.localdomain run-parts(/etc/cron.daily)[17612]: finished man-db.cron
Jan 15 13:16:04 localhost.localdomain anacron[14339]: Job `cron.daily' terminated
Jan 15 13:16:04 localhost.localdomain anacron[14339]: Normal exit (1 job run)

我找不到任何特定于 PGSQL 的日志(/var/log/中没有任何与 PGSQL 相关的日志,数据目录中也没有(,因此故障排除变得非常困难。感谢您的帮助!

故障排除提示:

  • 找到PostgreSQL日志(可能在/var/lib/pgsql/9.2/data(的某个地方并读取它。

  • 尝试以用户postgres的身份手动启动PostgreSQL

    postgres -D /path/to/the/data/directory
    

    看看你得到了什么。

  • 使用古代 9.2 以外的 PostgreSQL 版本。

最新更新