Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7085891

Browse files
Improvements to docs about pg_archive_cleanup and use of archives
Brendan Jurd
1 parent3bbcc5c commit7085891

File tree

3 files changed

+54
-42
lines changed

3 files changed

+54
-42
lines changed

‎doc/src/sgml/high-availability.sgml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -680,11 +680,6 @@ protocol to make nodes agree on a serializable transactional order.
680680
<varname>primary_conninfo</> as well.
681681
</para>
682682

683-
<para>
684-
You can use <varname>archive_cleanup_command</> to prune the archive of
685-
files no longer needed by the standby.
686-
</para>
687-
688683
<para>
689684
If you're setting up the standby server for high availability purposes,
690685
set up WAL archiving, connections and authentication like the primary
@@ -696,13 +691,26 @@ protocol to make nodes agree on a serializable transactional order.
696691
is not required.
697692
</para>
698693

694+
<para>
695+
If you're using a WAL archive, its size can be minimized using the <xref
696+
linkend="archive-cleanup-command"> parameter to remove files that are no
697+
longer required by the standby server.
698+
The <application>pg_archivecleanup</> utility is designed specifically to
699+
be used with <varname>archive_cleanup_command</> in typical single-standby
700+
configurations, see <xref linkend="pgarchivecleanup">.
701+
Note however, that if you're using the archive for backup purposes, you
702+
need to retain files needed to recover from at least the latest base
703+
backup, even if they're no longer needed by the standby.
704+
</para>
705+
699706
<para>
700707
A simple example of a <filename>recovery.conf</> is:
701708
<programlisting>
702709
standby_mode = 'on'
703710
primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
704711
restore_command = 'cp /path/to/archive/%f %p'
705712
trigger_file = '/path/to/trigger_file'
713+
archive_cleanup_command = 'pg_archivecleanup /path/to/archive %r'
706714
</programlisting>
707715
</para>
708716

@@ -712,14 +720,6 @@ trigger_file = '/path/to/trigger_file'
712720
the primary to allow them to be connected simultaneously.
713721
</para>
714722

715-
<para>
716-
If you're using a WAL archive, its size can be minimized using
717-
the <varname>archive_cleanup_command</> option to remove files that are
718-
no longer required by the standby server. Note however, that if you're
719-
using the archive for backup purposes, you need to retain files needed
720-
to recover from at least the latest base backup, even if they're no
721-
longer needed by the standby.
722-
</para>
723723
</sect2>
724724

725725
<sect2 id="streaming-replication">

‎doc/src/sgml/pgarchivecleanup.sgml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
</indexterm>
99

1010
<para>
11-
<application>pg_archivecleanup</> is designed to cleanup an archive when used
12-
as an <literal>archive_cleanup_command</literal> when running with
13-
<literal>standby_mode = on</literal>. <application>pg_archivecleanup</> can
14-
also be used as a standalone program to clean WAL file archives.
11+
<application>pg_archivecleanup</> is designed to be used as an
12+
<literal>archive_cleanup_command</literal> to clean up WAL file archives when
13+
running as a standby server (see <xref linkend="warm-standby">).
14+
<application>pg_archivecleanup</> can also be used as a standalone program to
15+
clean WAL file archives.
1516
</para>
1617

1718
<para>
@@ -39,20 +40,21 @@
3940
server to use <application>pg_archivecleanup</>, put this into its
4041
<filename>recovery.conf</filename> configuration file:
4142
<programlisting>
42-
archive_cleanup_command = 'pg_archivecleanup <replaceable>archiveDir</> %r'
43+
archive_cleanup_command = 'pg_archivecleanup <replaceable>archivelocation</> %r'
4344
</programlisting>
44-
where <replaceable>archiveDir</> is the directory from which WAL segment
45-
files should berestored.
45+
where <replaceable>archivelocation</> is the directory from which WAL segment
46+
files should beremoved.
4647
</para>
4748
<para>
48-
When used within <literal>archive_cleanup_command</literal>,
49-
all WAL files logically preceding the value of the <literal>%r</>
50-
will be removed <replaceable>archivelocation</>. This minimizes
51-
the number of files that need to be retained, while preserving
52-
crash-restart capability. Use of this parameter is appropriate if the
53-
<replaceable>archivelocation</> is a transient staging area for this
54-
particular standby server, but <emphasis>not</> when the
55-
<replaceable>archivelocation</> is intended as a long-term WAL archive area.
49+
When used within <xref linkend="archive-cleanup-command">, all WAL files
50+
logically preceding the value of the <literal>%r</> argument will be removed
51+
from <replaceable>archivelocation</>. This minimizes the number of files
52+
that need to be retained, while preserving crash-restart capability. Use of
53+
this parameter is appropriate if the <replaceable>archivelocation</> is a
54+
transient staging area for this particular standby server, but
55+
<emphasis>not</> when the <replaceable>archivelocation</> is intended as a
56+
long-term WAL archive area, or when multiple standby servers are recovering
57+
from the same archive location.
5658
</para>
5759
<para>
5860
The full syntax of <application>pg_archivecleanup</>'s command line is

‎doc/src/sgml/recovery-config.sgml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,30 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows
8080
</indexterm>
8181
<listitem>
8282
<para>
83-
This parameter specifies a shell command that will be executed at
84-
every restartpoint. This parameter is optional. The purpose of the
85-
<varname>archive_cleanup_command</> is to provide a mechanism for cleaning
86-
up old archived WAL files that are no longer needed by the standby
87-
server.
88-
Any <literal>%r</> is replaced by the name of the file
89-
containing the last valid restart point. That is the earliest file that
90-
must be kept to allow a restore to be restartable, so this information
91-
can be used to truncate the archive to just the minimum required to
92-
support restart from the current restore. <literal>%r</> would
93-
typically be used in a warm-standby configuration
94-
(see <xref linkend="warm-standby">).
95-
Write <literal>%%</> to embed an actual <literal>%</> character
96-
in the command.
83+
This optional parameter specifies a shell command that will be executed
84+
at every restartpoint. The purpose of
85+
<varname>archive_cleanup_command</> is to provide a mechanism for
86+
cleaning up old archived WAL files that are no longer needed by the
87+
standby server.
88+
Any <literal>%r</> is replaced by the name of the file containing the
89+
last valid restart point.
90+
That is the earliest file that must be <emphasis>kept</> to allow a
91+
restore to be restartable, and so all files earlier than <literal>%r</>
92+
may be safely removed.
93+
This information can be used to truncate the archive to just the
94+
minimum required to support restart from the current restore.
95+
The <application>pg_archivecleanup</> utility provided in
96+
<literal>contrib</> (see <xref linkend="pgarchivecleanup">) serves as a
97+
convenient target for <varname>archive_cleanup_command</> in typical
98+
single-standby configurations, for example:
99+
<programlisting> archive_cleanup_command = 'pg_archivecleanup /mnt/server/archivedir %r' </programlisting>
100+
Note however that if multiple standby servers are restoring from the
101+
same archive directory, you will need to ensure that you do not delete
102+
WAL files until they are no longer needed by any of the servers.
103+
<varname>archive_cleanup_command</> would typically be used in a
104+
warm-standby configuration (see <xref linkend="warm-standby">).
105+
Write <literal>%%</> to embed an actual <literal>%</> character in the
106+
command.
97107
</para>
98108
<para>
99109
If the command returns a non-zero exit status then a WARNING log

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp