mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 15:16:29 +00:00
187 lines
8.1 KiB
Plaintext
187 lines
8.1 KiB
Plaintext
<chapter id="command-reference" xreflabel="command reference">
|
|
<title>repmgr command reference</title>
|
|
|
|
<para>
|
|
Overview of repmgr commands.
|
|
</para>
|
|
|
|
<sect1 id="repmgr-standby-clone" xreflabel="repmgr standby clone">
|
|
<indexterm>
|
|
<primary>repmgr standby clone</primary>
|
|
<seealso>cloning</seealso>
|
|
</indexterm>
|
|
<title>repmgr standby clone</title>
|
|
<para>
|
|
<command>repmgr standby clone</command> clones a PostgreSQL node from another
|
|
PostgreSQL node, typically the primary, but optionally from any other node in
|
|
the cluster or from Barman. It creates the <filename>recovery.conf</filename> file required
|
|
to attach the cloned node to the primary node (or another standby, if cascading replication
|
|
is in use).
|
|
</para>
|
|
<note>
|
|
<simpara>
|
|
<command>repmgr standby clone</command> does not start the standby, and after cloning
|
|
<command>repmgr standby register</command> must be executed to notify &repmgr; of its presence.
|
|
</simpara>
|
|
</note>
|
|
|
|
|
|
<sect2 id="repmgr-standby-clone-config-file-copying" xreflabel="Copying configuration files">
|
|
<title>Handling configuration files</title>
|
|
|
|
<para>
|
|
Note that by default, all configuration files in the source node's data
|
|
directory will be copied to the cloned node. Typically these will be
|
|
<filename>postgresql.conf</filename>, <filename>postgresql.auto.conf</filename>,
|
|
<filename>pg_hba.conf</filename> and <filename>pg_ident.conf</filename>.
|
|
These may require modification before the standby is started.
|
|
</para>
|
|
<para>
|
|
In some cases (e.g. on Debian or Ubuntu Linux installations), PostgreSQL's
|
|
configuration files are located outside of the data directory and will
|
|
not be copied by default. &repmgr; can copy these files, either to the same
|
|
location on the standby server (provided appropriate directory and file permissions
|
|
are available), or into the standby's data directory. This requires passwordless
|
|
SSH access to the primary server. Add the option <literal>--copy-external-config-files</literal>
|
|
to the <command>repmgr standby clone</command> command; by default files will be copied to
|
|
the same path as on the upstream server. Note that the user executing <command>repmgr</command>
|
|
must have write access to those directories.
|
|
</para>
|
|
<para>
|
|
To have the configuration files placed in the standby's data directory, specify
|
|
<literal>--copy-external-config-files=pgdata</literal>, but note that
|
|
any include directives in the copied files may need to be updated.
|
|
</para>
|
|
<tip>
|
|
<simpara>
|
|
For reliable configuration file management we recommend using a
|
|
configuration management tool such as Ansible, Chef, Puppet or Salt.
|
|
</simpara>
|
|
</tip>
|
|
</sect2>
|
|
|
|
<sect2 id="repmgr-standby-clone-wal-management" xreflabel="Managing WAL during the cloning process">
|
|
<title>Managing WAL during the cloning process</title>
|
|
<para>
|
|
When initially cloning a standby, you will need to ensure
|
|
that all required WAL files remain available while the cloning is taking
|
|
place. To ensure this happens when using the default `pg_basebackup` method,
|
|
&repmgr; will set <command>pg_basebackup</command>'s <literal>--xlog-method</literal>
|
|
parameter to <literal>stream</literal>,
|
|
which will ensure all WAL files generated during the cloning process are
|
|
streamed in parallel with the main backup. Note that this requires two
|
|
replication connections to be available (&repmgr; will verify sufficient
|
|
connections are available before attempting to clone, and this can be checked
|
|
before performing the clone using the <literal>--dry-run</literal> option).
|
|
</para>
|
|
<para>
|
|
To override this behaviour, in <filename>repmgr.conf</filename> set
|
|
<command>pg_basebackup</command>'s <literal>--xlog-method</literal>
|
|
parameter to <literal>fetch</literal>:
|
|
<programlisting>
|
|
pg_basebackup_options='--xlog-method=fetch'</programlisting>
|
|
|
|
and ensure that <literal>wal_keep_segments</literal> is set to an appropriately high value.
|
|
See the <ulink url="https://www.postgresql.org/docs/current/static/app-pgbasebackup.html">
|
|
pg_basebackup</ulink> documentation for details.
|
|
</para>
|
|
|
|
<note>
|
|
<simpara>
|
|
From PostgreSQL 10, <command>pg_basebackup</command>'s
|
|
<literal>--xlog-method</literal> parameter has been renamed to
|
|
<literal>--wal-method</literal>.
|
|
</simpara>
|
|
</note>
|
|
</sect2>
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="repmgr-standby-register" xreflabel="repmgr standby register">
|
|
<indexterm><primary>repmgr standby register</primary></indexterm>
|
|
<title>repmgr standby register</title>
|
|
<para>
|
|
<command>repmgr standby register</command> adds a standby's information to
|
|
the &repmgr; metadata. This command needs to be executed to enable
|
|
promote/follow operations and to allow <command>repmgrd</command> to work with the node.
|
|
An existing standby can be registered using this command. Execute with the
|
|
<literal>--dry-run</literal> option to check what would happen without actually registering the
|
|
standby.
|
|
</para>
|
|
|
|
<sect2 id="rempgr-standby-register-wait" xreflabel="rempgr standby register --wait">
|
|
<title>Waiting for the registration to propagate to the standby</title>
|
|
<para>
|
|
Depending on your environment and workload, it may take some time for
|
|
the standby's node record to propagate from the primary to the standby. Some
|
|
actions (such as starting <command>repmgrd</command>) require that the standby's node record
|
|
is present and up-to-date to function correctly.
|
|
</para>
|
|
<para>
|
|
By providing the option <literal>--wait-sync</literal> to the
|
|
<command>repmgr standby register</command> command, &repmgr; will wait
|
|
until the record is synchronised before exiting. An optional timeout (in
|
|
seconds) can be added to this option (e.g. <literal>--wait-sync=60</literal>).
|
|
</para>
|
|
</sect2>
|
|
|
|
<sect2 id="rempgr-standby-register-inactive-node" xreflabel="Registering an inactive node">
|
|
<title>Registering an inactive node</title>
|
|
<para>
|
|
Under some circumstances you may wish to register a standby which is not
|
|
yet running; this can be the case when using provisioning tools to create
|
|
a complex replication cluster. In this case, by using the <literal>-F/--force</literal>
|
|
option and providing the connection parameters to the primary server,
|
|
the standby can be registered.
|
|
</para>
|
|
<para>
|
|
Similarly, with cascading replication it may be necessary to register
|
|
a standby whose upstream node has not yet been registered - in this case,
|
|
using <literal>-F/--force</literal> will result in the creation of an inactive placeholder
|
|
record for the upstream node, which will however later need to be registered
|
|
with the <literal>-F/--force</literal> option too.
|
|
</para>
|
|
<para>
|
|
When used with <command>repmgr standby register</command>, care should be taken that use of the
|
|
<literal>-F/--force</literal> option does not result in an incorrectly configured cluster.
|
|
</para>
|
|
</sect2>
|
|
</sect1>
|
|
|
|
<sect1 id="repmgr-standby-follow" xreflabel="repmgr standby follow">
|
|
<indexterm>
|
|
<primary>repmgr standby follow</primary>
|
|
</indexterm>
|
|
<title>repmgr standby follow</title>
|
|
<para>
|
|
Attaches the standby to a new primary. This command requires a valid
|
|
<filename>repmgr.conf</filename> file for the standby, either specified
|
|
explicitly with <literal>-f/--config-file</literal> or located in a
|
|
default location; no additional arguments are required.
|
|
</para>
|
|
<para>
|
|
This command will force a restart of the standby server, which must be
|
|
running. It can only be used to attach a standby to a new primary node.
|
|
</para>
|
|
<para>
|
|
To re-add an inactive node to the replication cluster, see
|
|
<xref linkend="repmgr-node-rejoin">
|
|
</para>
|
|
</sect1>
|
|
|
|
|
|
<sect1 id="repmgr-node-rejoin" xreflabel="repmgr node rejoin">
|
|
<indexterm>
|
|
<primary>repmgr node rejoin</primary>
|
|
</indexterm>
|
|
<title>repmgr node rejoin</title>
|
|
<para>
|
|
Enables a dormant (stopped) node to be rejoined to the replication cluster.
|
|
</para>
|
|
<para>
|
|
This can optionally use `pg_rewind` to re-integrate a node which has diverged
|
|
from the rest of the cluster, typically a failed primary.
|
|
</para>
|
|
</sect1>
|
|
</chapter>
|