无法启动PostgreSQL [英] Not able to start PostgreSQL
问题描述
有一台正在运行的CentOS7 Linux机器(不是由我管理的;对其拥有有限的权利).
Have a CentOS7 Linux machine running (not managed by me; have limited rights to/in it).
有一个请求在其中设置PostgreSQL.
Have a request to set PostgreSQL up in it.
只需从CentOS存储库中安装PostgreSQL:
Just installed PostgreSQL from the CentOS repository:
sudo yum install postgresql-server postgresql-contrib
一切都很好.
然后初始化数据库:
sudo yum install postgresql-server postgresql-contrib
一切都很好.
但随后开始:
sudo systemctl start postgresql
失败:
Job for postgresql.service failed because the control process exited with error code. See "systemctl status postgresql.service" and "journalctl -xe" for details.
我无权访问systemd-journal,因此"journalctl -xe"没有任何作用,但随后:
I do not have access to systemd-journal so nothing tod with "journalctl -xe", but then the:
systemctl status postgresql.service
返回:
● postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2020-04-24 16:41:04 EEST; 33s ago
Process: 30690 ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -o -p ${PGPORT} -w -t 300 (code=exited, status=1/FAILURE)
Process: 30684 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
postgres --version
postgres (PostgreSQL) 9.2.24
任何想法在这里可能出什么问题吗?热门继续吗?
Any ideas what could be wrong here? Hot to continue with that?
推荐答案
如 echo $ PGDATA
所示,您也具有PG9.3.这意味着9.2服务将无法启动,因为postgres 9.3可能已经占用了端口5432请执行以下
As the echo $PGDATA
shows you have PG9.3 as well. Which means that 9.2 service will not start because the port 5432 might be already occupied by postgres 9.3
Do the following
ps- ef | grep postgres
并获取postgres进程ID并杀死所有postgres进程.
And get the postgres process id and kill all postgres processes.
使用
rm -rf /var/lib/pgsql/9.3
转到/usr/pgsql-9.2/bin
并使用以下命令运行initdb
Go to /usr/pgsql-9.2/bin
and run the initdb using below command
./postgresql92-setup initdb
之后,使用以下命令启动postgresql-9.2服务
After that start the postgresql-9.2 service using
systemctl start postgresql-9.2.service
这篇关于无法启动PostgreSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!