確認したいこと
- pcp_detach_node -g で既存セッションに影響なくバックエンドのDBを切り離せるか
- デタッチ実行後に新規にクエリに振分けられ、セッションがなくなるまでデタッチされない
- pcp_detach_node だと強制的にデタッチされるが既存セッションに影響がある
手順
while :
do
pgbench -Sn -c 10 -j 10 -t 10000 -U awsuser -h localhost -d postgres -p 9999
done
- Pgpool-II に接続して、バックエンドのDBインスタンスを確認する
$ psql "host=localhost dbname=postgres port=9999 user=awsuser"
postgres=> show pool_nodes;
node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | r
eplication_state | replication_sync_state | last_status_change
---------+---------------------------------------------------------------------------------------------+------+--------+-----------+---------+------------+-------------------+-------------------+--
-----------------+------------------------+---------------------
0 | aurora-postgres124.cluster-********.ap-northeast-1.rds.amazonaws.com | 5432 | up | 0.000000 | primary | 6 | false | 0 |
| | 2021-09-29 04:35:21
1 | aurora-postgres124-instance-1-ap-northeast-1a.********.ap-northeast-1.rds.amazonaws.com | 5432 | up | 0.500000 | standby | 256822 | true | 0 |
| | 2021-09-29 04:35:21
2 | reader2.********.ap-northeast-1.rds.amazonaws.com | 5432 | up | 0.500000 | standby | 246942 | false | 0 |
| | 2021-09-29 05:03:07
(3 行)
- Pgpool-II でバックエンドのDBインスタンスを切り離す
- 実行後も "show pool_nodes" で確認すると、select_cnt が増えていく
$ pcp_detach_node -U pgpool -h localhost -n 2 -g
- Pgpool-II でクエリの発行状況を確認する
- 接続しぱなしだとPgpool-IIから切り離されいので、切断する
postgres=> show pool_nodes;
node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay | r
eplication_state | replication_sync_state | last_status_change
---------+---------------------------------------------------------------------------------------------+------+--------+-----------+---------+------------+-------------------+-------------------+--
-----------------+------------------------+---------------------
0 | aurora-postgres124.cluster-********.ap-northeast-1.rds.amazonaws.com | 5432 | up | 0.000000 | primary | 8 | false | 0 |
| | 2021-09-29 04:35:21
1 | aurora-postgres124-instance-1-ap-northeast-1a.********.ap-northeast-1.rds.amazonaws.com | 5432 | up | 0.500000 | standby | 321493 | true | 0 |
| | 2021-09-29 04:35:21
2 | reader2.********.ap-northeast-1.rds.amazonaws.com | 5432 | up | 0.500000 | standby | 311211 | false | 0 |
| | 2021-09-29 05:03:07
(3 行)
postgres=> \q
参考
$ pcp_attach_node -U pgpool -h localhost -n 1