I'm working on a remote VPS running Ubuntu 16.04 LTS. After a software update (apt upgrade
) in which postgresql-common
was updated, my PostgreSQL 9.5 server stopped listening on any port.
# All produce no results
sudo netstat -nltp | grep 5432
sudo netstat -nltp | grep postgres
sudo netstat | grep postgres
There are many things I tried to get this working but I've since purged the PostgreSQL 9.5 installation and reinstalled everything.
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
Here's truncated output from that successful re-installation:
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) ...
Note the key line above:
Failed to validate path /var/run/postgresql: Too many levels of symbolic links
While service postgresql status
confirms the server is running, the cluster is down immediately after installation:
$ 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
Attempting to start the cluster results in failure after several seconds:
$ sudo pg_ctlcluster 9.5 main start
Redirecting start request to systemctl
Job for postgresql@9.5-main.service failed because a timeout was exceeded. See "systemctl status postgresql@9.5-main.service" and "journalctl -xe" for details.
And journalctl
implicates that error message we saw earlier:
Apr 17 09:27:25 remoteserver systemd[1]: postgresql@9.5-main.service: 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]: postgresql@9.5-main.service: Start operation timed out. Terminating.
Apr 17 09:28:53 remoteserver systemd[1]: Failed to start PostgreSQL Cluster 9.5-main.
How do I resolve this PID file issue???