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

pg_recvlogical

pg_recvlogical <refpurpose>control <productname>PostgreSQL</productname> logical decoding streams</refpurpose> PostgreSQLのストリームの論理デコードを制御する

概要

pg_recvlogical [option...]

説明

<title>Description</title>

<command>pg_recvlogical</command> controls logical decoding replication slots and streams data from such replication slots. pg_recvlogicalはレプリケーションスロットの論理デコードを制御し、またレプリケーションスロットからデータを流します。

It creates a replication-mode connection, so it is subject to the same constraints as <xref linkend="app-pgreceivewal"/>, plus those for logical replication (see <xref linkend="logicaldecoding"/>). これはレプリケーションモードの接続をするため、pg_receivewalと同じ制約に加えて、論理レプリケーション(第49章を参照)と同じ制約も受けます。

<command>pg_recvlogical</command> has no equivalent to the logical decoding SQL interface's peek and get modes. It sends replay confirmations for data lazily as it receives it and on clean exit. To examine pending data on a slot without consuming it, use <link linkend="functions-replication"><function>pg_logical_slot_peek_changes</function></link>. pg_recvlogicalには、論理デコードのSQLインタフェースのpeekとgetのモードに対応するものがありません。 データを受信する度、および終了時にダラダラとその再生確認を送信します。 スロット上の未処理のデータを処理せずに検査するには、pg_logical_slot_peek_changesを使用してください。

In the absence of fatal errors, <application>pg_recvlogical</application> will run until terminated by the <systemitem>SIGINT</systemitem> (<keycombo action="simul"><keycap>Control</keycap><keycap>C</keycap></keycombo>) or <systemitem>SIGTERM</systemitem> signal. 致命的なエラーが無い場合、pg_recvlogicalSIGINTControl+C)またはSIGTERMシグナルで停止されるまで実行を続けます。

オプション

<title>Options</title>

At least one of the following options must be specified to select an action: 動作を選択するため、以下のオプションのうち少なくとも1つを指定しなければなりません。

--create-slot

Create a new logical replication slot with the name specified by <option>&#45;-slot</option>, using the output plugin specified by <option>&#45;-plugin</option>, for the database specified by <option>&#45;-dbname</option>. 新しい論理レプリケーションスロットを--slotで指定した名前で、--pluginの出力プラグインを使い、--dbnameで指定したデータベースに対して作成します。

The <option>&#45;-two-phase</option> can be specified with <option>&#45;-create-slot</option> to enable decoding of prepared transactions. --two-phase--create-slotと一緒に指定して、プリペアドトランザクションのデコードを有効にすることができます。

--drop-slot

Drop the replication slot with the name specified by <option>&#45;-slot</option>, then exit. --slotで指定された名前のレプリケーションスロットを削除して、終了します。

--start

Begin streaming changes from the logical replication slot specified by <option>&#45;-slot</option>, continuing until terminated by a signal. If the server side change stream ends with a server shutdown or disconnect, retry in a loop unless <option>&#45;-no-loop</option> is specified. --slotで指定した論理レプリケーションスロットからストリームの変更を開始し、シグナルを受けて終了するまで継続します。 サーバ側の変更ストリームがサーバのシャットダウンまたは接続断によって終了した場合は、--no-loopが指定されていなければ、ループ内でリトライします。

The stream format is determined by the output plugin specified when the slot was created. ストリームのフォーマットは、スロットが作成された時に指定された出力プラグインによって決定されます。

The connection must be to the same database used to create the slot. 接続はスロットの作成時に使用したのと同じデータベースに対してでなければなりません。

<option>&#45;-create-slot</option> and <option>&#45;-start</option> can be specified together. <option>&#45;-drop-slot</option> cannot be combined with another action. --create-slot--startは同時に指定することができます。 --drop-slotは他の動作と組み合わせることができません。

The following command-line options control the location and format of the output and other replication behavior: 以下のコマンド行オプションは出力の場所とフォーマット、およびその他のレプリケーションの動作を制御します。

-E lsn
--endpos=lsn

In <option>&#45;-start</option> mode, automatically stop replication and exit with normal exit status 0 when receiving reaches the specified LSN. If specified when not in <option>&#45;-start</option> mode, an error is raised. --startモードでは、自動的にレプリケーションを停止し、受信が指定のLSNに到達したら正常な終了ステータス0で終了します。 --start以外のモードの時に指定された場合は、エラーが発生します。

