バージョンごとのドキュメント一覧

pg_archivecleanup

pg_archivecleanup <refpurpose>clean up <productname>PostgreSQL</productname> WAL archive files</refpurpose> PostgreSQL WALアーカイブファイルを消去する

概要

pg_archivecleanup [option...] archivelocation oldestkeptwalfile

説明

<title>Description</title>

<application>pg_archivecleanup</application> is designed to be used as an <literal>archive_cleanup_command</literal> to clean up WAL file archives when running as a standby server (see <xref linkend="warm-standby"/>). <application>pg_archivecleanup</application> can also be used as a standalone program to clean WAL file archives. pg_archivecleanupは、スタンバイサーバとして動作している際のWALファイルのアーカイブを消去するためのarchive_cleanup_commandとして使用されるように設計されています(27.2参照)。 同時に、pg_archivecleanupはWALファイルのアーカイブを消去するためのスタンドアローンのプログラムとしても利用することができます。

To configure a standby server to use <application>pg_archivecleanup</application>, put this into its <filename>postgresql.conf</filename> configuration file: pg_archivecleanupを使うためにスタンバイサーバを設定するには、以下をpostgresql.conf設定ファイルに記述します。

archive_cleanup_command = 'pg_archivecleanup archivelocation %r'

where <replaceable>archivelocation</replaceable> is the directory from which WAL segment files should be removed. archivelocationは、WALセグメントファイルを削除するディレクトリです。

When used within <xref linkend="guc-archive-cleanup-command"/>, all WAL files logically preceding the value of the <literal>%r</literal> argument will be removed from <replaceable>archivelocation</replaceable>. This minimizes the number of files that need to be retained, while preserving crash-restart capability. Use of this parameter is appropriate if the <replaceable>archivelocation</replaceable> is a transient staging area for this particular standby server, but <emphasis>not</emphasis> when the <replaceable>archivelocation</replaceable> is intended as a long-term WAL archive area, or when multiple standby servers are recovering from the same archive location. archive_cleanup_commandで使用される場合、論理的に%rより前のすべてのWALファイルはarchivelocationから削除されます。 これによって、クラッシュ—リスタートの機能を維持するための、保持しなければならないファイル数を最小限にします。 このパラメータの使用は、archivelocationがスタンバイサーバにおいて短期的な保存場所となっている場合には適切ですが、archivelocationを長期的なWALアーカイブ領域として使っている場合、または複数のスタンバイサーバが同一のアーカイブログの場所からリカバリしている場合には適切ではありません

When used as a standalone program all WAL files logically preceding the <replaceable>oldestkeptwalfile</replaceable> will be removed from <replaceable>archivelocation</replaceable>. In this mode, if you specify a <filename>.partial</filename> or <filename>.backup</filename> file name, then only the file prefix will be used as the <replaceable>oldestkeptwalfile</replaceable>. This treatment of <filename>.backup</filename> file name allows you to remove all WAL files archived prior to a specific base backup without error. For example, the following example will remove all files older than WAL file name <filename>000000010000003700000010</filename>: スタンドアローンプログラムとして使用される場合、oldestkeptwalfileより論理的に前のWALファイルは、すべてarchivelocationから削除されます。 このモードでは、.partialまたは.backupのファイル名が指定されると、そのプレフィックス部だけがoldestkeptwalfileとして使用されます。 この.backupのファイル名の処置により、エラーを起こすことなく特定のベースバックアップより前のすべてのWALファイルを削除することを可能にします。 以下の例は、000000010000003700000010より古いすべてのファイルを削除する実例です。

pg_archivecleanup -d archive 000000010000003700000010.00000020.backup

pg_archivecleanup:  keep WAL file "archive/000000010000003700000010" and later
pg_archivecleanup:  removing file "archive/00000001000000370000000F"
pg_archivecleanup:  removing file "archive/00000001000000370000000E"

<application>pg_archivecleanup</application> assumes that <replaceable>archivelocation</replaceable> is a directory readable and writable by the server-owning user. pg_archivecleanupは、archivelocationがサーバを実行しているユーザによって読み書き可能なディレクトリであるものと仮定しています。

オプション

<title>Options</title>

<application>pg_archivecleanup</application> accepts the following command-line arguments: pg_archivecleanupは、以下のコマンドライン引数を受け付けます。

-d

Print lots of debug logging output on <filename>stderr</filename>. stderrに大量のデバッグログを出力します。

-n

Print the names of the files that would have been removed on <filename>stdout</filename> (performs a dry run). 削除されるファイルの名前をstdoutに出力します(実際には削除しません).

-V
--version

Print the <application>pg_archivecleanup</application> version and exit. pg_archivecleanupのバージョンを表示して終了します。

-x extension

Provide an extension that will be stripped from all file names before deciding if they should be deleted. This is typically useful for cleaning up archives that have been compressed during storage, and therefore have had an extension added by the compression program. For example: <literal>-x .gz</literal>. 削除するファイルを決定する前にファイル名から取り除かれる拡張子を指定します。 保存時に圧縮され、そのため圧縮プログラムにより拡張子を付けられたアーカイブを消去するのに特に役に立ちます。 例: -x.gz

-?
--help

Show help about <application>pg_archivecleanup</application> command line arguments, and exit. pg_archivecleanupのコマンドライン引数に関するヘルプを表示して終了します。

環境

<title>Environment</title>

The environment variable <envar>PG_COLOR</envar> specifies whether to use color in diagnostic messages. Possible values are <literal>always</literal>, <literal>auto</literal> and <literal>never</literal>. 環境変数PG_COLORは診断メッセージで色を使うかどうかを指定します。 可能な値はalwaysautoneverです。

注釈

<title>Notes</title>

<application>pg_archivecleanup</application> is designed to work with <productname>PostgreSQL</productname> 8.0 and later when used as a standalone utility, or with <productname>PostgreSQL</productname> 9.0 and later when used as an archive cleanup command. pg_archivecleanupは、PostgreSQL 8.0 とそれ以降において、スタンドアローンユーティリティとして動作するように設計されています。 また、PostgreSQL 9.0 とそれ以降においてはアーカイブのクリーンナップコマンドとして動作するように設計されています。

<application>pg_archivecleanup</application> is written in C and has an easy-to-modify source code, with specifically designated sections to modify for your own needs pg_archivecleanupはC言語で書かれており、必要に応じて修正すべき部分が明確に示されているので、修正の容易なソースコードとなっています。

<title>Examples</title> <para>On Linux or Unix systems, you might use:

LinuxやUnixのシステムでは、以下のように使います。

archive_cleanup_command = 'pg_archivecleanup -d /mnt/standby/archive %r 2>>cleanup.log'

where the archive directory is physically located on the standby server, so that the <varname>archive_command</varname> is accessing it across NFS, but the files are local to the standby. This will: アーカイブディレクトリは物理的にはスタンバイサーバ上に配置されていますので、archive_commandはNFSを経由してアーカイブディレクトリにアクセスしますが、それらのファイルはスタンバイサーバにとってはローカルファイルです。 この設定では、

  • produce debugging output in <filename>cleanup.log</filename> デバッグ出力をcleanup.logに生成します。

  • remove no-longer-needed files from the archive directory アーカイブディレクトリの中から、不要になったファイルを削除します。