3

I have used these steps to setup database replication on Postgresql 9.4.

But, when using pg_basebackup, my entire database dir is copied, including the postgresql.conf file. However, that file is different for master and slave, so changes will be overwritten after starting the replication.

How can I run PostgreSQL with a custom data dir, but with the postgresql.conf outside of that dir?

I am using CentOS7.

Bart Friederichs
  • 353
  • 1
  • 6
  • 23

2 Answers2

3

Use a --write-recovery-conf to set up a standby server.

   --write-recovery-conf
       Write a minimal recovery.conf in the output directory (or into the
       base archive file when using tar format) to ease setting up a
       standby server. The recovery.conf file will record the connection
       settings and, if specified, the replication slot that pg_basebackup
       is using, so that the streaming replication will use the same
       settings later on.
Evan Carroll
  • 2,245
  • 10
  • 34
  • 50
1

If I understood your question correctly, the docs contains instructions on how to pass postgres conf file as configuration parameter.

You can use a systemd unit on RHEL based systems to configure the cluster with custom name and/or configuration.

orotalt
  • 13
  • 2