If there's a record with LSN exactly equal to <replaceable>lsn</replaceable>, the record will be output. LSNがlsnと正確に一致するレコードがある場合、そのレコードは出力されます。

The <option>&#45;-endpos</option> option is not aware of transaction boundaries and may truncate output partway through a transaction. Any partially output transaction will not be consumed and will be replayed again when the slot is next read from. Individual messages are never truncated. --endposオプションはトランザクションの境界を意識しないため、トランザクションの途中で出力を切り捨てるかもしれません。 部分的に出力されたトランザクションはいずれも処理されず、スロットが次回、読み込まれた時に再び再生されます。 個々のメッセージが切り捨てられることはありません。

-f filename
--file=filename

Write received and decoded transaction data into this file. Use <literal>-</literal> for <systemitem>stdout</systemitem>. 受け取り、デコードしたトランザクションデータをこのファイルに書き込みます。 stdoutに出力するには-を使います。

-F interval_seconds
--fsync-interval=interval_seconds

Specifies how often <application>pg_recvlogical</application> should issue <function>fsync()</function> calls to ensure the output file is safely flushed to disk. 出力ファイルがディスクに安全にフラッシュされることを確実にするため、pg_recvlogicalfsync()の呼び出しを実行する頻度を指定します。

The server will occasionally request the client to perform a flush and report the flush position to the server. This setting is in addition to that, to perform flushes more frequently. サーバはクライアントに対して、フラッシュを実行し、またフラッシュ位置をサーバに報告するように、ときどき要求します。 この設定はそれに加えて、フラッシュをより高頻度で実行するものです。

Specifying an interval of <literal>0</literal> disables issuing <function>fsync()</function> calls altogether, while still reporting progress to the server. In this case, data could be lost in the event of a crash. 0という間隔を指定すると、fsync()の呼び出しをまったく実行しなくなりますが、それでも状況をサーバに報告はします。 この場合、クラッシュするとデータが失われるかもしれません。

-I lsn
--startpos=lsn

In <option>&#45;-start</option> mode, start replication from the given LSN. For details on the effect of this, see the documentation in <xref linkend="logicaldecoding"/> and <xref linkend="protocol-replication"/>. Ignored in other modes. --startモードでは、レプリケーションを指定のLSNから開始します。 この効果の詳細については第49章および55.4を参照してください。 その他のモードでは無視されます。

--if-not-exists

Do not error out when <option>&#45;-create-slot</option> is specified and a slot with the specified name already exists. --create-slotが指定され、指定された名前のスロットが既に存在している場合に、エラーを発生させません。

-n
--no-loop

When the connection to the server is lost, do not retry in a loop, just exit. サーバへの接続が失われたとき、ループ内でリトライせず、単に終了します。

-o name[=value]
--option=name[=value]

Pass the option <replaceable>name</replaceable> to the output plugin with, if specified, the option value <replaceable>value</replaceable>. Which options exist and their effects depends on the used output plugin. オプションnameと(指定されていれば)オプション値valueを出力プラグインに渡します。 存在するオプションとその効果は、利用する出力プラグインに依存します。

-P plugin
--plugin=plugin

When creating a slot, use the specified logical decoding output plugin. See <xref linkend="logicaldecoding"/>. This option has no effect if the slot already exists. スロットを作成するとき、指定された論理デコードの出力プラグインを使います。 第49章を参照してください。 このオプションは、スロットが既に存在する時は、何の効果もありません。

-s interval_seconds
--status-interval=interval_seconds

This option has the same effect as the option of the same name in <xref linkend="app-pgreceivewal"/>. See the description there. このオプションはpg_receivewalの同じ名前のオプションと同じ効果があります。 そちらの説明を参照してください。

-S slot_name
--slot=slot_name

In <option>&#45;-start</option> mode, use the existing logical replication slot named <replaceable>slot_name</replaceable>. In <option>&#45;-create-slot</option> mode, create the slot with this name. In <option>&#45;-drop-slot</option> mode, delete the slot with this name. --startモードでは、slot_nameという名前の既存の論理レプリケーションスロットを使います。 --create-slotでは、この名前のスロットを作成します。 --drop-slotモードでは、この名前のスロットを削除します。

-t
--two-phase

