pgpool-II導入してみた(コネクションプールモード)

①インストール
[root@node1 ~]# yum install http://www.pgpool.net/yum/rpms/4.0/redhat/rhel-7-x86_64/pgpool-II-release-4.0-1.noarch.rpm ★①
読み込んだプラグイン:fastestmirror, langpacks
pgpool-II-release-4.0-1.noarch.rpm | 5.2 kB 00:00:00
/var/tmp/yum-root-kLrXQ2/pgpool-II-release-4.0-1.noarch.rpm を調べています: pgpool-II-release-4.0-1.noarch
/var/tmp/yum-root-kLrXQ2/pgpool-II-release-4.0-1.noarch.rpm をインストール済みとして設定しています
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ pgpool-II-release.noarch 0:4.0-1 を インストール
--> 依存性解決を終了しました。
base/7/x86_64 | 3.6 kB 00:00:00
extras/7/x86_64 | 3.4 kB 00:00:00
ol7_UEKR5/x86_64 | 2.5 kB 00:00:00
ol7_UEKR5/x86_64/updateinfo | 27 kB 00:00:00
ol7_UEKR5/x86_64/primary_db | 3.9 MB 00:00:00
pgdg10/7/x86_64 | 3.6 kB 00:00:00
pgdg10/7/x86_64/primary_db | 243 kB 00:00:00
pgdg11/7/x86_64 | 3.6 kB 00:00:00
pgdg11/7/x86_64/primary_db | 204 kB 00:00:00
pgdg94/7/x86_64 | 3.6 kB 00:00:00
pgdg94/7/x86_64/primary_db | 280 kB 00:00:00
pgdg95/7/x86_64 | 3.6 kB 00:00:00
pgdg95/7/x86_64/primary_db | 268 kB 00:00:00
pgdg96/7/x86_64 | 3.6 kB 00:00:00
pgdg96/7/x86_64/primary_db | 269 kB 00:00:00
updates/7/x86_64 | 3.4 kB 00:00:00
updates/7/x86_64/primary_db | 5.7 MB 00:00:00

依存性を解決しました

==========================================================================================================================================================================================================================================
Package アーキテクチャー バージョン リポジトリー 容量
==========================================================================================================================================================================================================================================
インストール中:
pgpool-II-release noarch 4.0-1 /pgpool-II-release-4.0-1.noarch 2.2 k

トランザクションの要約
==========================================================================================================================================================================================================================================
インストール 1 パッケージ

合計容量: 2.2 k
インストール容量: 2.2 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
インストール中 : pgpool-II-release-4.0-1.noarch 1/1
検証中 : pgpool-II-release-4.0-1.noarch 1/1

インストール:
pgpool-II-release.noarch 0:4.0-1

完了しました!
[root@node1 ~]# yum install -y pgpool-II-pg11.x86_64 pgpool-II-pg11-debuginfo.x86_64 pgpool-II-pg11-devel.x86_64 pgpool-II-pg11-extensions.x86_64 ★②
読み込んだプラグイン:fastestmirror, langpacks
pgpool40 | 1.3 kB 00:00:00
pgpool40/7/x86_64/primary | 23 kB 00:00:00
Determining fastest mirrors
* base: ftp.riken.jp
* extras: ftp.riken.jp
* updates: ftp.riken.jp
pgpool40 183/183
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ pgpool-II-pg11.x86_64 0:4.0.5-1pgdg.rhel7 を インストール
--> 依存性の処理をしています: libmemcached.so.11()(64bit) のパッケージ: pgpool-II-pg11-4.0.5-1pgdg.rhel7.x86_64
---> パッケージ pgpool-II-pg11-debuginfo.x86_64 0:4.0.5-1pgdg.rhel7 を インストール
---> パッケージ pgpool-II-pg11-devel.x86_64 0:4.0.5-1pgdg.rhel7 を インストール
---> パッケージ pgpool-II-pg11-extensions.x86_64 0:4.0.5-1pgdg.rhel7 を インストール
--> トランザクションの確認を実行しています。
---> パッケージ libmemcached.x86_64 0:1.0.16-5.el7 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

