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

pg_checksums

pg_checksums <refpurpose>enable, disable or check data checksums in a <productname>PostgreSQL</productname> database cluster</refpurpose> PostgreSQLデータベースクラスタのデータチェックサムを有効化、無効化、あるいは検査する。

概要

pg_checksums [option...] [[ -D | --pgdata ]datadir]

説明

<title>Description</title>

<application>pg_checksums</application> checks, enables or disables data checksums in a <productname>PostgreSQL</productname> cluster. The server must be shut down cleanly before running <application>pg_checksums</application>. When verifying checksums, the exit status is zero if there are no checksum errors, and nonzero if at least one checksum failure is detected. When enabling or disabling checksums, the exit status is nonzero if the operation failed. pg_checksumsPostgreSQLクラスタのデータチェックサムの検査と有効化、無効化を行います。 pg_checksumsを実行する前にサーバは正常停止されていなければなりません。 チェックサムを検査する場合、終了ステータスはチェックサム誤りが無ければゼロで、チェックサム誤りが一つでも在ったなら非ゼロです。 チェックサムの有効化、無効化をする場合、終了ステータスは操作に失敗したときに非ゼロになります。

When verifying checksums, every file in the cluster is scanned. When enabling checksums, each relation file block with a changed checksum is rewritten in-place. Disabling checksums only updates the file <filename>pg_control</filename>. チェックサムを検査する場合、クラスタ内の各ファイルがスキャンされます。 チェックサムの有効化では、チェックサムが変更されたすべてのリレーションファイルブロックがその場で書き換えられます。 チェックサムの無効化では、ファイルpg_controlだけ更新されます。

オプション

<title>Options</title>

The following command-line options are available: 以下のコマンドラインオプションが使用できます。

-D directory
--pgdata=directory

Specifies the directory where the database cluster is stored. データベースクラスタが格納されているディレクトリを指定します。

-c
--check

Checks checksums. This is the default mode if nothing else is specified. チェックサムを検査します。 これは何も指定しなかった場合のデフォルトのモードです。

-d
--disable

Disables checksums. チェックサムを無効化します。

-e
--enable

Enables checksums. チェックサムを有効化します。

-f filenode
--filenode=filenode

Only validate checksums in the relation with filenode <replaceable>filenode</replaceable>. 指定したファイルノードfilenodeのリレーション内のチェックサムだけを検査します。

-N
--no-sync

By default, <command>pg_checksums</command> will wait for all files to be written safely to disk. This option causes <command>pg_checksums</command> to return without waiting, which is faster, but means that a subsequent operating system crash can leave the updated data directory corrupt. Generally, this option is useful for testing but should not be used on a production installation. This option has no effect when using <literal>&#45;-check</literal>. pg_checksumsはデフォルトでは全てのファイルが安全にディスクに書かれるまで待ちます。 このオプションは、pg_checksumsがこれを待たずに応答するようにします。より早いですが、直後のオペレーティングシステムのクラッシュで更新されたデータディレクトリの破損が残る可能性があることを意味します。 一般に、このオプションはテストには有用ですが、本番導入むけには使うべきではありません。 --checkを使う場合には、このオプションは効果がありません。

-P
--progress

Enable progress reporting. Turning this on will deliver a progress report while checking or enabling checksums. 進行報告を有効にします。 これを有効にするとチェックサムの検査あるいは有効化で、進行報告が出力されます。

-v
--verbose

Enable verbose output. Lists all checked files. 冗長な出力を有効にします。 チェックした全ファイルの一覧を出力します。

-V
--version

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

-?
--help

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

環境

<title>Environment</title>
PGDATA

Specifies the directory where the database cluster is stored; can be overridden using the <option>-D</option> option. データベースクラスタが格納されたディレクトリを指定します。 これに対して-Dオプションで上書き指定できます。

PG_COLOR

Specifies whether to use color in diagnostic messages. Possible values are <literal>always</literal>, <literal>auto</literal> and <literal>never</literal>. 対話的メッセージで色を使用するかを指定します。 指定可能な値はalwaysautoneverです。

注釈

<title>Notes</title>

Enabling checksums in a large cluster can potentially take a long time. During this operation, the cluster or other programs that write to the data directory must not be started or else data loss may occur. 大きいクラスタでチェックサムを有効にするには、場合によっては長時間を要する可能性があります。 この操作中にデータディレクトリに書き込みをするクラスタや他のプログラムを開始してはいけません。さもないとでデータ損失が起きるかもしれません。

When using a replication setup with tools which perform direct copies of relation file blocks (for example <xref linkend="app-pgrewind"/>), enabling or disabling checksums can lead to page corruptions in the shape of incorrect checksums if the operation is not done consistently across all nodes. When enabling or disabling checksums in a replication setup, it is thus recommended to stop all the clusters before switching them all consistently. Destroying all standbys, performing the operation on the primary and finally recreating the standbys from scratch is also safe. リレーションファイルブロックの直接コピーを行うツール(例えばpg_rewind)でレプリケーションのセットアップを使う時のチェックサムの有効化や無効化は、操作が全ノードを通して一貫して行われない場合、不正なチェックサムという形でページ破損を引き起こすおそれがあります。 したがって、レプリケーションのセットアップでチェックサムの有効化や無効化をするときには、一貫して切り替える前にすべてのクラスタを停止することを推奨します。 全てのスタンバイを廃棄して、プライマリ上で操作を行い、最後にスタンバイを新たに再作成するのも安全です。

If <application>pg_checksums</application> is aborted or killed while enabling or disabling checksums, the cluster's data checksum configuration remains unchanged, and <application>pg_checksums</application> can be re-run to perform the same operation. チェックサムの有効化や無効化をしている最中にpg_checksumsが中断されたり、killされたりした場合、クラスタのデータチェックサム設定は変更されないままとなり、pg_checksumsを同じ操作を再実行できます。