Enables decoding of prepared transactions. This option may only be specified with <option>&#45;-create-slot</option> プリペアドトランザクションのデコードを有効にします。 このオプションは--create-slotでのみ指定できます

-v
--verbose

Enables verbose mode. 冗長モードを有効にします。

The following command-line options control the database connection parameters. 以下のコマンド行オプションはデータベース接続パラメータを制御します。

-d dbname
--dbname=dbname

The database to connect to. See the description of the actions for what this means in detail. The <replaceable>dbname</replaceable> can be a <link linkend="libpq-connstring">connection string</link>. If so, connection string parameters will override any conflicting command line options. Defaults to the user name. 接続するデータベースです。 この意味の詳細は動作の説明を参照してください。 dbname接続文字列でも構いません。 その場合、接続文字列パラメータは衝突するコマンドラインオプションよりも優先します。 デフォルトはユーザ名です。

-h hostname-or-ip
--host=hostname-or-ip

Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. The default is taken from the <envar>PGHOST</envar> environment variable, if set, else a Unix domain socket connection is attempted. サーバが動作しているマシンのホスト名を指定します。 値がスラッシュで始まるときは、Unixドメインソケットのディレクトリとみなされます。 デフォルト値は、環境変数PGHOSTが設定されていればそれが使用され、設定されていなければUnixドメインソケット接続を試みます。

-p port
--port=port

Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the <envar>PGPORT</envar> environment variable, if set, or a compiled-in default. サーバが接続を監視しているTCPポート番号またはローカルのUnixドメインソケットのファイル拡張子を指定します。 デフォルトは環境変数PGPORTが設定されていればそれを使用し、そうでなければコンパイル時に設定されたデフォルト値です。

-U user
--username=user

User name to connect as. Defaults to current operating system user name. 接続で使用するユーザ名です。 デフォルトは現在のOSのユーザ名です。

-w
--no-password

Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a <filename>.pgpass</filename> file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password. パスワード入力を促しません。 サーバがパスワード認証を必要とし、.pgpassファイルなど他の手段によるパスワードが利用できない場合は、接続試行は失敗します。 このオプションはバッチジョブやスクリプトなど、パスワードを入力するユーザがいない場合に有用でしょう。

-W
--password

Force <application>pg_recvlogical</application> to prompt for a password before connecting to a database. pg_recvlogicalがデータベースに接続する前に、強制的にパスワード入力を促します。

This option is never essential, since <application>pg_recvlogical</application> will automatically prompt for a password if the server demands password authentication. However, <application>pg_recvlogical</application> will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing <option>-W</option> to avoid the extra connection attempt. サーバがパスワード認証を要求する場合、pg_recvlogicalは自動的にパスワード入力を促しますから、このオプションは本質的ではありません。 しかし、サーバがパスワードを必要とすることを確認するためにpg_recvlogicalが無駄な接続試行を行うことになります。 無駄な接続試行を避けるために-Wを指定するのが有効になる場合もあるでしょう。

The following additional options are available: この他に、以下のオプションが利用できます。

-V
--version

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

-?
--help

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

終了ステータス

<title>Exit Status</title>

<application>pg_recvlogical</application> will exit with status 0 when terminated by the <systemitem>SIGINT</systemitem> or <systemitem>SIGTERM</systemitem> signal. (That is the normal way to end it. Hence it is not an error.) For fatal errors or other signals, the exit status will be nonzero. pg_recvlogicalSIGINTまたはSIGTERMシグナルで停止されたとき、ステータス0で終了します。 (これは止めるための通常の方法です。 そのためエラーではありません。) 致命的エラーや他のシグナルに対しては、終了ステータスは非ゼロになります。

環境

<title>Environment</title>

This utility, like most other <productname>PostgreSQL</productname> utilities, uses the environment variables supported by <application>libpq</application> (see <xref linkend="libpq-envars"/>). このユーティリティは、他のほとんどのPostgreSQLユーティリティと同様、libpqでサポートされる環境変数を使用します。 (34.15を参照してください)。

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_recvlogical</application> will preserve group permissions on the received WAL files if group permissions are enabled on the source cluster. pg_recvlogicalは、ソースクラスタでグループパーミッションが有効である場合、受け取ったWALファイルのグループパーミッションを維持します。

<title>Examples</title>

See <xref linkend="logicaldecoding-example"/> for an example. 例については49.1を参照してください。

関連項目

<title>See Also</title> pg_receivewal