==========================================================================================================================================================================================================================================
Package アーキテクチャー バージョン リポジトリー 容量
==========================================================================================================================================================================================================================================
インストール中:
pgpool-II-pg11 x86_64 4.0.5-1pgdg.rhel7 pgpool40 1.2 M
pgpool-II-pg11-debuginfo x86_64 4.0.5-1pgdg.rhel7 pgpool40 1.9 M
pgpool-II-pg11-devel x86_64 4.0.5-1pgdg.rhel7 pgpool40 17 k
pgpool-II-pg11-extensions x86_64 4.0.5-1pgdg.rhel7 pgpool40 41 k
依存性関連でのインストールをします:
libmemcached x86_64 1.0.16-5.el7 base 237 k

トランザクションの要約
==========================================================================================================================================================================================================================================
インストール 4 パッケージ (+1 個の依存関係のパッケージ)

総ダウンロード容量: 3.4 M
インストール容量: 17 M
Downloading packages:
(1/5): libmemcached-1.0.16-5.el7.x86_64.rpm | 237 kB 00:00:00
(2/5): pgpool-II-pg11-debuginfo-4.0.5-1pgdg.rhel7.x86_64.rpm | 1.9 MB 00:00:02
(3/5): pgpool-II-pg11-devel-4.0.5-1pgdg.rhel7.x86_64.rpm | 17 kB 00:00:00
(4/5): pgpool-II-pg11-4.0.5-1pgdg.rhel7.x86_64.rpm | 1.2 MB 00:00:03
(5/5): pgpool-II-pg11-extensions-4.0.5-1pgdg.rhel7.x86_64.rpm | 41 kB 00:00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
合計 1.0 MB/s | 3.4 MB 00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
インストール中 : libmemcached-1.0.16-5.el7.x86_64 1/5
インストール中 : pgpool-II-pg11-4.0.5-1pgdg.rhel7.x86_64 2/5
インストール中 : pgpool-II-pg11-extensions-4.0.5-1pgdg.rhel7.x86_64 3/5
インストール中 : pgpool-II-pg11-devel-4.0.5-1pgdg.rhel7.x86_64 4/5
インストール中 : pgpool-II-pg11-debuginfo-4.0.5-1pgdg.rhel7.x86_64 5/5
検証中 : libmemcached-1.0.16-5.el7.x86_64 1/5
検証中 : pgpool-II-pg11-extensions-4.0.5-1pgdg.rhel7.x86_64 2/5
検証中 : pgpool-II-pg11-debuginfo-4.0.5-1pgdg.rhel7.x86_64 3/5
検証中 : pgpool-II-pg11-devel-4.0.5-1pgdg.rhel7.x86_64 4/5
検証中 : pgpool-II-pg11-4.0.5-1pgdg.rhel7.x86_64 5/5

インストール:
pgpool-II-pg11.x86_64 0:4.0.5-1pgdg.rhel7 pgpool-II-pg11-debuginfo.x86_64 0:4.0.5-1pgdg.rhel7 pgpool-II-pg11-devel.x86_64 0:4.0.5-1pgdg.rhel7 pgpool-II-pg11-extensions.x86_64 0:4.0.5-1pgdg.rhel7

依存性関連をインストールしました:
libmemcached.x86_64 0:1.0.16-5.el7

完了しました! ★
[root@node1 ~]#
[root@node1 ~]# pgpool -v ★yum完了した後、このコマンドによりインストールが成功したかを確認する
pgpool-II version 4.0.5 (torokiboshi)
[root@node1 ~]# mkdir /var/log/pgpool ★pgpoolの起動ログを格納する箇所を用意する(systemctl start pgpool.serviceコマンドで起動する場合、Linuxのmessageにログが出力されます)
[root@node1 ~]# chown postgres:postgres /var/log/pgpool/ ★適切に権限を与える
[root@node1 ~]# cd /etc/pgpool-II/ ★/etc/pgpool-IIフォルダーに遷移する
[root@node1 ~]# vi /etc/pgpool-II/pool_passwd ★pool_passwdファイルを作成する
[root@node1 pgpool-II]# ll
合計 212
-rwxrw-r--. 1 root root 858 5月 15 16:38 pcp.conf
-rwxrw-r--. 1 root root 40632 6月 11 17:13 pgpool.conf
-rw-r--r--. 1 root root 39335 5月 15 16:38 pgpool.conf.sample-logical
-rw-r--r--. 1 root root 40567 5月 15 16:38 pgpool.conf.sample-master-slave
-rw-r--r--. 1 root root 40515 5月 15 16:38 pgpool.conf.sample-replication
-rw-r--r--. 1 root root 40588 5月 15 16:38 pgpool.conf.sample-stream
-rwxrw-r--. 1 root root 3277 5月 15 16:38 pool_hba.conf
-rw-r--r--. 1 root root 2 6月 11 17:13 pool_passwd ★作成された
[root@node1 pgpool-II]# chown postgres:postgres /etc/pgpool-II/pool_passwd ★適切に権限を与える
[root@node1 pgpool-II]# pg_md5 -m -u testuser testuser
[root@node1 pgpool-II]# pg_md5 -m -u postgres postgres ★接続用のユーザにパスワードを用意する
[root@node1 pgpool-II]# cat pool_passwd


