pgpool2 でレプリケーション
pgpool2 を使って、postgresql のレプリケーションを実施してみた。
環境
次の2つのサーバ共に、postgresql と pgpool2 をインストール
debian squeeze
- postgresql (8.4.7-0squeeze2)
- pgpool2 (1.3.2)
ubuntu marverick
- postgresql (8.4.7-0ubuntu0.10.10)
- pgpool2 (2.3.2.1-0ubuntu1)
必要な設定
- pgpool.conf
- pg_hba.conf
- postgresql.conf
気を付けるべき点は、pg_hba.conf の IPv4 local connections において、
同じマシンからの METHOD は、同じものを指定すること。
つまり、2つのサーバの ip アドレスをそれぞれ hoge, bar とするとき、
hoge マシンの pg_hba.conf を
# IPv4 local connections: host all all 127.0.0.1/32 password host all all bar trust
とするならば、bar マシンの pg_hba.conf は、
# IPv4 local connections: host all all 127.0.0.1/32 trust host all all hoge password
でなければいけない。
これは、pgpool2 が postgres サーバに対し、クエリを発行する際、全てのサーバに対し同じメソッドで通信を行うためである。