无法在CentOS 7上启动postgresql服务

Mut*_*amy 25 postgresql centos rhel centos7 rhel7

无法在CentOS 7上启动postgresql-9.5.

我按照这个页面 - https://wiki.postgresql.org/wiki/YUM_Installation - 在CentOS上安装数据库服务器.

设置后我尝试了同样的方法setenforce 0,但这也没有帮助.

我正在做所有的操作root.

systemctl start postgresql-9.5.service
Job for postgresql-9.5.service failed because the control process exited with error 
code. See "systemctl status postgresql-9.5.service" and "journalctl -xe" for details.
Run Code Online (Sandbox Code Playgroud)

以下是我获得的状态 -

Redirecting to /bin/systemctl status  postgresql-9.5.service
? postgresql-9.5.service - PostgreSQL 9.5 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-9.5.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2016-02-18 15:20:30 EST; 2min 28s ago
  Process: 15041 ExecStartPre=/usr/pgsql-9.5/bin/postgresql95-check-db-dir ${PGDATA} (code=exited, status=1/FAILURE)

Feb 18 15:20:30 myserver systemd[1]: Starting PostgreSQL 9.5 database server...
Feb 18 15:20:30 myserver systemd[1]: postgresql-9.5.service: control process exited, code=exited status=1
Feb 18 15:20:30 myserver systemd[1]: Failed to start PostgreSQL 9.5 database server.
Feb 18 15:20:30 myserver systemd[1]: Unit postgresql-9.5.service entered failed state.
Feb 18 15:20:30 myserver systemd[1]: postgresql-9.5.service failed.
Run Code Online (Sandbox Code Playgroud)

并且不同conf文件的内容如下 -

[root@myserver /]# cat /etc/ld.so.conf.d/postgresql-pgdg-libs.conf
/usr/pgsql-9.5/lib/

[root@myserver /]# cat /usr/lib/tmpfiles.d/postgresql-9.5.conf
d /var/run/postgresql 0755 postgres postgres -

[root@myserver /]# cat /usr/pgsql-9.5/share/postgresql-9.5-libs.conf
/usr/pgsql-9.5/lib/

[root@myserver /]# cat /etc/alternatives/pgsql-ld-conf
/usr/pgsql-9.5/lib/

[root@myserver /]# cat /var/lib/alternatives/pgsql-ld-conf
auto
/etc/ld.so.conf.d/postgresql-pgdg-libs.conf

/usr/pgsql-9.5/share/postgresql-9.5-libs.conf
950
Run Code Online (Sandbox Code Playgroud)

用Google搜索我看到的错误.许多人都看到了相同的错误,并且根本原因在每种情况下都不同.阅读这些帖子,我不清楚我是否看到任何已经报道的原因.

Dmi*_*kov 46

确保已正确安装所有软件包并更新yum存储库部分,[base][updates]在安装之前按照指南中的说明进行安装.我们有CentOS 7和PostgreSQL 9.5,它可以完美地完成以下步骤:

# vi /etc/yum.repos.d/CentOS-Base.repo
# yum localinstall http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
# yum list postgres*
# yum install -y postgresql95-server.x86_64 postgresql95-contrib.x86_64 postgresql95-libs.x86_64 
# /usr/pgsql-9.5/bin/postgresql95-setup initdb
# systemctl enable postgresql-9.5.service
# systemctl start postgresql-9.5.service 
Run Code Online (Sandbox Code Playgroud)

最后,systemctl status postgresql-9.5.service应该告诉你这样的事情:

postgresql-9.5.service - PostgreSQL 9.5 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-9.5.service; enabled)
   Active: active (running) since Fri 2016-02-19 00:01:13 UTC; 6min ago
  Process: 10809 ExecStart=/usr/pgsql-9.5/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=0/SUCCESS)
  Process: 10802 ExecStartPre=/usr/pgsql-9.5/bin/postgresql95-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 10811 (postgres)
   CGroup: /system.slice/postgresql-9.5.service
           ??10811 /usr/pgsql-9.5/bin/postgres -D /var/lib/pgsql/9.5/data
           ??10812 postgres: logger process   
           ??10814 postgres: checkpointer process   
           ??10815 postgres: writer process   
           ??10816 postgres: wal writer process   
           ??10817 postgres: autovacuum launcher process   
           ??10818 postgres: stats collector process 
Run Code Online (Sandbox Code Playgroud)

  • 神奇的界限就是这个 - "#us/pgsql-9.5/bin/postgresql95-setup initdb`.谢谢 :).如果`service <name> initdb`不起作用,指南会提到上面的行作为替代.但是,如果输出确实有效,则没有指导输出的内容.在我的例子中,我使用`service <name> initdb`它只是让我回到命令提示符.我最终发现,它没有用. (14认同)

isa*_*pir 6

最常见的问题是数据库集群未初始化。您可以通过使用以下initdb命令运行postgresql-XX-setup脚本轻松地对其进行初始化,例如

sudo /usr/pgsql-11/bin/postgresql-11-setup initdb
Run Code Online (Sandbox Code Playgroud)

然后启动Postgres服务,例如

sudo systemctl start postgresql-11
Run Code Online (Sandbox Code Playgroud)