testuser:md5d70a0452418aeb8fb4030eae69ca2856
postgres:md53175bce1d3201d16594cebf9d7eb3f9d ★
[root@node1 pgpool-II]# vi pgpool.conf ★pgpool.confを最低限に編集する
[root@node1 pgpool-II]# egrep -i 'backend_|connection_cache|num_init_children|max_pool' pgpool.conf ★
# num_init_children * listen_backlog_multiplier.
backend_hostname0 = 'localhost' ★触ったもの
backend_port0 = 5432 ★
backend_weight0 = 1 ★
backend_data_directory0 = '/var/lib/pgsql/11/data' ★
backend_flag0 = 'ALLOW_TO_FAILOVER' ★
#backend_hostname1 = 'host2'
#backend_port1 = 5433
#backend_weight1 = 1
#backend_data_directory1 = '/data1'
#backend_flag1 = 'ALLOW_TO_FAILOVER'
enable_pool_hba = off ★
num_init_children = 32 ★
max_pool = 4 ★
connection_cache = on ★
failover_on_backend_error = on
root@node1 pgpool-II]# pgpool -n -d > /var/log/pgpool/pgpool.log 2>&1 & ★pgpoolを起動させる
[1] 23702
[root@node1 pgpool-II]# cat /var/log/pgpool/pgpool.log ★相関のログはこれ
2019-06-12 10:36:46: pid 23702: DEBUG: initializing pool configuration
2019-06-12 10:36:46: pid 23702: DETAIL: num_backends: 1 total_weight: 1.000000
2019-06-12 10:36:46: pid 23702: DEBUG: initializing pool configuration
2019-06-12 10:36:46: pid 23702: DETAIL: backend 0 weight: 2147483647.000000 flag: 0000
2019-06-12 10:36:46: pid 23702: DEBUG: pool_coninfo_size: num_init_children (32) * max_pool (4) * MAX_NUM_BACKENDS (128) * sizeof(ConnectionInfo) (136) = 2228224 bytes requested for shared memory
2019-06-12 10:36:46: pid 23702: DEBUG: ProcessInfo: num_init_children (32) * sizeof(ProcessInfo) (32) = 1024 bytes requested for shared memory
2019-06-12 10:36:46: pid 23702: DEBUG: Request info are: sizeof(POOL_REQUEST_INFO) 5264 bytes requested for shared memory
2019-06-12 10:36:46: pid 23702: DEBUG: Recovery management area: sizeof(int) 4 bytes requested for shared memory
2019-06-12 10:36:46: pid 23702: LOG: memory cache initialized
2019-06-12 10:36:46: pid 23702: DETAIL: memcache blocks :64
2019-06-12 10:36:46: pid 23702: DEBUG: memory cache request size : 67108864
2019-06-12 10:36:46: pid 23702: LOG: pool_discard_oid_maps: discarded memqcache oid maps
2019-06-12 10:36:46: pid 23702: LOG: Setting up socket for 0.0.0.0:9999
2019-06-12 10:36:46: pid 23702: LOG: Setting up socket for :::9999
2019-06-12 10:36:46: pid 23708: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23709: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23704: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23705: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23706: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23707: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23710: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23711: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23702: DEBUG: find_primary_node_repeatedly: not in streaming replication mode
2019-06-12 10:36:46: pid 23712: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23713: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23714: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23715: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23723: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23725: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23726: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23728: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23731: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23724: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23720: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23716: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23717: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23718: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23719: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23722: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23727: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23729: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23732: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23721: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23730: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23734: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23736: DEBUG: I am PCP child with pid:23736
2019-06-12 10:36:46: pid 23737: DEBUG: I am 23737
2019-06-12 10:36:46: pid 23737: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23702: LOG: pgpool-II successfully started. version 4.0.5 (torokiboshi)
2019-06-12 10:36:46: pid 23733: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23738: DEBUG: I am health check process pid:23738 DB node id:0
2019-06-12 10:36:46: pid 23738: DEBUG: initializing backend status
2019-06-12 10:36:46: pid 23735: DEBUG: initializing backend status

