EnterpriseDB/repmgr

Docs clarification: usage of pg_ctlcluster in Debian/Ubuntu

Opened this issue · 0 comments

At https://repmgr.org/docs/current/configuration-file-service-commands.html, there can be some clarification to the following statement:

and set /etc/sudoers accordingly

->

and set /etc/sudoers accordingly, e.g.:

cat << EOT | tee /etc/sudoers.d/postgres
postgres ALL = NOPASSWD: /usr/bin/pg_ctlcluster
postgres ALL = NOPASSWD: /usr/bin/systemctl * repmgrd
EOT

Also,

While pg_ctlcluster will work when executed as user postgres, it's strongly recommended to use sudo pg_ctlcluster on systemd systems, to ensure systemd has a correct picture of the PostgreSQL application state.

->

Notice the sudo: if pg_ctlcluster is executed as user postgres, it won't update systemd state correctly. When running pg_ctlcluster as root on systemd systems, it redirects its work to systemd and update the picture of PostgreSQL application state accordingly.

P.S.
In practice I found no difference in calling sudo systemd stop postgres@13-main and sudo pg_ctlcluster 13 main stop, because the latter just calls the former internally.