PostgreSQL 9.5 未监听;集群已关闭;“符号链接级别过多”

PostgreSQL 9.5 未监听;集群已关闭;“符号链接级别过多”

我正在运行 Ubuntu 16.04 LTS 的远程 VPS 上工作。在更新了软件更新 ( apt upgrade)后postgresql-common,我的 PostgreSQL 9.5 服务器停止监听任何端口。

# All produce no results
sudo netstat -nltp | grep 5432
sudo netstat -nltp | grep postgres
sudo netstat | grep postgres

我尝试了很多方法来实现这一点,但后来清除 PostgreSQL 9.5 安装并重新安装所有内容。

sudo apt purge postgresql-9.5 postgresql-client-9.5 postgresql-client-common postgresql-common postgresql-contrib
sudo apt install postgresql-9.5 postgresql-client-9.5 postgresql-client-common postgresql-common postgresql-contrib

以下是部分输出成功的重新安装:

Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
Failed to validate path /var/run/postgresql: Too many levels of symbolic links
Setting up postgresql-9.5 (9.5.21-0ubuntu0.16.04.1) ...
Creating new cluster 9.5/main ...
  config /etc/postgresql/9.5/main
  data   /var/lib/postgresql/9.5/main
  locale en_US.UTF-8
  socket /var/run/postgresql
  port   5432
update-alternatives: using /usr/share/postgresql/9.5/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
Setting up postgresql-contrib-9.5 (9.5.21-0ubuntu0.16.04.1) ...
Setting up postgresql-contrib (9.5+173ubuntu0.3) ...
Processing triggers for systemd (229-4ubuntu21.27) ...

请注意上面的关键一行:

Failed to validate path /var/run/postgresql: Too many levels of symbolic links

虽然service postgresql status确认服务器正在运行,但安装后集群立即关闭:

$ pg_lsclusters 
Ver Cluster Port Status Owner    Data directory               Log file
9.5 main    5432 down   postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log

尝试启动集群几秒钟后失败:

$ sudo pg_ctlcluster 9.5 main start
Redirecting start request to systemctl
Job for [email protected] failed because a timeout was exceeded. See "systemctl status [email protected]" and "journalctl -xe" for details.

journalctl暗示我们之前看到的错误消息:

Apr 17 09:27:25 remoteserver systemd[1]: [email protected]: Can't open PID file /var/run/postgresql/9.5-main.pid (yet?) after start: Too many levels of symbolic links
Apr 17 09:27:28 remoteserver sm-mta[2726]: ruleset=check_relay, arg1=[45.142.195.2], arg2=45.142.195.2, relay=[45.142.195.2], reject=421 4.3.2 Connection rat
Apr 17 09:28:18 remoteserver sm-mta[2727]: ruleset=check_relay, arg1=[45.142.195.2], arg2=45.142.195.2, relay=[45.142.195.2], reject=421 4.3.2 Connection rat
Apr 17 09:28:53 remoteserver systemd[1]: [email protected]: Start operation timed out. Terminating.
Apr 17 09:28:53 remoteserver systemd[1]: Failed to start PostgreSQL Cluster 9.5-main.

我该如何解决这个 PID 文件问题?

相关内容