LoginSignup
0
0

More than 3 years have passed since last update.

PostgreSQL12レプリケーション周りの変更点

Posted at

はじめに

PostgreSQL バージョン12で変更となった、レプリケーションの設定方法を備忘録として記載しておく。
今回の記事では、単純なレプリケーション構成に使われるパラメータのみスコープとしている。

変更点

これまでレプリケーションの設定を記載していたrecovery.confが廃止され、パラメータはpostgresql.confへ統合された。

変更されたパラメータ

パラメータ名 備考
standby_mode 廃止
primary_conninfo postgresql.confへ統合
pprimary_slot_name postgresql.confへ統合
promote_trigger_file postgresql.confへ統合
旧バージョンでの名称はtrigger_file

変更後のpostgresql.conf

postgresql.conf
#------------------------------------------------------------------------------
# REPLICATION
#------------------------------------------------------------------------------
...
# - Standby Servers -

# These settings are ignored on a master server.

#primary_conninfo = ''                  # connection string to sending server
                                        # (change requires restart)
#primary_slot_name = ''                 # replication slot on sending server
                                        # (change requires restart)
#promote_trigger_file = ''              # file name whose presence ends recovery

注意点

pg_basebackupのオプション

これまでpg_basebackupコマンドでスタンバイサーバの構築を行う際、オプション -Rを指定することでrecovery.confファイルを生成していた。
recovery.conf廃止に伴い、今後はこのオプションが必要無くなるのかと思いきやそうではない。
バージョン12からは、-Rオプションを指定するとstandby.signalというシグナルファイルが生成される。(touchコマンドで後から生成することも可能。)
このシグナルファイルが存在することよりスタンバイサーバとして起動する。
シグナルファイルが存在しない場合、プライマリサーバとして起動してしまうため注意が必要。

recovery.conf存在時のエラー

バージョン12からは、recovery.confファイルが存在すると下記エラーが発生し、起動自体出来なくなるので注意が必要。

$ pg_ctl start
...
LOG:  database system was shut down at 2020-03-15 05:47:55 JST
FATAL:  using recovery command file "recovery.conf" is not supported
LOG:  startup process (PID 30440) exited with exit code 1
LOG:  aborting startup due to startup process failure
LOG:  database system is shut down
...
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0