[pgsql-jp: 40808] 9.0 でストリーミングレプリケーション使用時のスイッチオーバー
Seiichirou Hiraoka
flathill @ netspring.co.jp
2011年 6月 15日 (水) 11:06:16 JST
平岡です。
PostgreSQL 9.0.4 でストリーミングレプリケーション使用時にスイッチ
オーバーを試みておりますが、
Jun 15 09:24:02 centos-db2 postgres[7939]: [2-1] FATAL: timeline 2 of the primary does not match recovery target timeline 1
のようなエラーが出てスレーブ (旧マスタ) の起動が失敗します。
当方にて試した内容を以下に記載しますので、アドバイス等頂けます
と幸いです。
以下のページ等を参考に設定を試みております。
http://lets.postgresql.jp/documents/technical/replication/1
- 環境
OS: CentOS 5.5
PostgreSQL: 9.0.4
アドレス
. マスタ: 192.168.11.22
. スレーブ: 192.168.11.23
設定ファイル (マスタスレーブ共通)
. postgresql.conf
listen_addresses = '*' # what IP address(es) to listen on;
wal_level = hot_standby # minimal, archive, or hot_standby
archive_mode = on # allows archiving to be done
archive_command = 'cp %p /pgsql/archive/%f' # command to use to archive a logfile segment
max_wal_senders = 2 # max number of walsender processes
wal_keep_segments = 100 # in logfile segments, 16MB each; 0 disables
hot_standby = on # "on" allows queries during recovery
log_destination = 'syslog' # Valid values are combinations of
. pg_hba.conf
host replication postgres 192.168.11.22/32 md5
host replication postgres 192.168.11.23/32 md5
. recovery.conf (スレーブ)
standby_mode = 'on'
primary_conninfo = 'host=192.168.11.23 port=5432 user=postgres password=postgres'
recovery_target_timeline='latest'
restore_command = 'scp 192.168.11.23:/pgsql/archive/%f "%p" 2> /dev/null'
trigger_file = '/pgsql/data/trigger'
. recovery.conf.BAK (マスタ)
standby_mode = 'on'
primary_conninfo = 'host=192.168.11.22 port=5432 user=postgres password=postgres'
recovery_target_timeline='latest'
restore_command = 'scp 192.168.11.22:/pgsql/archive/%f "%p" 2> /dev/null'
trigger_file = '/pgsql/data/trigger'
- 通常運用状態
上記設定でマスタスレーブを起動する事で、ストリーミングレプリケーション
により運用が行えています。
- スイッチオーバー
以下のようにスイッチオーバーを試みます。
1) マスタを停止
2) スレーブに trigger ファイルを作成
3) マスタの recovery.conf.BAK を recovery.conf にリネーム
4) マスタを起動
この状態で、前述の FATAL: エラーが出力されますが、手順に問題はあります
でしょうか。
マスタを停止してスレーブをフェイルオーバーした後、ベースバックアップ
から取り直してマスタを起動すると、FATAL: エラーは出力されず正常に構成
されますが、スイッチオーバー時にベースバックアップの再取得は必要なの
でしょうか。
上記参考ページの説明を見る限りではベースバックアップの再取得は不要
なようですが、別のページでは必要と書かれているものもあったりします。
以上、よろしくお願い致します。
- flathill
pgsql-jp メーリングリストの案内