简体   繁体   English

PostgreSQL 服务器无法启动

[英]PostgreSQL server can not start

I have rebooted Ubuntu server where I have PostgreSQL database with version 12.我已经重新启动了 Ubuntu 服务器,其中我有版本 12 的 PostgreSQL 数据库。
I started the database server by typing the following command我通过键入以下命令启动了数据库服务器

sudo service postgresql start

and when I check the status by当我检查状态时

sudo service postgresql status

It shows the database server is active like this,它显示数据库服务器像这样处于活动状态,

  Active: active (exited) since Thu 2020-07-16 12:28:41 UTC; 14min ago
  Process: 5875 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
  Main PID: 5875 (code=exited, status=0/SUCCESS)

However, I keep getting this error and I can not find this PID when I do netstat or htop.但是,我不断收到此错误,并且在执行 netstat 或 htop 时找不到此 PID。

Connection to IP_ADDRESS:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

I saw similar questions and they solved by setting the listening address to localhost or 0.0.0.0 and port number to 5432 which I did but I still have this error not being able to connect to the database.我看到了类似的问题,他们通过将侦听地址设置为 localhost 或 0.0.0.0 并将端口号设置为 5432 来解决,我这样做了,但我仍然遇到无法连接到数据库的错误。

I also get this error when I executed pg_lsclusters当我执行 pg_lsclusters 时,我也收到此错误

11  main    5433 down   postgres /var/lib/postgresql/11/main /var/log/postgresql/postgresql-11-main.log
12  main    5432 down   postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log

Could someone help me to figure out why it is happening?有人可以帮我弄清楚为什么会这样吗?

Thank you very much.非常感谢。

Maybe it is only listening on localhost?也许它只在本地主机上收听? Try netstat -an | grep -i "listen "试试netstat -an | grep -i "listen " netstat -an | grep -i "listen " to see what ports are actively being listened to on your system. netstat -an | grep -i "listen "查看系统上正在监听哪些端口。 Maybe the IP address changed after you rebooted?也许 IP 地址在您重新启动后发生了变化?

Check the postgresql logs, are there any messages there?查看 postgresql 日志,那里有消息吗?

sudo su - postgres and try connecting with psql . sudo su - postgres并尝试使用psql连接。

ps -fu postgres to see what processes are running as the postgresql user. ps -fu postgres查看以 postgresql 用户身份运行的进程。

I managed to first by enabling Postgres service from systemctl by我首先通过 systemctl 启用 Postgres 服务

systemctl enable postgresql.service

Then, I started a specific version of the PostgreSQL database server by然后,我启动了一个特定版本的 PostgreSQL 数据库服务器

pg_ctlcluster 11 main start

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM