无法在CentOS 7上启动postgresql服务

bxgwgixi  于 2022-11-08  发布在  PostgreSQL
关注(0)|答案(3)|浏览(699)

无法在CentOS 7上启动postgresql-9.5。
我按照这个页面-https://wiki.postgresql.org/wiki/YUM_Installation-在CentOS上安装数据库服务器。
我在设置setenforce 0后尝试了同样的方法,这也没有帮助。
我以root的身份执行所有操作。

  1. systemctl start postgresql-9.5.service
  2. Job for postgresql-9.5.service failed because the control process exited with error
  3. code. See "systemctl status postgresql-9.5.service" and "journalctl -xe" for details.

这就是我的地位-

  1. Redirecting to /bin/systemctl status postgresql-9.5.service
  2. postgresql-9.5.service - PostgreSQL 9.5 database server
  3. Loaded: loaded (/usr/lib/systemd/system/postgresql-9.5.service; enabled; vendor preset: disabled)
  4. Active: failed (Result: exit-code) since Thu 2016-02-18 15:20:30 EST; 2min 28s ago
  5. Process: 15041 ExecStartPre=/usr/pgsql-9.5/bin/postgresql95-check-db-dir ${PGDATA} (code=exited, status=1/FAILURE)
  6. Feb 18 15:20:30 myserver systemd[1]: Starting PostgreSQL 9.5 database server...
  7. Feb 18 15:20:30 myserver systemd[1]: postgresql-9.5.service: control process exited, code=exited status=1
  8. Feb 18 15:20:30 myserver systemd[1]: Failed to start PostgreSQL 9.5 database server.
  9. Feb 18 15:20:30 myserver systemd[1]: Unit postgresql-9.5.service entered failed state.
  10. Feb 18 15:20:30 myserver systemd[1]: postgresql-9.5.service failed.

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

  1. [root@myserver /]# cat /etc/ld.so.conf.d/postgresql-pgdg-libs.conf
  2. /usr/pgsql-9.5/lib/
  3. [root@myserver /]# cat /usr/lib/tmpfiles.d/postgresql-9.5.conf
  4. d /var/run/postgresql 0755 postgres postgres -
  5. [root@myserver /]# cat /usr/pgsql-9.5/share/postgresql-9.5-libs.conf
  6. /usr/pgsql-9.5/lib/
  7. [root@myserver /]# cat /etc/alternatives/pgsql-ld-conf
  8. /usr/pgsql-9.5/lib/
  9. [root@myserver /]# cat /var/lib/alternatives/pgsql-ld-conf
  10. auto
  11. /etc/ld.so.conf.d/postgresql-pgdg-libs.conf
  12. /usr/pgsql-9.5/share/postgresql-9.5-libs.conf
  13. 950

我在谷歌上搜索了我看到的错误。许多人都看到了同样的错误,每种情况下的根本原因都不同。通读这些帖子,我不清楚我看到的是已经报告的任何原因。

cwdobuhd

cwdobuhd1#

请确保您已经正确安装了所有软件包,并在安装之前更新了yum存储库部分[base][updates],如guide中所述。我们有CentOS 7和PostgreSQL 9.5,它可以通过以下步骤完美地工作:

  1. vi /etc/yum.repos.d/CentOS-Base.repo
  2. yum localinstall http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
  3. yum list postgres*
  4. yum install -y postgresql95-server.x86_64 postgresql95-contrib.x86_64 postgresql95-libs.x86_64
  5. /usr/pgsql-9.5/bin/postgresql95-setup initdb
  6. systemctl enable postgresql-9.5.service
  7. systemctl start postgresql-9.5.service

最后,systemctl status postgresql-9.5.service应该会显示如下内容:

  1. postgresql-9.5.service - PostgreSQL 9.5 database server
  2. Loaded: loaded (/usr/lib/systemd/system/postgresql-9.5.service; enabled)
  3. Active: active (running) since Fri 2016-02-19 00:01:13 UTC; 6min ago
  4. Process: 10809 ExecStart=/usr/pgsql-9.5/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=0/SUCCESS)
  5. Process: 10802 ExecStartPre=/usr/pgsql-9.5/bin/postgresql95-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
  6. Main PID: 10811 (postgres)
  7. CGroup: /system.slice/postgresql-9.5.service
  8. ├─10811 /usr/pgsql-9.5/bin/postgres -D /var/lib/pgsql/9.5/data
  9. ├─10812 postgres: logger process
  10. ├─10814 postgres: checkpointer process
  11. ├─10815 postgres: writer process
  12. ├─10816 postgres: wal writer process
  13. ├─10817 postgres: autovacuum launcher process
  14. └─10818 postgres: stats collector process
展开查看全部
ngynwnxp

ngynwnxp2#

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

  1. sudo /usr/pgsql-11/bin/postgresql-11-setup initdb

然后启动Postgres服务,例如

  1. sudo systemctl start postgresql-11
o2gm4chl

o2gm4chl3#

这些步骤对我的测试服务器很有帮助。
通过SSH连接服务器。
然后切换用户:

  1. sudo su - postgres

检查Postgres状态:

  1. pg_ctl status

停止数据库:

  1. pg_ctl stop

检查是否不存在服务器进程:

  1. ps axf | grep postg

启动Postgres服务:

  1. sudo systemctl start postgresql.service

  1. sudo systemctl start postgresql

然后检查状态:

  1. systemctl status postgresql.service ИЛИ systemctl status postgresql
展开查看全部

相关问题