1

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!

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.