I am trying to bring up a postgres server where the configuration files and the data are in separate places/partitions
postgresql-10 has been installed using the official repository using YUM in Centos 7
And it has been initialised using
/usr/pgsql-10/bin/pg_ctl initdb --pgdata=/var/lib/pgsql/10/data
as user app
What is referenced as PGDATA (configuration) directory is the default one:
# ls -salt /var/lib/pgsql/10/data
total 120
4 drwxrwxr-x. 19 app app 4096 Nov 10 17:29 .
I would like to use the following directory for data storage:
# ls -salt /usr/ip-spotlight/postgresql/
total 12
4 drwxrwxr-x. 3 postgres postgres 4096 Nov 10 17:43 .
4 drwx------. 2 postgres postgres 4096 Nov 10 17:43 data
And it complains about:
2017-11-10 17:51:44.495 CET [81743] FATAL: "/usr/ip-spotlight/postgresql/data" is not a valid data directory
2017-11-10 17:51:44.495 CET [81743] DETAIL: File "/usr/ip-spotlight/postgresql/data/PG_VERSION" is missing.
On the other hand, in https://www.postgresql.org/docs/current/static/runtime-config-file-locations.html it says:
If you wish, you can specify the configuration file names and
locations individually using the parameters config_file, hba_file
and/or ident_file. config_file can only be specified on the postgres
command line, but the others can be set within the main configuration
file.
My /var/lib/pgsql/10/data/postgresql.conf
is configured as:
data_directory = '/usr/ip-spotlight/postgresql/data'
hba_file = '/var/lib/pgsql/10/data/pg_hba.conf'
ident_file = '/var/lib/pgsql/10/data/pg_ident.conf'
Could you please advise how to separate the config files of postgresql and the actual data storage ?
Best Answer
OK, i figured it out:
initialise the db as user
postgres
override
PGDATA
env variable through systemd