Pgpool提供了一些维护工具,用于日常观察Pgpool运行状态、上线、下线节点等操作。主要有:pcp_stop_pgpool,pcp_node_count,pcp_node_info,pcp_health_check_stats,pcp_proc_count,pcp_proc_info,pcp_detach_node,pcp_attach_node,pcp_recovery_node,pcp_promote_node,pcp_pool_status,pcp_watchdog_info,pcp_reload_config,本篇介绍它们的使用方法。
pcp_recovery_node
用于恢复从节点,主要用于集群新建时创建新的从节点或者恢复失效节点。
[postgres@db01 bin]$ pcp_recovery_node--helppcp_recovery_node - recover a nodeUsage: pcp_recovery_node [OPTION...] [node-id] Options: -U, --username=NAME username for PCP authentication -h, --host=HOSTNAME pgpool-II host -p, --port=PORT PCP port number -w, --no-password never prompt for password -W, --password force password prompt (should happen automatically) -n, --node-id=NODEID ID of a backend node-d, --debug enable debug message (optional) -v, --verbose output verbose messages -?, --help print this help 比如要恢复1号节点: pcp_recovery_node -U pgpool -n1
pcp_attach_node
用于将一个Pgpool节点添加到集群中,比如由于种种原因(Pgpool非正常退出、本节点PostgreSQL服务终止)导致用show pool_nodes发现某个从节点未加入集群,可以使用此命令将该从节点重新加入到集群中。
[postgres@db01 bin]$ pcp_attach_node--helppcp_attach_node - attach a node from pgpool-II Usage: pcp_attach_node [OPTION...] [node-id] Options: -U, --username=NAME username for PCP authentication -h, --host=HOSTNAME pgpool-II host -p, --port=PORT PCP port number -w, --no-password never prompt for password -W, --password force password prompt (should happen automatically) -n, --node-id=NODEID ID of a backend node-d, --debug enable debug message (optional) -v, --verbose output verbose messages -?, --help print this help
pcp_detach_node
从Pgpool集群中移除指定节点
[postgres@db01 bin]$ pcp_detach_node--helppcp_detach_node - detach a node from pgpool-II Usage: pcp_detach_node [OPTION...] [node-id] Options: -U, --username=NAME username for PCP authentication -h, --host=HOSTNAME pgpool-II host -p, --port=PORT PCP port number -w, --no-password never prompt for password -W, --password force password prompt (should happen automatically) -n, --node-id=NODEID ID of a backend node-g, --gracefully promote gracefully (optional) -d, --debug enable debug message (optional) -v, --verbose output verbose messages -?, --help print this help
pcp_stop_pgpool
停止Pgpool,可停止某一个节点或者整个集群
[postgres@db01 bin]$ pcp_stop_pgpool--helppcp_stop_pgpool - terminate pgpool-II Usage: pcp_stop_pgpool [OPTION...] Options: -U, --username=NAME username for PCP authentication -h, --host=HOSTNAME pgpool-II host -p, --port=PORT PCP port number -w, --no-password never prompt for password -W, --password force password prompt (should happen automatically) -m, --mode=MODE MODE can be "smart", "fast", or "immediate"-s, --scope=SCOPE SCOPE can be "cluster", or "local" cluster scope do operations on all Pgpool-II nodes part of the watchdog cluster -d, --debug enable debug message (optional) -v, --verbose output verbose messages -?, --help print this help
pcp_promote_node
提升指定节点为新的主节点或者将指定节点切换成主节点
[postgres@db01 bin]$ pcp_promote_node--helppcp_promote_node - promote a node as new main from pgpool-II Usage: pcp_promote_node [OPTION...] [node-id] Options: -U, --username=NAME username for PCP authentication -h, --host=HOSTNAME pgpool-II host -p, --port=PORT PCP port number -w, --no-password never prompt for password -W, --password force password prompt (should happen automatically) -n, --node-id=NODEID ID of a backend node-g, --gracefully promote gracefully (optional) -s, --switchover switchover primary to specified node (optional) -d, --debug enable debug message (optional) -v, --verbose output verbose messages -?, --help print this help
pcp_reload_config
不重启重新加载Pgpool配置,对于一些需要重启的配置无效
[postgres@db01 bin]$ pcp_reload_config--helppcp_reload_config - reload a pgpool-II config file Usage: pcp_reload_config [OPTION...] Options: -U, --username=NAME username for PCP authentication -h, --host=HOSTNAME pgpool-II host -p, --port=PORT PCP port number -w, --no-password never prompt for password -W, --password force password prompt (should happen automatically) -s, --scope=SCOPE SCOPE can be "cluster", or "local" cluster scope do operations on all Pgpool-II nodes part of the watchdog cluster -d, --debug enable debug message (optional) -v, --verbose output verbose messages -?, --help print this help
pcp_node_count
显示当前Pgpool集群节点数
[postgres@db01 bin]$ pcp_node_count--helppcp_node_count - display the total number of nodes under pgpool-II's controlUsage:pcp_node_count [OPTION...]Options: -U, --username=NAME username for PCP authentication -h, --host=HOSTNAME pgpool-II host -p, --port=PORT PCP port number -w, --no-password never prompt for password -W, --password force password prompt (should happen automatically) -d, --debug enable debug message (optional) -v, --verbose output verbose messages -?, --help print this help[postgres@db01 bin]$ pcp_node_count -U pgpoolPassword:3
pcp_node_info
显示Pgpool集群节点信息
[postgres@db01 bin]$ pcp_node_info-U pgpool Password: db01 543220.333333 up up standby standby 0 none none 2023-10-2911:49:50 db02 543220.333333 up up primary primary 0 none none 2023-11-0412:10:47 db03 543220.333333 up up standby standby 0 none none 2023-10-2911:49:50
pcp_health_check_stats
检查集群指定节点的健康状况
[postgres@db01 bin]$ pcp_health_check_stats-U pgpool -n1Password: 1 db02 5432 up primary 2023-11-0412:10:47 1917301917300000.000000 02188.978762 2023-11-0914:35:32 2023-11-0914:35:32
pcp_proc_count
列出当前节点Pgpool进程
[postgres@db01 bin]$ pcp_proc_count-U pgpool Password: 179878518418111858699188351918746061876627189506618601021874790186612618659671865968187510918252851890730188195218251241833024185823618766301832026184181218241491875313189272818659641874477184183818503591879288187531018255661892244187544318335271875106186612818941131875440189272918650801885068185900618587051865965187828418418201893414189411018828361833525186589818850691892060184565618418051833551185826218589521846022189188018753161891881188234118666471892245180751018753141875928189224618746071891883180820918948551875925185870218492411891070187908018605901810460185900018927221841821184183918583771883522188234218740611882418189095418835231875929189272518753111890727189349718582391860108188282118920631890637189206417989951825569187908118744781816679187510718413981894858182493318824361893417189206118941111874791189072818759261866147189188418581311849638185813218850711876624189272618920661891073187929118792891875452186589918620431882338187510318753151885070187929018918851883520187530718590041876625186010918754441892067188507218766281860591189273018456591866480184135118616691878285182572618766311890638187446218824371875317187545317921671882822189134318661291862044187593018740621892723186011018906391891071186010518605931891074181046118744791893498181596818835241890955186838918683961842410185900118770091848652184132818920651892260184246018747921859007188234318587061891886189134418582631874438189188818948591875454188301518744631865969189107218252171848653187511017668691858455187510418920681874608187510518770101894114188301618922611868390187663218496431882419188301718766261858608187908218823391866648187531218828231860595186013118754451875927184605118907291874459184579118490211858379181670018920621890731184436518252861891889188195318824201860106184902318753081824148187530918413291876629189272418835211894115187443918918821894860181548218751111862045189341818582411874464189226218590051860107189272718423851895067186590018601041858707184184318934151891345188283718948561881954189341618666491891890186013218650821858701188507318907321875108186614918605921893419186648118419611874460187406318251261879292189107518934991858082185900218460231868393188283818252631875446185870418423861848124187446118503611877011187531818782861875441184182218948571890956182526018754421882438184115418941121882340189506818582381825730186667518744401879293
pcp_proc_info
显示当前节点每个Pgpool进程状态
dbname username 2023-11-0911:46:26 (2:09 before process restarting) 4302023-11-0912:21:37 2023-11-0913:23:18 02023-11-0913:53:00 31818622017987850 Wait for connection dbname username 2023-11-0911:46:26 (2:09 before process restarting) 4302023-11-0912:21:37 2023-11-0913:23:18 02023-11-0913:53:00 31125518017987851 Wait for connection dbname username 2023-11-0911:46:26 (2:09 before process restarting) 4302023-11-0912:21:37 2023-11-0913:23:18 02023-11-0913:53:00 31468486017987852 Wait for connection
pcp_pool_status
显示Pgpool集群配置及状态
[postgres@db01 bin]$ pcp_pool_status-U pgpool Password: name : backend_clustering_mode value: 1desc : clustering mode name : listen_addresses value: * desc : host name(s) or IP address(es) to listen on name : port value: 9999desc : pgpool accepting port number name : unix_socket_directories value: /tmp desc : pgpool socket directories
pcp_watchdog_info
显示Pgpool看门狗状态
[postgres@db01 bin]$ pcp_watchdog_info-U pgpool Password: 33 YES db01:9999 Linux db01 db01 db01:9999 Linux db01 db01 999990004 LEADER 0 MEMBER db02:9999 Linux db02 db02 999990007 STANDBY 0 MEMBER db03:9999 Linux db03 db03 999990007 STANDBY 0 MEMBER