mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 16:46:28 +00:00
Enable provision of "archive_cleanup_command" in recovery.conf
If "archive_cleanup_command" is defined in "repmgr.conf", a corresponding entry will be made in the node's "recovery.conf" file after cloning a standby. Note that we recommend using PgBarman to manage WAL archives, but are providing this facility to help repmgr to be integrated in existing environments. Implements GitHub #416.
This commit is contained in:
@@ -314,6 +314,7 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
|||||||
options->tablespace_mapping.tail = NULL;
|
options->tablespace_mapping.tail = NULL;
|
||||||
memset(options->recovery_min_apply_delay, 0, sizeof(options->recovery_min_apply_delay));
|
memset(options->recovery_min_apply_delay, 0, sizeof(options->recovery_min_apply_delay));
|
||||||
options->recovery_min_apply_delay_provided = false;
|
options->recovery_min_apply_delay_provided = false;
|
||||||
|
memset(options->archive_cleanup_command, 0, sizeof(options->archive_cleanup_command));
|
||||||
options->use_primary_conninfo_password = false;
|
options->use_primary_conninfo_password = false;
|
||||||
memset(options->passfile, 0, sizeof(options->passfile));
|
memset(options->passfile, 0, sizeof(options->passfile));
|
||||||
|
|
||||||
@@ -508,6 +509,8 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
|||||||
parse_time_unit_parameter(name, value, options->recovery_min_apply_delay, error_list);
|
parse_time_unit_parameter(name, value, options->recovery_min_apply_delay, error_list);
|
||||||
options->recovery_min_apply_delay_provided = true;
|
options->recovery_min_apply_delay_provided = true;
|
||||||
}
|
}
|
||||||
|
else if (strcmp(name, "archive_cleanup_command") == 0)
|
||||||
|
strncpy(options->archive_cleanup_command, value, MAXLEN);
|
||||||
else if (strcmp(name, "use_primary_conninfo_password") == 0)
|
else if (strcmp(name, "use_primary_conninfo_password") == 0)
|
||||||
options->use_primary_conninfo_password = parse_bool(value, name, error_list);
|
options->use_primary_conninfo_password = parse_bool(value, name, error_list);
|
||||||
else if (strcmp(name, "passfile") == 0)
|
else if (strcmp(name, "passfile") == 0)
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ typedef struct
|
|||||||
TablespaceList tablespace_mapping;
|
TablespaceList tablespace_mapping;
|
||||||
char recovery_min_apply_delay[MAXLEN];
|
char recovery_min_apply_delay[MAXLEN];
|
||||||
bool recovery_min_apply_delay_provided;
|
bool recovery_min_apply_delay_provided;
|
||||||
|
char archive_cleanup_command[MAXLEN];
|
||||||
bool use_primary_conninfo_password;
|
bool use_primary_conninfo_password;
|
||||||
char passfile[MAXPGPATH];
|
char passfile[MAXPGPATH];
|
||||||
|
|
||||||
@@ -161,8 +162,8 @@ typedef struct
|
|||||||
UNKNOWN_NODE_ID, "", "", "", "", "", REPLICATION_TYPE_PHYSICAL, \
|
UNKNOWN_NODE_ID, "", "", "", "", "", REPLICATION_TYPE_PHYSICAL, \
|
||||||
/* log settings */ \
|
/* log settings */ \
|
||||||
"", "", "", DEFAULT_LOG_STATUS_INTERVAL, \
|
"", "", "", DEFAULT_LOG_STATUS_INTERVAL, \
|
||||||
/* standby action settings */ \
|
/* standby clone settings */ \
|
||||||
false, "", "", { NULL, NULL }, "", false, false, "", \
|
false, "", "", { NULL, NULL }, "", false, "", false, "", \
|
||||||
/* standby promote settings */ \
|
/* standby promote settings */ \
|
||||||
DEFAULT_PROMOTE_CHECK_TIMEOUT, DEFAULT_PROMOTE_CHECK_INTERVAL, \
|
DEFAULT_PROMOTE_CHECK_TIMEOUT, DEFAULT_PROMOTE_CHECK_INTERVAL, \
|
||||||
/* node check settings */ \
|
/* node check settings */ \
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<sect2 id="cloning-from-barman-prerequisites" xreflabel="Prerequisites for cloning from Barman">
|
<sect2 id="cloning-from-barman-prerequisites">
|
||||||
<title>Prerequisites for cloning from Barman</title>
|
<title>Prerequisites for cloning from Barman</title>
|
||||||
<para>
|
<para>
|
||||||
In order to enable Barman support for <command>repmgr standby clone</command>, following
|
In order to enable Barman support for <command>repmgr standby clone</command>, following
|
||||||
|
|||||||
@@ -65,7 +65,71 @@
|
|||||||
</tip>
|
</tip>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
<refsect1 id="repmgr-standby-clone-wal-management" xreflabel="Managing WAL during the cloning process">
|
<refsect1 id="repmgr-standby-clone-recovery-conf">
|
||||||
|
<indexterm>
|
||||||
|
<primary>recovery.conf</primary>
|
||||||
|
<secondary>customising with "repmgr standby clone"</secondary>
|
||||||
|
</indexterm>
|
||||||
|
|
||||||
|
<title>Customising recovery.conf</title>
|
||||||
|
<para>
|
||||||
|
By default, &repmgr; will create a minimal <filename>recovery.conf</filename>
|
||||||
|
containing following parameters:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<itemizedlist spacing="compact" mark="bullet">
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<simpara><varname>standby_mode</varname> (always <literal>'on'</literal>)</simpara>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<simpara><varname>recovery_target_timeline</varname> (always <literal>'latest'</literal>)</simpara>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<simpara><varname>primary_conninfo</varname></simpara>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<simpara><varname>primary_slot_name</varname> (if replication slots in use)</simpara>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
</itemizedlist>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The following additional parameters can be specified in <filename>repmgr.conf</filename>
|
||||||
|
for inclusion in <filename>recovery.conf</filename>:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<itemizedlist spacing="compact" mark="bullet">
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<simpara><varname>restore_command</varname></simpara>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<simpara><varname>archive_cleanup_command</varname></simpara>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<simpara><varname>recovery_min_apply_delay</varname></simpara>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
</itemizedlist>
|
||||||
|
|
||||||
|
<note>
|
||||||
|
<para>
|
||||||
|
We recommend using <ulink url="https://www.pgbarman.org/">Barman</ulink> to manage
|
||||||
|
WAL file archiving. For more details on combining &repmgr; and <application>Barman</application>,
|
||||||
|
in particular using <varname>restore_command</varname> to configure Barman as a backu source of
|
||||||
|
WAL files, see <xref linkend="cloning-from-barman">.
|
||||||
|
</para>
|
||||||
|
</note>
|
||||||
|
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1 id="repmgr-standby-clone-wal-management">
|
||||||
<title>Managing WAL during the cloning process</title>
|
<title>Managing WAL during the cloning process</title>
|
||||||
<para>
|
<para>
|
||||||
When initially cloning a standby, you will need to ensure
|
When initially cloning a standby, you will need to ensure
|
||||||
@@ -102,6 +166,12 @@
|
|||||||
|
|
||||||
|
|
||||||
<refsect1 id="repmgr-standby-create-recovery-conf">
|
<refsect1 id="repmgr-standby-create-recovery-conf">
|
||||||
|
|
||||||
|
<indexterm>
|
||||||
|
<primary>recovery.conf</primary>
|
||||||
|
<secondary>generating for a standby cloned by another method</secondary>
|
||||||
|
</indexterm>
|
||||||
|
|
||||||
<title>Using a standby cloned by another method</title>
|
<title>Using a standby cloned by another method</title>
|
||||||
<para>
|
<para>
|
||||||
&repmgr; supports standbys cloned by another method (e.g. using <application>barman</application>'s
|
&repmgr; supports standbys cloned by another method (e.g. using <application>barman</application>'s
|
||||||
|
|||||||
@@ -5864,7 +5864,6 @@ create_recovery_file(t_node_info *node_record, t_conninfo_param_list *recovery_c
|
|||||||
appendPQExpBuffer(&recovery_file_buf,
|
appendPQExpBuffer(&recovery_file_buf,
|
||||||
"recovery_min_apply_delay = %s\n",
|
"recovery_min_apply_delay = %s\n",
|
||||||
config_file_options.recovery_min_apply_delay);
|
config_file_options.recovery_min_apply_delay);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* primary_slot_name = '...' (optional, for 9.4 and later) */
|
/* primary_slot_name = '...' (optional, for 9.4 and later) */
|
||||||
@@ -5889,6 +5888,16 @@ create_recovery_file(t_node_info *node_record, t_conninfo_param_list *recovery_c
|
|||||||
free(escaped);
|
free(escaped);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* archive_cleanup_command (optional) */
|
||||||
|
if (config_file_options.archive_cleanup_command[0] != '\0')
|
||||||
|
{
|
||||||
|
char *escaped = escape_recovery_conf_value(config_file_options.archive_cleanup_command);
|
||||||
|
appendPQExpBuffer(&recovery_file_buf,
|
||||||
|
"archive_cleanup_command = '%s'\n",
|
||||||
|
escaped);
|
||||||
|
free(escaped);
|
||||||
|
}
|
||||||
|
|
||||||
if (as_file == true)
|
if (as_file == true)
|
||||||
{
|
{
|
||||||
maxpath_snprintf(recovery_file_path, "%s/%s", dest, RECOVERY_COMMAND_FILE);
|
maxpath_snprintf(recovery_file_path, "%s/%s", dest, RECOVERY_COMMAND_FILE);
|
||||||
|
|||||||
@@ -65,9 +65,6 @@
|
|||||||
# at least the number of standbys which will connect
|
# at least the number of standbys which will connect
|
||||||
# to the primary.
|
# to the primary.
|
||||||
|
|
||||||
#recovery_min_apply_delay= # If provided, "recovery_min_apply_delay" in recovery.conf
|
|
||||||
# will be set to this value.
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Witness server settings
|
# Witness server settings
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
@@ -175,8 +172,15 @@ ssh_options='-q -o ConnectTimeout=10' # Options to append to "ssh"
|
|||||||
# file system location to another. This
|
# file system location to another. This
|
||||||
# parameter can be provided multiple times.
|
# parameter can be provided multiple times.
|
||||||
|
|
||||||
#restore_command='' # This will be placed in the recovery.conf
|
#restore_command='' # This will be placed in the recovery.conf file generated
|
||||||
# file generated by repmgr
|
# by repmgr.
|
||||||
|
|
||||||
|
#archive_cleanup_command='' # This will be placed in the recovery.conf file generated
|
||||||
|
# by repmgr. Note we recommend using Barman for managing
|
||||||
|
# WAL archives (see: https://www.pgbarman.org )
|
||||||
|
|
||||||
|
#recovery_min_apply_delay= # If provided, "recovery_min_apply_delay" in recovery.conf
|
||||||
|
# will be set to this value (PostgreSQL 9.4 and later).
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user