0

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
● postgresql@13-apif.service - PostgreSQL Cluster 13-apif
   Loaded: loaded (/lib/systemd/system/postgresql@.service; 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/postgresql@13-apif.service
           ├─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.

Alexi Theodore
  • 1,177
  • 10
  • 16
  • Do `man pg_createcluster` to see what those options really mean. Hint not what you think. My guess is you will need to modify the `/etc/postgresql/13/apif/pg_ctl.conf` file. – Adrian Klaver Dec 15 '21 at 22:26
  • I had already and I have no idea how I missed that, but yea I see it now. Anyways, I dug around and still couldn't really find what I was looking for. I settled on an acceptable alternative (answered below). – Alexi Theodore Dec 16 '21 at 00:17
  • 2
    Don't use the packaged startup and cluster creation scripts if you don't want to stick with the packagers' ideas of file locations. Roll your own. – Laurenz Albe Dec 16 '21 at 07:05

1 Answers1

0

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
Alexi Theodore
  • 1,177
  • 10
  • 16