I want to start postmaster using /some/dir/postgresql.conf and have the data /in/another/directory.
I have tried:
Setting "Environment=PGOPTS='--config_file="/some/dir/postgresql.conf" in override.conf
Setting "Environment=PGOPTS='--config_file="/some/dir/postgresql.conf" in postgresql.service
Changing "ExecStart" in postgresql.service to start with -o "-c config_file='/some/dir/postgresql.conf'" (obsolete)
Setting -D /some/dir works and it uses postgresql.conf from correct path, but it does not respect data_directory and still uses the directory specified in -D.
postgres=# SELECT name, setting FROM pg_settings WHERE setting LIKE '/%';
name | setting
-------------------------+------------------------------------
config_file | /some/dir/postgresql.conf
data_directory | /some/dir
I have not been able to start postmaster in any way that shows different dir's for config_file and data_directory.
What's the correct way to start postmaster with configuration in one directory and make it read data_directory for where to locate the DBs?
Thanks!
The -D
option is (counter-intuitively) not the data directory, but the directory that contains postgresql.conf
. As the documentation says:
-D datadir
Specifies the file system location of the database configuration files.
Then you specify the data directory in postgresql.conf
by setting the data_directory
parameter.