After rebooting Red Hat Satellite server, PostgreSQL service won't start.​​ ​

环境

  • Red Hat Satellite 6.4

问题

  • After rebooting Red Hat Satellite server, PostgreSQL service won't start.
  • Having /var/lib/pgsql on a NFS filesystem.
  • Executing katello-service restart, the services start correctly

决议

  • Append the parameter ​​remote-fs.target​​ next to existing line ​​After=network.target​​ in the file ​​/usr/lib/systemd/system/postgresql.service​​ as below:

​Raw​

After=network.target remote-fs.target     <<< Append this

根源

  • After the machine reboot, postgreSQL services was starting before NFS mounted ​​/var/lib/pgsql​​ directory. Adding the dependency ​​remote-fs.target​​ to systemd services' files postpones postgres services to wait for NFS mount to be loaded.

诊断步骤

  • /var/log/message shows below error:

​Raw​

Nov 30 10:43:29 satellite systemd: Starting Logout off all iSCSI sessions on shutdown...
Nov 30 10:43:29 satellite postgresql-check-db-dir: "/var/lib/pgsql/data" is missing or empty.
Nov 30 10:43:29 satellite postgresql-check-db-dir: Use "postgresql-setup initdb" to initialize the database cluster.