mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
283 lines
9.2 KiB
XML
283 lines
9.2 KiB
XML
<chapter id="event-notifications" xreflabel="event notifications">
|
|
<title>Event Notifications</title>
|
|
|
|
<indexterm>
|
|
<primary>event notifications</primary>
|
|
</indexterm>
|
|
|
|
<para>
|
|
Each time &repmgr; or &repmgrd; perform a significant event, a record
|
|
of that event is written into the <literal>repmgr.events</literal> table together with
|
|
a timestamp, an indication of failure or success, and further details
|
|
if appropriate. This is useful for gaining an overview of events
|
|
affecting the replication cluster. However note that this table has
|
|
advisory character and should be used in combination with the &repmgr;
|
|
and PostgreSQL logs to obtain details of any events.
|
|
</para>
|
|
<para>
|
|
Example output after a primary was registered and a standby cloned
|
|
and registered:
|
|
<programlisting>
|
|
repmgr=# SELECT * from repmgr.events ;
|
|
node_id | event | successful | event_timestamp | details
|
|
---------+------------------+------------+-------------------------------+-------------------------------------------------------------------------------------
|
|
1 | primary_register | t | 2016-01-08 15:04:39.781733+09 |
|
|
2 | standby_clone | t | 2016-01-08 15:04:49.530001+09 | Cloned from host 'repmgr_node1', port 5432; backup method: pg_basebackup; --force: N
|
|
2 | standby_register | t | 2016-01-08 15:04:50.621292+09 |
|
|
(3 rows)</programlisting>
|
|
</para>
|
|
<para>
|
|
Alternatively, use <xref linkend="repmgr-cluster-event"/> to output a
|
|
formatted list of events.
|
|
</para>
|
|
<para>
|
|
Additionally, event notifications can be passed to a user-defined program
|
|
or script which can take further action, e.g. send email notifications.
|
|
This is done by setting the <literal>event_notification_command</literal> parameter in
|
|
<filename>repmgr.conf</filename>.
|
|
</para>
|
|
<para>
|
|
The following format placeholders are provided for all event notifications:
|
|
</para>
|
|
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><option>%n</option></term>
|
|
<listitem>
|
|
<para>
|
|
node ID
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
<term><option>%e</option></term>
|
|
<listitem>
|
|
<para>
|
|
event type
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
<term><option>%s</option></term>
|
|
<listitem>
|
|
<para>
|
|
success (1) or failure (0)
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><option>%t</option></term>
|
|
<listitem>
|
|
<para>
|
|
timestamp
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
<term><option>%d</option></term>
|
|
<listitem>
|
|
<para>
|
|
details
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
|
|
<para>
|
|
The values provided for <literal>%t</literal> and <literal>%d</literal>
|
|
may contain spaces, so should be quoted in the provided command
|
|
configuration, e.g.:
|
|
<programlisting>
|
|
event_notification_command='/path/to/some/script %n %e %s "%t" "%d"'</programlisting>
|
|
</para>
|
|
|
|
<para>
|
|
The following parameters are provided for a subset of event notifications; their meaning may
|
|
change according to context:
|
|
</para>
|
|
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><option>%p</option></term>
|
|
<listitem>
|
|
<para>
|
|
node ID of the current primary (<xref linkend="repmgr-standby-register"/> and <xref linkend="repmgr-standby-follow"/>)
|
|
</para>
|
|
<para>
|
|
node ID of the demoted primary (<xref linkend="repmgr-standby-switchover"/> only)
|
|
</para>
|
|
<para>
|
|
node ID of the former primary (<literal>repmgrd_failover_promote</literal> only)
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><option>%c</option></term>
|
|
<listitem>
|
|
<para>
|
|
<literal>conninfo</literal> string of the primary node
|
|
(<xref linkend="repmgr-standby-register"/> and <xref linkend="repmgr-standby-follow"/>)
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
<term><option>%a</option></term>
|
|
<listitem>
|
|
<para>
|
|
name of the current primary node (<xref linkend="repmgr-standby-register"/> and <xref linkend="repmgr-standby-follow"/>)
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
<para>
|
|
The values provided for <literal>%c</literal> and <literal>%a</literal>
|
|
may contain spaces, so should always be quoted.
|
|
</para>
|
|
|
|
<para>
|
|
By default, all notification types will be passed to the designated script;
|
|
the notification types can be filtered to explicitly named ones using the
|
|
<varname>event_notifications</varname> parameter, e.g.:
|
|
<programlisting>
|
|
event_notifications='primary_register,standby_register,witness_register'</programlisting>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
Events generated by the &repmgr; command:
|
|
|
|
<itemizedlist spacing="compact" mark="bullet">
|
|
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgr-primary-register-events">cluster_created</link></literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgr-primary-register-events">primary_register</link></literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgr-primary-unregister-events">primary_unregister</link></literal></simpara>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgr-standby-clone-events">standby_clone</link></literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgr-standby-register-events">standby_register</link></literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgr-standby-register-events">standby_register_sync</link></literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgr-standby-unregister-events">standby_unregister</link></literal></simpara>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgr-standby-promote-events">standby_promote</link></literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgr-standby-follow-events">standby_follow</link></literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgr-standby-switchover-events">standby_switchover</link></literal></simpara>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgr-witness-register-events">witness_register</link></literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgr-witness-unregister-events">witness_unregister</link></literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgr-node-rejoin-events">node_rejoin</link></literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgr-cluster-cleanup-events">cluster_cleanup</link></literal></simpara>
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
</para>
|
|
|
|
<para>
|
|
Events generated by &repmgrd; (streaming replication mode):
|
|
|
|
<itemizedlist spacing="compact" mark="bullet">
|
|
<listitem>
|
|
<simpara><literal>repmgrd_start</literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal>repmgrd_shutdown</literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal>repmgrd_reload</literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal>repmgrd_failover_promote</literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal>repmgrd_failover_follow</literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal>repmgrd_failover_aborted</literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal>repmgrd_standby_reconnect</literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal>repmgrd_promote_error</literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal>repmgrd_local_disconnect</literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal>repmgrd_local_reconnect</literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal>repmgrd_upstream_disconnect</literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal>repmgrd_upstream_reconnect</literal></simpara>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<simpara><literal>standby_disconnect_manual</literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal>standby_failure</literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal>standby_recovery</literal></simpara>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgrd-primary-child-disconnection-events">child_node_disconnect</link></literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgrd-primary-child-disconnection-events">child_node_reconnect</link></literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgrd-primary-child-disconnection-events">child_node_new_connect</link></literal></simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><literal><link linkend="repmgrd-primary-child-disconnection-events">child_nodes_disconnect_command</link></literal></simpara>
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
</para>
|
|
|
|
<para>
|
|
Note that under some circumstances (e.g. when no replication cluster primary
|
|
could be located), it will not be possible to write an entry into the
|
|
<literal>repmgr.events</literal>
|
|
table, in which case executing a script via <varname>event_notification_command</varname>
|
|
can serve as a fallback by generating some form of notification.
|
|
</para>
|
|
|
|
|
|
</chapter>
|