The following bug has been logged on the website:
Bug reference: 17469
Logged by: Joe Hebert
Email address: jhebert@micron.com
PostgreSQL version: 11.11
Operating system: RHEL 8.5
Description:
The following command was used to initialize the database (separate issue
with postgresql-11-setup not working):
/usr/pgsql-11/bin/initdb -A password -E utf8 -D /postgres/data/datafiles -X
/postgres/tranlog
Initialization completed successfully.
Then ran: sudo systemctl enable postgresql-11
Result: Created symlink
/etc/systemd/system/multi-user.target.wants/postgresql-11.service â
/usr/lib/systemd/system/postgresql-11.service.
Then ran: sudo systemctl start postgresql-11
Result:
Job for postgresql-11.service failed because the control process exited with
error code.
See "systemctl status postgresql-11.service" and "journalctl -xe" for
details.
sudo systemctl status postgresql-11
â postgresql-11.service - PostgreSQL 11 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-11.service; enabled;
vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2022-04-27 16:19:40 MDT; 28s
ago
Docs: https://www.postgresql.org/docs/11/static/
Process: 147756 ExecStartPre=/usr/pgsql-11/bin/postgresql-11-check-db-dir
${PGDATA} (code=exited, status=1/FAILURE)
Apr 27 16:19:40 systemd[1]: Starting PostgreSQL 11 database server...
Apr 27 16:19:40 systemd[1]: postgresql-11.service: Control process exited,
code=exited status=1
Apr 27 16:19:40 systemd[1]: postgresql-11.service: Failed with result
'exit-code'.
Apr 27 16:19:40 systemd[1]: Failed to start PostgreSQL 11 database
server.
After researching further, I reviewed file
/usr/lib/systemd/system/postgresql-11.service
and found the following offending line:
Environment=PGDATA=/var/lib/pgsql/11/data/
Which should have been set to /postgres/data/datafiles based in the option
provided to the initdb command.
Work-around: sudo systemctl edit --full postgresql-11
replaced the content, fixing the incorrect path
Result: PostgreSQL instance started successfully
If this is not considered a bug, please consider addressing this as an
enhancement. As a side note, I tried the "sudo systemctl edit" command
without the --full option to only override the one line, however, the issue
still persisted and required a wholesale replacement of the
postgresql-11.service file.