Specifying an Alternative PostgreSQL Data Directory on RHEL
The default data directory for PostgreSQL 11.8 is /var/lib/pgsql/11/data. If you do not need to change the directory, skip this topic.
![]() |
Important The steps below use the example alternative directory in the following steps is
/external-vol/pgdata-11.8.
|
- Complete one of the following based on the version of Red Hat Enterprise Linux(RHEL).
- RHEL 6:
- Create and edit /etc/sysconfig/pgsql/postgresql-11.
- Add the following line then save and close the file:
PGDATA=/external-vol/pgdata-11.8
- RHEL 7:
- Create and edit /etc/systemd/system/postgresql-11.service.
- Add the following content:
.include /lib/systemd/system/postgresql-11.service [Service] Environment=PGDATA=/external-vol/pgdata-11.8
- Reload the Systemd configuration:
systemctl daemon-reload
- RHEL 6:
- Set the PGDATA environment variable to point to the custom data directory. This is necessary for the Xpress Insight Server installer to find the custom data directory: export PGDATA="/external-vol/pgdata-11.8"