はじめに
pcpコマンド使用時に下記のエラーが発生した場合に対処例を記載。
$ pcp_watchdog_info -h localhost -U test_db_user
FATAL: authentication failed for user "test_db_user"
DETAIL: username and/or password does not match
対処例
PCPコマンドを使用するにはユーザ認証が必要になるので、ユーザ名とmd5ハッシュに変換されたパスワードを/etc/pgpool-II/pcp.confファイルに設定する必要がある。
下記例では、ユーザ「test_db_user」に平文のパスワード「test_db_passwd」をmd5に変換してpcp.confに設定している。
$ echo "test_db_user:$(pg_md5 --username=test_db_user test_db_passwd)"
test_db_user:58acbaafa69f725a3a1063a960b93bb1
$ echo "test_db_user:$(pg_md5 --username=test_db_user test_db_passwd)" >> /etc/pgpool-II/pcp.conf
$ pcp_watchdog_info -h localhost -U test_db_user
→ 平文のパスワードを入力
192.168.100.3:9999 Linux test2-server.novalocal 192.168.100.3 9999 9000 7 STANDBY
192.168.100.2:9999 Linux test-server.novalocal 192.168.100.2 9999 9000 4 MASTER
また、pcpコマンドは、-wをつけるとコマンドは.pcppassファイルから読み込むので、パスワード入力をせずに、コマンドの実行が可能。
.pcppassファイルは、環境変数PCPPASSFILEに設定されているファイルパス、または、~/.pcppassとなる。
$ export PCPPASSFILE
$ PCPPASSFILE=/var/lib/pgsql/.pcppass
$ chmod 0600 /var/lib/pgsql/.pcppass
$ pcp_watchdog_info -h localhost -U test_db_user -w