Pgpool-II EC2 インスタンス
$ sudo yum -y install gcc
$ sudo yum install -y postgresql postgresql-server postgresql-devel postgresql-contrib postgresql-docs
$ psql "host=aurora-postgres117.cluster-******.ap-northeast-1.rds.amazonaws.com user=awsuser dbname=writer port=5432"
$ wget www.pgpool.net/download.php?f=pgpool-II-4.1.3.tar.gz
$ tar xfvz pgpool-II-4.1.3.tar.gz
$ cd pgpool-II-4.1.3
$ ./configure
$ make
$ sudo make install
$ sudo mkdir /var/run/pgpool
$ sudo mkdir /var/log/pgpool
$ sudo chown postgres:postgres /var/log/pgpool/
$ sudo chown postgres:postgres /var/run/pgpool/
$ sudo touch /usr/local/etc/pool_passwd
$ sudo chown postgres:postgres /usr/local/etc/pool_passwd
- /etc/pgpool-II/pgpool.conf で接続設定
listen_addresses = '*'
backend_hostname0 = 'aurora-postgres117.cluster-******.ap-northeast-1.rds.amazonaws.com'
backend_port0 = 5432
$ cd /etc/pgpool-II/
$ sudo pg_md5 --md5auth --username=awsuer password123
$ sudo cat pool_passwd
awsuer:md5***
$ sudo cp -p /usr/lib/systemd/system/pgpool.service /etc/systemd/system/
$ sudo systemctl enable pgpool.service
$ sudo systemctl is-enabled pgpool.service
enabled
$ sudo systemctl start pgpool.service
$ sudo systemctl status pgpool.service
接続確認
$ psql "host=localhost user=awsuser dbname=writer port=9999"
pgbench
$ vi ~/.pgpass
$ vi chmod 600 ~/.pgpass
aurora-postgres117.cluster-******.ap-northeast-1.rds.amazonaws.com:5432:writer:awsuser:******
aurora-postgres117.cluster-ro-******.ap-northeast-1.rds.amazonaws.com:5432:writer:awsuser:******
172.**.*.165:9999:writer:awsuser:******
$ sudo yum -y install postgresql postgresql-contrib
$ pgbench -i -s 100 -U awsuser -h aurora-postgres117.cluster-******.ap-northeast-1.rds.amazonaws.com -d writer
$ pgbench -r -c 2 -j 2 -t 1000 -U awsuser -h aurora-postgres117.cluster-******.ap-northeast-1.rds.amazonaws.com -d writer
$ pgbench -r -c 2 -j 2 -t 1000 -U awsuser -h 172.**.*.165 -d writer -p 9999