If installed from a package, the repmgrd can be started
via the operating system's service command, e.g. in systemd
using systemctl
.
See appendix Package details for details of service commands for different distributions.
The commands repmgr daemon start
and
repmgr daemon stop
can be used
as convenience wrappers to start and stop repmgrd on the local node.
repmgr daemon start
and
repmgr daemon stop
require
that the appropriate start/stop commands are configured as
repmgrd_service_start_command
and repmgrd_service_stop_command
in repmgr.conf
.
repmgrd can be started manually like this:
repmgrd -f /etc/repmgr.conf --pid-file /tmp/repmgrd.pid
and stopped with kill `cat /tmp/repmgrd.pid`
. Adjust paths as appropriate.
repmgrd will generate a PID file by default.
This is a behaviour change from previous versions (earlier than 4.1), where
the PID file had to be explicitly specified with the command line
parameter --pid-file
.
The PID file can be specified in repmgr.conf
with the configuration
parameter repmgrd_pid_file
.
It can also be specified on the command line (as in previous versions) with
the command line parameter --pid-file
. Note this will override
any value set in repmgr.conf
with repmgrd_pid_file
.
--pid-file
may be deprecated in future releases.
If a PID file location was specified by the package maintainer, repmgrd will use that. This only applies if repmgr was installed from a package and the package maintainer has specified the PID file location.
If none of the above apply, repmgrd will create a PID file
in the operating system's temporary directory (as setermined by the environment variable
TMPDIR
, or if that is not set, will use /tmp
).
To prevent a PID file being generated at all, provide the command line option
--no-pid-file
.
To see which PID file repmgrd would use, execute repmgrd
with the option --show-pid-file
. repmgrd
will not start if this option is provided. Note that the value shown is the
file repmgrd would use next time it starts, and is
not necessarily the PID file currently in use.
If repmgr was installed from Debian/Ubuntu packages, additional configuration is required before repmgrd is started as a daemon.
This is done via the file /etc/default/repmgrd
, which by default
looks like this:
# default settings for repmgrd. This file is source by /bin/sh from # /etc/init.d/repmgrd # disable repmgrd by default so it won't get started upon installation # valid values: yes/no REPMGRD_ENABLED=no # configuration file (required) #REPMGRD_CONF="/path/to/repmgr.conf" # additional options REPMGRD_OPTS="--daemonize=false" # user to run repmgrd as #REPMGRD_USER=postgres # repmgrd binary #REPMGRD_BIN=/usr/bin/repmgrd # pid file #REPMGRD_PIDFILE=/var/run/repmgrd.pid
Set REPMGRD_ENABLED
to yes
, and REPMGRD_CONF
to the repmgr.conf
file you are using.
See Debian/Ubuntu packages for details of the Debian/Ubuntu packages and
typical file locations (including repmgr.conf
).
From repmgrd 4.1, ensure REPMGRD_OPTS
includes
--daemonize=false
, as daemonization is handled by the service command.
If using systemd, you may need to execute systemctl daemon-reload
.
Also, if you attempted to start repmgrd using systemctl start repmgrd
,
you'll need to execute systemctl stop repmgrd
. Because that's how systemd
rolls.