使用以下方式安装 PostgreSQL:
sudo yum install postgresql-server postgresql-contrib
PostgreSQL 版本:9.2.18
启动服务时:
sudo service postgresql start
得到错误:
Redirecting to /bin/systemctl start postgresql.service
Job for postgresql.service failed because the control process exited with error code. See "systemctl status postgresql.service" and "journalctl -xe" for details.
journalctl -xe
细节:
-- Unit postgresql.service has failed.
--
-- The result is failed.
7月 19 04:17:04 node2 systemd[1]: Unit postgresql.service entered failed state.
7月 19 04:17:04 node2 systemd[1]: postgresql.service failed.
7月 19 04:17:04 node2 polkitd[19772]: Unregistered Authentication Agent for unix-process:27133:53830492 (system bus name :1.405, object path /org/freedesktop/PolicyKit1/AuthenticationA
7月 19 04:19:33 node2 polkitd[19772]: Registered Authentication Agent for unix-process:27165:53845472 (system bus name :1.406 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object pat
7月 19 04:19:33 node2 systemd[1]: Starting PostgreSQL database server...
-- Subject: Unit postgresql.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit postgresql.service has begun starting up.
7月 19 04:19:34 node2 pg_ctl[27187]: pg_ctl: could not start server
7月 19 04:19:34 node2 pg_ctl[27187]: Examine the log output.
7月 19 04:19:34 node2 systemd[1]: postgresql.service: control process exited, code=exited status=1
7月 19 04:19:34 node2 systemd[1]: Failed to start PostgreSQL database server.
-- Subject: Unit postgresql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit postgresql.service has failed.
--
-- The result is failed.
7月 19 04:19:34 node2 systemd[1]: Unit postgresql.service entered failed state.
7月 19 04:19:34 node2 systemd[1]: postgresql.service failed.
7月 19 04:19:34 node2 polkitd[19772]: Unregistered Authentication Agent for unix-process:27165:53845472 (system bus name :1.406, object path /org/freedesktop/PolicyKit1/AuthenticationA
lines 2850-2910/2910 (END)
运行systemctl status PostgreSQL.service
,得到以下信息:
● postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2017-07-19 04:30:26 EDT; 42min ago
Process: 27285 ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -o -p ${PGPORT} -w -t 300 (code=exited, status=1/FAILURE)
Process: 27280 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 26640 (code=exited, status=0/SUCCESS)
在能够连接到 PostgreSQL 数据库之前,您有 3 个步骤:
您已经安装了 PostgreSQL,现在需要创建集群。该
initdb
工具是您所需要的。您将在此处找到文档。
这可能会令人困惑,因为当您使用基于 debian 的发行版时,
apt
perl 包装器会为您完成所有步骤。在我的情况下,它
shared_buffers
太大了,导致失败状态,我将它减少到 128MB 并重新启动然后工作正常,我的情况是我在操作系统崩溃到新操作系统后复制了数据目录。对我来说同样的行为。就我而言,PGDATA 的权限错误。它仅详细记录在 /var/log/messages 中。chmod 700 data 帮助启动并运行备用节点。