From 6684b4ea2d0b1a9418280103c491e03ce972c36a Mon Sep 17 00:00:00 2001 From: mikecaat <35882227+mikecaat@users.noreply.github.com> Date: Fri, 26 Aug 2022 10:13:55 +0900 Subject: [PATCH] Add notes to take a backup at standby-site (#223) * Add notes to take a backup at standby-site * Unify 'standby site' to 'standby-site' Co-authored-by: Masahiro Ikeda --- docs/index-ja.html | 24 +++++++++++++++++++----- docs/index.html | 27 +++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/docs/index-ja.html b/docs/index-ja.html index 3d08f97c..f8947cf9 100755 --- a/docs/index-ja.html +++ b/docs/index-ja.html @@ -390,19 +390,33 @@

削除済みバックアップの消去

スタンバイサイトでのバックアップ

-

PostgreSQL 9.0 以降のレプリケーションを利用している場合、スタンバイサイトでバックアップを取得することができます。

+

PostgreSQL 9.0 以降のレプリケーションを利用している場合、スタンバイサイトでもバックアップを取得することができます。 +基本的な使用方法は、単体の PostgreSQL で利用する場合と同様なので、注意が必要な点のみ記述します。

-

スタンバイサイトでのバックアップを行うためには、通常の pg_rman の利用方法と異なるオプションを指定する必要があります。 +

スタンバイサイトでバックアップを取得する場合もアーカイブWALをバックアップ対象にする必要があります。 +共有ディスクなどを用意し、マスタのアーカイブ領域をスタンバイからも参照できるような構成か、 +archive_modeを 'always' として、スタンバイサイトでもアーカイブを出力するような構成にしてください。

-

スタンバイサイトで pg_rman を用いたバックアップを行う使用例を示します。 基本的な使用方法は、単体の PostgreSQL で利用する場合と同様なので、注意が必要な点のみ記述します。

+

後者の構成の場合は、スタンバイ構築時にプライマリに存在するアーカイブWAL(historyファイルを含む)を同期して、 +リストアに必要なファイルを漏れなく、バックアップ出来るようにしてください。また、--keep-arclog-files / --keep-arclog-daysを +利用することでバックアップ時に古いアーカイブを削除することが可能ですが、バックアップ取得対象ではないアーカイブ領域は、 +削除対象にならない点に注意してください。そのため、スタンバイサイトでバックアップを取得する場合は、本オプションを利用しても、 +マスタの古いアーカイブを削除することはできません。 +

-

まず、バックアップカタログの初期化についてです。 -D/--pgdata で指定するものは、スタンバイのデータベースクラスタへのパスとなります。

+

バックアップカタログの初期化時には、-D/--pgdata で、 +スタンバイのデータベースクラスタへのパスを指定してください。

$ pg_rman init -B <バックアップカタログパス> -D <(スタンバイの)PostgreSQLのデータベースクラスタパス>
 
-

スタンバイサイトでバックアップを取得するには、-D/--pgdata オプションでスタンバイサイトのデータベースクラスタを指定し、その他の接続オプション(-d/--dbname-h/--host-p/--port など)でマスタサイトの設定情報を指定します。 スタンバイ接続オプション (--standby-host--standby-port) でスタンバイサイトの設定情報を指定します。--standby-host--standby-port は両方とも指定する必要があります。

+

スタンバイサイトでのバックアップを行うためには、通常の pg_rman の利用方法と異なるオプションを指定する必要があります。 +スタンバイサイトでバックアップを取得するには、-D/--pgdata オプションでスタンバイサイトの +データベースクラスタを指定し、その他の接続オプション(-d/--dbname-h/--host、 +-p/--port など)でマスタサイトの設定情報を指定します。 スタンバイ接続オプション +(--standby-host--standby-port) でスタンバイサイトの設定情報を指定します。--standby-host +と --standby-port は両方とも指定する必要があります。

以下の環境において、スタンバイサイトからバックアップを取得する際のコマンド例を示します。

diff --git a/docs/index.html b/docs/index.html index bd0db359..cf336daa 100755 --- a/docs/index.html +++ b/docs/index.html @@ -379,9 +379,28 @@

Remove deleted backups

Standby-site Backup

-

If you use replication feature on PostgreSQL 9.0 later, you can get backup from standby-site.

+

If you use replication feature on PostgreSQL 9.0 later, you can get backup from standby-site. +The basic usage is the same as when using it with a single master server, so only the points that +need attention are described. +

+ +

Archive WALs must also be taken when you take a backup of the standby-site. +So, you need to prepare a shared disk and so on so that the archive area of the master can be +accessed from the standby, or set archive_mode to 'always' at the standby-site. +

+ +

In the latter case, copy the primary's archive WALs (including history file) +when the standby-site is created to make sure that you can take back up all the files required for restoring. +You can delete old archive WALs at the time of backup using --keep-arclog-files / --keep-arclog-days. +But, since the deletion target is only the one which it take a backup, the master's archived WALs +are not deleted if you take a backup at standby-site. +

-

You should specify different options from usual use for getting backup from standby-site. In detail, you should specify the database cluster on standby-site by -D/--pgdata option. And you should specify information on master-site by connection options (-d/--dbname, -h/--host, -p/--port). In addition, you should specify information to connect standby-site by standby connection options (--standby-host, --standby-port).

+

You should specify different options from usual use for getting backup from standby-site. +In detail, you should specify the database cluster on standby-site by -D/--pgdata option. +And you should specify information on master-site by connection options (-d/--dbname, +-h/--host, -p/--port). In addition, you should specify information +to connect standby-site by standby connection options (--standby-host, --standby-port).

$ pg_rman init -B <a backup catalog path> -D <(the database cluster path(on standby-site)>
 
@@ -396,7 +415,7 @@

Standby-site Backup

  • the database cluster path of standby-site: /home/postgres/pgdata_sby
  • -

    Then, the backup from standby site can be done with the below command:

    +

    Then, the backup from standby-site can be done with the below command:

    $ pg_rman backup --pgdata=/home/postgres/pgdata_sby --backup-mode=full --host=master --standby-host=localhost --standby-port=5432
     
    @@ -744,7 +763,7 @@

    Connection options

    Standby connection options

    -

    Parameters to connect standby server. They are used only when you get backup from the standby site.

    +

    Parameters to connect standby server. They are used only when you get backup from the standby-site.