I am trying to get postgresql-9.5 to start on boot on CentOS 7.
I've followed the installation and startup steps here https://wiki.postgresql.org/wiki/YUM_Installation And have tried some additional troubleshooting from this question here https://stackoverflow.com/questions/35492893/unable-to-start-postgresql-9-5-on-centos-7
It might be relevant that I am using a custom PGDATA directory that is a mount point. (/mnt/data
)
The database was initialized pointing to the /mnt/data
directory.
su postgres -c "/usr/pgsql-9.5/bin/pg_ctl initdb -D /mnt/data"
I made the necessary changes to the /usr/lib/systemd/system/postgresql-9.5.service
file to point to the /mnt/data
directory.
The service was enabled and started successfully.
systemctl enable postgresql-9.5
systemctl start postgresql-9.5
After rebooting, systemctl status postgresql-9.5
shows the following:
● postgresql-9.5.service - PostgreSQL 9.5 database server Loaded: loaded (/usr/lib/systemd/system/postgresql-9.5.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Wed 2016-04-06 00:53:02 EDT; 4min 36s ago Process: 9911 ExecStartPre=/usr/pgsql-9.5/bin/postgresql95-check-db-dir ${PGDATA} (code=exited, status=1/FAILURE) Apr 06 00:53:02 pgdev-fl1 systemd[1]: Starting PostgreSQL 9.5 database server... Apr 06 00:53:02 pgdev-fl1 systemd[1]: postgresql-9.5.service: control process exited, code=exited status=1 Apr 06 00:53:02 pgdev-fl1 systemd[1]: Failed to start PostgreSQL 9.5 database server. Apr 06 00:53:02 pgdev-fl1 systemd[1]: Unit postgresql-9.5.service entered failed state. Apr 06 00:53:02 pgdev-fl1 systemd[1]: postgresql-9.5.service failed.
However, I can immediately run systemctl start postgresql-9.5
and it loads just fine, using the /mnt/data
directory.
Thinking it might be an issue of timing and it trying to start the service before the mount point exists, I included Requires=mnt-data.mount
in the [Unit]
section of /usr/lib/systemd/system/postgresql-9.5.service
, and re-enabled the service after a systemctl daemon-reload
.
Yet still it errors out with the same message upon boot.
Running /usr/pgsql-9.5/bin/postgresql95-check-db-dir ${PGDATA}
generates no output for me so I am at a loss as to where to continue troubleshooting this issue.
Any guidance is appreciated!
Update - 4/6/16
After checking journalctl
it's apparent that it is trying to load the postgresql-9.5 service before the iSCSI volume is mounted, even though the Requires
directive was included.