②postgres DB 側
[root@node1 ~]# su - postgres ★postgresユーザへ遷移
最終ログイン: 2019/06/03 (月) 23:21:56 JST日時 pts/2
-bash-4.2$ export PATH=/usr/pgsql-11/bin:$PATH ★環境変数を設定する
-bash-4.2$ export PGDATA=/var/lib/pgsql/11/data ★環境変数を設定する
-bash-4.2$ cd /var/lib/pgsql/11/data ★環境変数を設定する
-bash-4.2$ cat pg_hba.conf
# PostgreSQL Client Authentication Configuration File
# ===================================================
#
# Refer to the "Client Authentication" section in the PostgreSQL
# documentation for a complete description of this file. A short
# synopsis follows.
#
<省略>

# TYPE DATABASE USER ADDRESS METHOD

# "local" is for Unix domain socket connections only
local testdb testuser trust
local all postgres trust
local all all peer
# IPv4 local connections:
#host all all 127.0.0.1/32 ident
host all all ::1/128 trust ★localhost用の接続エントリはこれ
host testdb postgres 192.168.56.0/24 trust
# IPv6 local connections:
#host all all ::1/128 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
#host replication all 127.0.0.1/32 ident
#host replication all ::1/128 ident
-bash-4.2$ pg_ctl start ★起動させる
サーバの起動完了を待っています....2019-06-11 17:17:52.743 JST [3925] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2019-06-11 17:17:52.743 JST [3925] LOCATION: StreamServerPort, pqcomm.c:593
2019-06-11 17:17:52.743 JST [3925] LOG: 00000: listening on IPv6 address "::", port 5432
2019-06-11 17:17:52.743 JST [3925] LOCATION: StreamServerPort, pqcomm.c:593
2019-06-11 17:17:52.750 JST [3925] LOG: 00000: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2019-06-11 17:17:52.750 JST [3925] LOCATION: StreamServerPort, pqcomm.c:587
2019-06-11 17:17:52.758 JST [3925] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2019-06-11 17:17:52.758 JST [3925] LOCATION: StreamServerPort, pqcomm.c:587
2019-06-11 17:17:52.947 JST [3925] LOG: 00000: redirecting log output to logging collector process
2019-06-11 17:17:52.947 JST [3925] HINT: Future log output will appear in directory "log".
2019-06-11 17:17:52.947 JST [3925] LOCATION: SysLogger_Start, syslogger.c:668
完了
サーバ起動完了
-bash-4.2$ psql -h localhost -p 5432 -U postgres -d testdb ★5432ポートでも接続できる(pgpool経由しなく)
psql (11.3)
"help" でヘルプを表示します。

testdb=# \q
-bash-4.2$ psql -h localhost -p 9999 -U postgres -d testdb ★9999ポートでも接続できる(pgpool経由する)
psql (11.3)
"help" でヘルプを表示します。

testdb=# \q

