I’m having a problem with PostgreSQL 9.5+173 on Ubuntu 16.04 and I happened to stumble across the following threads in my research that somewhat describes the behavior I’m seeing:
https://www.postgresql.org/message-id/562E4453.5090803%40aklaver.com
Long story short I have a fresh install of Ubuntu 16 with nothing on it and PostgreSQL running. I’ve stopped PostgreSQL changed the data directory and port and a couple other settings and it starts back up fine.
I can start and stop PostgreSQL manually via systemctl
without any problems. I can also connect to the database and can verify that it is running via a ps ax | grep postgres
.
However, after I reboot PostgreSQL will not start up. Any attempt to start it up via systemctl start postgresql.service
doesn’t do anything and does not fail. The only way I am able to get it started is if I call systemctl start postgresql@9.5-main.service
.
I did some investigation and looked at both the postgresql.service and postgresql@9.5-main.service scripts and realized that the postgresql.service script does nothing as stated in the thread above and that the postgresql@9.5-main.service has the PartOf directive which means it should be getting triggered from the postgresql.service as the sytemd docs state, but it isn’t for some reason. Basically I’m at a loss as to why everything works before I reboot and then doesn’t work after I reboot. Is there something I’m missing? I’m starting to go CRAZY over something so simple.
Update: I added an ExecStartPre=/bin/touch /tmp/postgresq.log
to the postgresql@9.5-main.service to see if it’s actually getting called on boot and it is not. Manually calling systemctl start postgresql@9.5-main.service
creates the file in the /tmp directory.
Update: I have also found that calling systemd daemon-reload
after reboot will allow me to start postgres via the systemctl start postgresql
command.
Advertisement
Answer
Turns out that the problem was the fact that I symlinked /etc/postgresql/9.5/main/
across partitions to a custom partition that wasn’t available right away, so when PostgreSQL tried to start on boot it couldn’t because it’s configuration files were not available. This describes what was happening since I could start PostgreSQL manually after I logged in.