mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 00:26:30 +00:00
Document repmgrd's role on each type of node. Add
logging (when run in verbose mode) showing what decisions repmgrd is making after it determines what type of node it is.
This commit is contained in:
48
README.rst
48
README.rst
@@ -524,12 +524,28 @@ First, register the master by typing on "node1"::
|
|||||||
|
|
||||||
repmgr -f /var/lib/pgsql/repmgr/repmgr.conf --verbose master register
|
repmgr -f /var/lib/pgsql/repmgr/repmgr.conf --verbose master register
|
||||||
|
|
||||||
Start the "standby" server.
|
Then start the "standby" server.
|
||||||
|
|
||||||
Register the standby by typing on "node2"::
|
You could now register the standby by typing on "node2"::
|
||||||
|
|
||||||
repmgr -f /var/lib/pgsql/repmgr/repmgr.conf --verbose standby register
|
repmgr -f /var/lib/pgsql/repmgr/repmgr.conf --verbose standby register
|
||||||
|
|
||||||
|
However, you can instead start repmgrd::
|
||||||
|
|
||||||
|
repmgrd -f /var/lib/pgsql/repmgr/repmgr.conf --verbose > /var/lib/pgsql/repmgr/repmgr.log 2>&1
|
||||||
|
|
||||||
|
Which will automatically register your standby system. And eventually
|
||||||
|
you need repmgrd running anyway, to save lag monitoring information.
|
||||||
|
repmgrd will log the deamon activity to the listed file. You can
|
||||||
|
watch what it is doing with::
|
||||||
|
|
||||||
|
tail -f /var/lib/pgsql/repmgr/repmgr.log
|
||||||
|
|
||||||
|
Hit control-C to exit this tail command when you are done.
|
||||||
|
|
||||||
|
Monitoring and testing
|
||||||
|
----------------------
|
||||||
|
|
||||||
At this point, you have a functioning primary on "node1" and a functioning
|
At this point, you have a functioning primary on "node1" and a functioning
|
||||||
standby server running on "node2". You can confirm the master knows
|
standby server running on "node2". You can confirm the master knows
|
||||||
about the standby, and that it is keeping it current, by looking at
|
about the standby, and that it is keeping it current, by looking at
|
||||||
@@ -955,19 +971,16 @@ the program.
|
|||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
|
|
||||||
repmgrd reads the ``repmgr.conf`` file in current directory, or as indicated with -f
|
repmgrd reads the ``repmgr.conf`` file in current directory, or as
|
||||||
parameter. It checks if the standby is in repl_nodes and adds it if not.
|
indicated with -f parameter. If run on a standby, it checks if that
|
||||||
|
standby is in ``repl_nodes`` and adds it if not.
|
||||||
|
|
||||||
Before you can run the repmgr daemon (repmgrd) you need to register a master
|
Before you can run repmgrd you need to register a master in a cluster
|
||||||
and at least a standby in a cluster using the ``MASTER REGISTER`` and
|
using the ``MASTER REGISTER`` command. If run on a master,
|
||||||
``STANDBY REGISTER`` commands.
|
repmgrd will exit, as it has nothing to do on them yet. It is only
|
||||||
|
targeted at running on standby servers currently. If converting
|
||||||
For example, following last example and assuming that ``repmgr.conf`` is in postgres
|
a former master into a standby, you will need to start repmgrd
|
||||||
home directory you will run this on the master::
|
in order to make it fully operational in its new role.
|
||||||
|
|
||||||
repmgr -f /home/postgres/repmgr.conf master register
|
|
||||||
|
|
||||||
and the same in the standby.
|
|
||||||
|
|
||||||
The repmgr daemon creates 2 connections: one to the master and another to the
|
The repmgr daemon creates 2 connections: one to the master and another to the
|
||||||
standby.
|
standby.
|
||||||
@@ -975,9 +988,9 @@ standby.
|
|||||||
Lag monitoring
|
Lag monitoring
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
The repmgrd (repmgr daemon) helps monitor a set of master and standby
|
repmgrd helps monitor a set of master and standby servers. You can
|
||||||
servers. You can see which node is the current master, as well as how
|
see which node is the current master, as well as how far behind each
|
||||||
far behind each is from current.
|
is from current.
|
||||||
|
|
||||||
To look at the current lag between primary and each node listed
|
To look at the current lag between primary and each node listed
|
||||||
in ``repl_node``, consult the ``repl_status`` view::
|
in ``repl_node``, consult the ``repl_status`` view::
|
||||||
@@ -994,7 +1007,6 @@ This view shows the latest monitor info from every node.
|
|||||||
|
|
||||||
* time_lag: in seconds. How many seconds behind the master is this node.
|
* time_lag: in seconds. How many seconds behind the master is this node.
|
||||||
|
|
||||||
|
|
||||||
Error codes
|
Error codes
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
|||||||
10
repmgrd.c
10
repmgrd.c
@@ -157,14 +157,11 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
snprintf(repmgr_schema, MAXLEN, "%s%s", DEFAULT_REPMGR_SCHEMA_PREFIX, local_options.cluster_name);
|
snprintf(repmgr_schema, MAXLEN, "%s%s", DEFAULT_REPMGR_SCHEMA_PREFIX, local_options.cluster_name);
|
||||||
|
|
||||||
printf("Establishing database connection\n");
|
|
||||||
|
|
||||||
log_info(_("%s Connecting to database '%s'\n"), progname, local_options.conninfo);
|
log_info(_("%s Connecting to database '%s'\n"), progname, local_options.conninfo);
|
||||||
|
|
||||||
myLocalConn = establishDBConnection(local_options.conninfo, true);
|
myLocalConn = establishDBConnection(local_options.conninfo, true);
|
||||||
|
|
||||||
/* should be v9 or better */
|
/* should be v9 or better */
|
||||||
log_info(_("%s connected to database, checking its state\n"), progname);
|
log_info(_("%s Connected to database, checking its state\n"), progname);
|
||||||
pg_version(myLocalConn, standby_version);
|
pg_version(myLocalConn, standby_version);
|
||||||
if (strcmp(standby_version, "") == 0)
|
if (strcmp(standby_version, "") == 0)
|
||||||
{
|
{
|
||||||
@@ -203,8 +200,13 @@ main(int argc, char **argv)
|
|||||||
checkNodeConfiguration(local_options.conninfo);
|
checkNodeConfiguration(local_options.conninfo);
|
||||||
if (myLocalMode == STANDBY_MODE)
|
if (myLocalMode == STANDBY_MODE)
|
||||||
{
|
{
|
||||||
|
log_info(_("%s Starting continuous standby node monitoring'\n"), progname);
|
||||||
MonitorCheck();
|
MonitorCheck();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log_info(_("%s This is a primary node, program not needed here; exiting'\n"), progname);
|
||||||
|
}
|
||||||
|
|
||||||
/* Prevent a double-free */
|
/* Prevent a double-free */
|
||||||
if (primaryConn == myLocalConn)
|
if (primaryConn == myLocalConn)
|
||||||
|
|||||||
Reference in New Issue
Block a user