③pgpool経由する場合のプロセス状況
[root@node1 pgpool-II]# ps -ef | egrep -i 'pgpool|postgres'
root 3847 3805 0 6月11 pts/1 00:00:00 su - postgres
postgres 3848 3847 0 6月11 pts/1 00:00:00 -bash
root 25077 3314 0 11:13 pts/0 00:00:00 pgpool -n -d
root 25079 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25080 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25081 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25082 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25083 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25084 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25085 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25086 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25087 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25088 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25089 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25090 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25091 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25092 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25093 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25094 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25095 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25096 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25097 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25098 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25099 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25100 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25101 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25102 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25103 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25104 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25105 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25106 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25107 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25108 25077 0 11:13 pts/0 00:00:00 pgpool: postgres testdb ::1(45453) idle
root 25109 25077 0 11:13 pts/0 00:00:00 pgpool: postgres testdb ::1(45449) idle
root 25110 25077 0 11:13 pts/0 00:00:00 pgpool: postgres testdb ::1(45447) idle
root 25111 25077 0 11:13 pts/0 00:00:00 pgpool: PCP: wait for connection request
root 25112 25077 0 11:13 pts/0 00:00:00 pgpool: worker process
root 25113 25077 0 11:13 pts/0 00:00:00 pgpool: health check process(0)
postgres 25116 1 0 11:13 pts/1 00:00:00 /usr/pgsql-11/bin/postgres
postgres 25117 25116 0 11:13 ? 00:00:00 postgres: pg11: logger
postgres 25119 25116 0 11:13 ? 00:00:00 postgres: pg11: checkpointer
postgres 25120 25116 0 11:13 ? 00:00:00 postgres: pg11: background writer
postgres 25121 25116 0 11:13 ? 00:00:00 postgres: pg11: walwriter
postgres 25122 25116 0 11:13 ? 00:00:00 postgres: pg11: autovacuum launcher
postgres 25123 25116 0 11:13 ? 00:00:00 postgres: pg11: archiver
postgres 25124 25116 0 11:13 ? 00:00:00 postgres: pg11: stats collector
postgres 25125 25116 0 11:13 ? 00:00:00 postgres: pg11: logical replication launcher
postgres 25127 25116 0 11:13 ? 00:00:00 postgres: pg11: postgres testdb ::1(43737) idle
postgres 25258 3848 0 11:22 pts/1 00:00:00 psql -h localhost -p 9999 -U postgres -d testdb ★9999ポートでの接続①
root 25338 25295 0 11:23 pts/2 00:00:00 su - postgres
postgres 25339 25338 0 11:23 pts/2 00:00:00 -bash
postgres 25409 25339 0 11:24 pts/2 00:00:00 psql -h localhost -p 9999 -U postgres -d testdb ★9999ポートでの接続②
postgres 25410 25116 0 11:24 ? 00:00:00 postgres: pg11: postgres testdb ::1(43743) idle
root 25530 25493 0 11:25 pts/3 00:00:00 su - postgres
postgres 25531 25530 0 11:25 pts/3 00:00:00 -bash
postgres 25594 25531 0 11:25 pts/3 00:00:00 psql -h localhost -p 9999 -U postgres -d testdb ★9999ポートでの接続③
postgres 25595 25116 0 11:25 ? 00:00:00 postgres: pg11: postgres testdb ::1(43747) idle
root 25666 25629 0 11:26 pts/4 00:00:00 su - postgres
postgres 25667 25666 0 11:26 pts/4 00:00:00 -bash
postgres 25730 25667 0 11:26 pts/4 00:00:00 psql -h localhost -p 5432 -U postgres -d testdb ★5432ポートでの接続
postgres 25731 25116 0 11:26 ? 00:00:00 postgres: pg11: postgres testdb ::1(43749) idle
root 25734 3314 0 11:26 pts/0 00:00:00 grep -E --color=auto -i pgpool|postgres
[root@node1 pgpool-II]# netstat -nal|grep 9999
tcp 0 0 127.0.0.1:9999 0.0.0.0:* LISTEN
tcp6 0 0 ::1:9999 :::* LISTEN
tcp6 0 0 ::1:9999 ::1:45447 ESTABLISHED
tcp6 0 0 ::1:45449 ::1:9999 ESTABLISHED
tcp6 0 0 ::1:9999 ::1:45449 ESTABLISHED
tcp6 0 0 ::1:45447 ::1:9999 ESTABLISHED
tcp6 0 0 ::1:45453 ::1:9999 ESTABLISHED
tcp6 0 0 ::1:9999 ::1:45453 ESTABLISHED
unix 2 [ ACC ] STREAM LISTENING 118593 /tmp/.s.PGSQL.9999
[root@node1 pgpool-II]# netstat -nal|grep 5432
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN
tcp6 0 0 :::5432 :::* LISTEN
tcp6 0 0 ::1:43749 ::1:5432 ESTABLISHED
tcp6 0 0 ::1:43737 ::1:5432 ESTABLISHED
tcp6 0 0 ::1:5432 ::1:43737 ESTABLISHED
tcp6 0 0 ::1:5432 ::1:43743 ESTABLISHED
tcp6 0 0 ::1:5432 ::1:43749 ESTABLISHED
tcp6 0 0 ::1:43743 ::1:5432 ESTABLISHED
tcp6 0 0 ::1:5432 ::1:43747 ESTABLISHED
tcp6 0 0 ::1:43747 ::1:5432 ESTABLISHED
unix 2 [ ACC ] STREAM LISTENING 118614 /var/run/postgresql/.s.PGSQL.5432
unix 2 [ ACC ] STREAM LISTENING 118616 /tmp/.s.PGSQL.5432
<省略>
root 25666 25629 0 11:26 pts/4 00:00:00 su - postgres
postgres 25667 25666 0 11:26 pts/4 00:00:00 -bash
postgres 25862 25667 0 11:30 pts/4 00:00:00 psql -p 5432 -U postgres -d testdb ★「-h localhost」を指定しく、直接接続する場合
postgres 25863 25116 0 11:30 ? 00:00:00 postgres: pg11: postgres testdb [local] idle ★プロセスがこれ
root 25865 3314 0 11:30 pts/0 00:00:00 grep -E --color=auto -i pgpool|postgres
<省略>
[root@node1 pgpool-II]# ps -ef | egrep -i 'pgpool|postgres'
root 3847 3805 0 6月11 pts/1 00:00:00 su - postgres
postgres 3848 3847 0 6月11 pts/1 00:00:00 -bash
root 25077 3314 0 11:13 pts/0 00:00:00 pgpool -n -d
root 25079 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25080 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25081 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25082 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25083 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25084 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25085 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25086 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25087 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25088 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25089 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25090 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25091 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25092 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25093 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25094 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25095 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25096 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25097 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25098 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25099 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25100 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25101 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25102 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25103 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25104 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25105 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25106 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25107 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25108 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25109 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25110 25077 0 11:13 pts/0 00:00:00 pgpool: wait for connection request
root 25111 25077 0 11:13 pts/0 00:00:00 pgpool: PCP: wait for connection request
root 25112 25077 0 11:13 pts/0 00:00:00 pgpool: worker process
root 25113 25077 0 11:13 pts/0 00:00:00 pgpool: health check process(0)
postgres 25116 1 0 11:13 pts/1 00:00:00 /usr/pgsql-11/bin/postgres
postgres 25117 25116 0 11:13 ? 00:00:00 postgres: pg11: logger
postgres 25119 25116 0 11:13 ? 00:00:00 postgres: pg11: checkpointer
postgres 25120 25116 0 11:13 ? 00:00:00 postgres: pg11: background writer
postgres 25121 25116 0 11:13 ? 00:00:00 postgres: pg11: walwriter
postgres 25122 25116 0 11:13 ? 00:00:00 postgres: pg11: autovacuum launcher
postgres 25123 25116 0 11:13 ? 00:00:00 postgres: pg11: archiver
postgres 25124 25116 0 11:13 ? 00:00:00 postgres: pg11: stats collector
postgres 25125 25116 0 11:13 ? 00:00:00 postgres: pg11: logical replication launcher
postgres 25127 25116 0 11:13 ? 00:00:00 postgres: pg11: postgres testdb ::1(43737) idle ★
root 25338 25295 0 11:23 pts/2 00:00:00 su - postgres
postgres 25339 25338 0 11:23 pts/2 00:00:00 -bash
postgres 25410 25116 0 11:24 ? 00:00:00 postgres: pg11: postgres testdb ::1(43743) idle ★
root 25530 25493 0 11:25 pts/3 00:00:00 su - postgres
postgres 25531 25530 0 11:25 pts/3 00:00:00 -bash
postgres 25595 25116 0 11:25 ? 00:00:00 postgres: pg11: postgres testdb ::1(43747) idle ★
root 25666 25629 0 11:26 pts/4 00:00:00 su - postgres
postgres 25667 25666 0 11:26 pts/4 00:00:00 -bash
postgres 25985 25116 0 11:40 ? 00:00:00 postgres: pg11: postgres testdb ::1(43759) idle ★psqlでの接続が終了しても、postgresqlへの接続プロセスの数は減らない。
root 26022 3314 0 11:40 pts/0 00:00:00 grep -E --color=auto -i pgpool|postgres
[root@node1 pgpool-II]#