Doc: enhance online recovery document.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 22 Jan 2021 06:05:33 +0000 (15:05 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 22 Jan 2021 06:09:38 +0000 (15:09 +0900)
Add explanation what should be done in the recovery first stage and
second stage. Also add mention about snapshot isolation mode where
native replication mode is explained.

Remove accidentally left caution of script timeout in the Japanese
document.

doc.ja/src/sgml/online-recovery.sgml
doc/src/sgml/online-recovery.sgml

index eccee78ca765de7ab53fbe3cc21f0fcbdb7557e3..c0f1fa050662b8b6ba9366ccd770305f660569a3 100644 (file)
   -->
   オンラインリカバリは2段階に分けて実施されます。
   第1段階は「ファーストステージ」、第2段階は「セカンドステージ」と呼ばれます。
-  それぞれのステージ用にスクリプトを用意する必要があります。
-  <xref linkend="guc-replication-mode">の時のみセカンドステージが必要です。
+  <xref linkend="guc-replication-mode">あるいは<xref linkend="guc-snapshot-isolation-mode">の時のみセカンドステージが必要です。
    ストリーミングレプリケーションモードを含むその他のモードでは、セカンドステージは実施されず、<xref linkend="guc-recovery-2nd-stage-command">用のスクリプトを用意する必要はありません。
     つまり、そのエントリを空文字にしておいても問題ありません。
-    これらのスクリプトの例は<xref linkend="example-cluster-pgpool-config-online-recovery">にあります。
+ </para>
+
+ <para>
+  ファーストステージでは、<productname>PostgreSQL</productname>の<command>pg_baseback</command>コマンドなどを利用してメイン(プライマリ)ノードのバックアップコピーからレプリカ(スタンバイ)ノードを作ります。
+  ファーストステージ中に更新されたデータは<productname>PostgreSQL</productname>のトランザクションログに記録されます。
+ </para>
+ <para>
+  セカンドステージでは、リカバリ対象のレプリカノードを起動します。
+  この時にトランザクションログが再生され、このレプリカノードは完全にメインノードと同期します。
+ </para>
+ <para>
+  それぞれのステージ用にスクリプトを用意する必要があります。
+  完全なサンプルスクリプトが<ulink url="https://git.postgresql.org/gitweb/?p=pgpool2.git;a=blob_plain;f=src/sample/scripts/recovery_1st_stage.sample;hb=refs/heads/master">/etc/pgpool-II/recovery_1st_stage.sample</ulink>および<ulink url="https://git.postgresql.org/gitweb/?p=pgpool2.git;a=blob_plain;f=src/sample/scripts/recovery_2nd_stage.sample;hb=refs/heads/master">/etc/pgpool-II/recovery_2nd_stage.sample</ulink>に用意されています。
+  これらのスクリプトを使ったインストール例は<xref linkend="example-cluster-pgpool-config-online-recovery">にあります。
  </para>
  <para>
   <!--
     <!--
     Wait until all client connections have disconnected.
     -->
-    全てのクライアント接続が切断されるまで待機(<xref linkend="guc-replication-mode">のみ)。
+    å\85¨ã\81¦ã\81®ã\82¯ã\83©ã\82¤ã\82¢ã\83³ã\83\88æ\8e¥ç¶\9aã\81\8cå\88\87æ\96­ã\81\95ã\82\8cã\82\8bã\81¾ã\81§å¾\85æ©\9fï¼\88<xref linkend="guc-replication-mode">ã\81\82ã\82\8bã\81\84ã\81¯<xref linkend="guc-snapshot-isolation-mode">ã\81®ã\81¿ï¼\89ã\80\82
    </para>
   </listitem>
   <listitem>
    <para>
-    CHECKPOINT(<xref linkend="guc-replication-mode">のみ)。
+    CHECKPOINT.
    </para>
   </listitem>
   <listitem>
     <!--
     Second stage of online recovery.
     -->
-    オンラインリカバリのセカンドステージ(<xref linkend="guc-replication-mode">のみ)。
+    ã\82ªã\83³ã\83©ã\82¤ã\83³ã\83ªã\82«ã\83\90ã\83ªã\81®ã\82»ã\82«ã\83³ã\83\89ã\82¹ã\83\86ã\83¼ã\82¸ï¼\88<xref linkend="guc-replication-mode">ã\81\82ã\82\8bã\81\84ã\81¯<xref linkend="guc-snapshot-isolation-mode">ã\81®ã\81¿ï¼\89ã\80\82
    </para>
   </listitem>
   <listitem>
    only one of them will have received the online recovery command and will
    block the connections from clients.
    -->
-   <xref linkend="guc-replication-mode">でのオンラインリカバリには制限事項があります。
+   <xref linkend="guc-replication-mode">ã\81\82ã\82\8bã\81\84ã\81¯<xref linkend="guc-snapshot-isolation-mode">ã\81§ã\81®ã\82ªã\83³ã\83©ã\82¤ã\83³ã\83ªã\82«ã\83\90ã\83ªã\81«ã\81¯å\88¶é\99\90äº\8bé \85ã\81\8cã\81\82ã\82\8aã\81¾ã\81\99ã\80\82
     <productname>Pgpool-II</productname>が複数のホストにインストールされている場合、<productname>Pgpool-II</productname>はオンラインリカバリの2ndステージの間全てのクライアントを止める必要があるため、オンラインリカバリは正しく動作しません。
     複数の<productname>Pgpool-II</productname>ホストがある場合、そのうちの1台のみがオンラインリカバコマンドを受け取り、クライアントからの接続をブロックします。
   </para>
      </para>
     </note>
 
-    <caution>
-     <para>
-      <!--
-      <varname>recovery_1st_stage command</varname> runs as a <acronym>SQL</acronym>
-      command from <productname>PostgreSQL</>'s point of view. Therefore, <varname>recovery_1st_stage_command
-     </varname> can get prematuraly killed by <productname>PostgreSQL</> if
-      <varname>statement_timeout</varname> is configured with the value that is
-      smaller than the time <varname>recovery_1st_stage_command</varname> takes for
-      completion.
-      -->
-      <varname>recovery_1st_stage_command</varname>は、<productname>PostgreSQL</>から見ると、一つの<acronym>SQL</acronym>として実行されます。
-      そのため、<productname>PostgreSQL</>の<varname>statement_timeout</varname>が<varname>recovery_1st_stage_command</varname>の完了にかかる時間よりも短く設定されていると、<varname>recovery_1st_stagecommand</varname>コマンドの実行が途中でキャンセルされます。
-     </para>
-     <para>
-      <!--
-      Typical error in such case is
-      -->
-      典型的なエラーは以下のようなものです。
-      <programlisting>
-       rsync used in the command is killed by signal 2 for example.
-      </programlisting>
-     </para>
-    </caution>
-
     <para>
      <!--
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
      try to execute <command>$PGDATA/sync-command</command>.
      -->
      オンラインリカバリのセカンドステージでメインノードで実行されるコマンドを指定します。
-     これは<xref linkend="guc-replication-mode">時のみ必要であるため、他のモードではコマンドファイルを用意する必要はありません。
+     これは<xref linkend="guc-replication-mode">あるいは<xref linkend="guc-snapshot-isolation-mode">時のみ必要であるため、他のモードではコマンドファイルを用意する必要はありません。
       コマンドファイルはセキュリティ上の観点からデータベースクラスタ内に配置される必要があります。
       例えば、<varname>recovery_2nd_stage_command</varname> = <literal>'sync-command'</literal>となっている場合、<productname>Pgpool-II</productname>はコマンドスクリプトを<literal>$PGDATA</literal>ディレクトリの中で探し、<command>$PGDATA/sync-command</command>を起動しようとします。
     </para>
      </para>
     </note>
 
-    <caution>
-     <para>
-      <!--
-      <varname>recovery_2nd_stage command</varname> runs as a <acronym>SQL</acronym>
-      command from PostgreSQL's point of view. Therefore, <varname>recovery_2nd_stage command
-     </varname> can get prematuraly killed by PostgreSQL if the PostgreSQL's
-      <varname>statement_time_out</varname> is configured with the value that is
-      smaller than the time <varname>recovery_2nd_stage_command</varname> takes for
-      completion.
-      -->
-      <varname>recovery_2nd_stage_command</varname>は、<productname>PostgreSQL</>から見ると、一つの<acronym>SQL</acronym>として実行されます。
-      そのため、<productname>PostgreSQL</>の<varname>statement_timeout</varname>が<varname>recovery_2nd_stage_command</varname>の完了にかかる時間よりも短く設定されていると、<varname>recovery_1st_stagecommand</varname>コマンドの実行が途中でキャンセルされます。
-     </para>
-    </caution>
-
     <para>
      <!--
      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
index 98e7aee28e56b440d21a1309d6f00017daa164cc..ba1af9590f89b403a54f4c9254976941cc50721b 100644 (file)
  <para>
   Online recovery is performed in two phases. The first phase is
   called "first stage" and the second phase is called "second
-  stage". You need to provide scripts for each
-  stage. Only <xref linkend="guc-replication-mode"> requires the
-   second stage.  For other modes including streaming replication
-   mode the second stage is not performed and you don't need to
-   provide a script for the stage
-   in <xref linkend="guc-recovery-2nd-stage-command">. i.e. you can
-    safely leave it as an empty string. Those scripts example can be found in
-    <xref linkend="example-cluster-pgpool-config-online-recovery">.
+  stage". Only <xref linkend="guc-replication-mode"> and <xref
+  linkend="guc-snapshot-isolation-mode"> require the second stage.
+  For other modes including streaming replication mode the second
+  stage is not performed and you don't need to provide a script for
+  the stage in <xref
+  linkend="guc-recovery-2nd-stage-command">. i.e. you can safely leave
+  it as an empty string.
  </para>
+
+ <para>
+  In the first stage the standby (replica) node is created by using
+  <productname>PostgreSQL</productname>'s
+  <command>pg_basebackup</command>, for example, from a backup of the
+  main (primary) node. Update data while executing the first stage
+  will be logged into the <productname>PostgreSQL</productname>'s
+  transaction log.
+ </para>
+
+ <para>
+  In the second stage the target recovery node is started. The
+  transaction log will be replayed and the replica node will be
+  completely synced with the master node.
+ </para>
+
+ <para>
+  You need to provide scripts for each stage.  Complete sample scripts
+  are provided at <ulink
+  url="https://git.postgresql.org/gitweb/?p=pgpool2.git;a=blob_plain;f=src/sample/scripts/recovery_1st_stage.sample;hb=refs/heads/master">/etc/pgpool-II/recovery_1st_stage.sample</ulink>
+  and <ulink
+  url="https://git.postgresql.org/gitweb/?p=pgpool2.git;a=blob_plain;f=src/sample/scripts/recovery_2nd_stage.sample;hb=refs/heads/master">/etc/pgpool-II/recovery_2nd_stage.sample</ulink>.
+  Example installation using those scripts can be found in <xref
+  linkend="example-cluster-pgpool-config-online-recovery">.
+ </para>
+
  <para>
   Connections from clients are not allowed only in the second stage
   while the data can be updated or retrieved during the first stage.
   </listitem>
   <listitem>
    <para>
-    Wait until all client connections have disconnected (only
-    in <xref linkend="guc-replication-mode">).
+    Wait until all client connections have disconnected (only in <xref
+    linkend="guc-replication-mode"> and <xref
+    linkend="guc-snapshot-isolation-mode">).
    </para>
   </listitem>
   <listitem>
    <para>
-    CHECKPOINT (only in <xref linkend="guc-replication-mode">).
-     specified).
+    CHECKPOINT (only in <xref linkend="guc-replication-mode"> and
+  <xref linkend="guc-snapshot-isolation-mode">).
    </para>
   </listitem>
   <listitem>
    <para>
-    Execute second stage of online recovery (only
-    in <xref linkend="guc-replication-mode">).
+    Execute second stage of online recovery (only in <xref
+    linkend="guc-replication-mode"> and <xref
+    linkend="guc-snapshot-isolation-mode">).
    </para>
   </listitem>
   <listitem>