Postgres on Ubuntu, controlling the postgresql.conf location

575 Views Asked by At

I created a cluster as follows:

pg_createcluster -d /some_dir/pg_data/ -p 5432 \
    --environment=/some_dir/pg_env.prod.conf \
    --createclusterconf=/some_dir/pg.prod.conf \
    13 apif

However, when the cluster is stood-up, it has effectively copied the pg.prod.conf file to the default directory (-c config_file=/etc/postgresql/13/apif/postgresql.conf) rather than using it. That means if I make changes to the file, of course, they won't be seen. Thats not what I wanted.

sudo systemctl status postgresql@13-apif
● [email protected] - PostgreSQL Cluster 13-apif
   Loaded: loaded (/lib/systemd/system/[email protected]; indirect; vendor preset: enabled)
   Active: active (running) since Wed 2021-12-15 21:15:25 UTC; 6s ago
  Process: 6791 ExecStop=/usr/bin/pg_ctlcluster --skip-systemctl-redirect -m fast 13-apif stop (code=exited, status=2)
  Process: 6656 ExecReload=/usr/bin/pg_ctlcluster --skip-systemctl-redirect 13-apif reload (code=exited, status=0/SUCCESS)
  Process: 6868 ExecStart=/usr/bin/pg_ctlcluster --skip-systemctl-redirect 13-apif start (code=exited, status=0/SUCCESS)
 Main PID: 6873 (postgres)
    Tasks: 9 (limit: 4915)
   CGroup: /system.slice/system-postgresql.slice/[email protected]
           ├─6873 /usr/lib/postgresql/13/bin/postgres -D /some_dir/apif -c config_file=/etc/postgresql/13/apif/postgresql.conf
           ├─6874 postgres: logger
           ├─6876 postgres: checkpointer
           ├─6877 postgres: background writer
           ├─6878 postgres: walwriter
           ├─6879 postgres: autovacuum launcher
           ├─6880 postgres: stats collector
           ├─6881 postgres: pg_cron launcher
           └─6882 postgres: logical replication launcher

Dec 15 21:15:22 ip-172-33-2-19 systemd[1]: Starting PostgreSQL Cluster 13-apif...
Dec 15 21:15:25 ip-172-33-2-19 systemd[1]: Started PostgreSQL Cluster 13-apif.
...

How do I do this the way I want to?... where the cluster is configured to reference a file of my choosing, permanently.

1

There are 1 best solutions below

0
On

I tried to find an answer and couldn't.

But I did find an acceptable work-around. And while this isn't quite what I was looking for because it doesn't explicitly specify the location of the conf file, it does allow me to reference it in a replicable one-liner.

pg_createcluster -d /some_dir/pg_data/ -p 5432 \
    --environment=/some_dir/pg_env.prod.conf \
    --pgoption include_if_exists=/some_dir/pg.prod.conf \
    13 apif