简单了解pgpool
创始人
2024-06-03 09:49:56
0

简单了解pgpool

文章目录

  • 简单了解pgpool
  • PGPOOL-II特点
  • PGPOOL 常用命令
      • pcp_recovery_node
      • pcp_promote_node
      • pcp_detach_node
      • pcp_attach_node
      • pcp_node_count
      • pcp_node_info
      • pcp_pool_status
      • pcp_proc_count
      • pcp_proc_info
      • pcp_stop_pgpool

在这里插入图片描述

PGPOOL-II特点

1.连接池

pgpool-II保存已经连接到服务器的连接,并在使用相同参数(例如:用户名,数据库) 连接进来时重用它们。它减少了连接开销,并增加了系统的总体吞吐量

2.故障切换

如果其中一台数据库服务器出现故障或无法访问,则Pgpool-II会将其分离,并将继续使用其余的数据库服务器进行操作。

3.复制

pgpool-II可以管理多个PostgreSQL 服务器。激活复制功能可以在两个或多个PostgreSQL群集上创建实时备份,如果其中一台节点失效,服务可以不被中断继续运行。

4.负载均衡

当数据运行在复制模式或主备模式下,pgpool能够将查询语句分散到集群的各个数据库中

5.在线还原

Pgpool-II可以通过执行一个命今来执行数据库节点的联机恢复。

6.限制超过限度的连接

PostgreSQL会限制当前的最大连接数,当到达这个数量时,新的连接将被拒绝。

1.3 工作模式

1.原始模式

这种模式ppoo1不负责后端数据库数据同步,只实现一个故障切换功能,数据库的数据同步由用户负责,这种模式不支持负载均衡。

2.主备模式

使用其他软件完成数据的数据复制,

如slony或流复制,中间件层使用

PgPool-II式,Pgpool-II提供高可用和连接池的功能。

3.连接池模式

在此模式下,除了原始模式的功能外,还实现连接池功能。

4.复制模式

这种模式下pgpool负责后端数据库数据同步,pepool节点上的写操作需等待所有后端数据库将数据写入后才向客户端返回成功,是强同步复制方式,这种模式支持负载均衡。

1.5 watchdog 作用

和pgpool后端postgresql数据库节点以及远程pgpool节点进行通讯。
对远程pgpool节点是否存活进行检查
当watchdog子进程启动时,对本地pgpool的配置和远程pgpool的配置参数进行检查,并且输出本地和远程pgpool不一致的参数。
当pgpool主节点宕机时,Watchdog集群将选举出新的Watchdog主节点。
当pgpool备节点激活成主节点时,Watchdog负责将vvip移植到新的pgpool节点

PGPOOL 常用命令

pcp_recovery_node

执行在线恢复

pcp_recovery_node -v -d -h 10.10.3.100 -p 9898 -U postgres -n 1

[root@pg1 pgpool-II]# pcp_recovery_node --help
pcp_recovery_node - recover a node
Usage:
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

pcp_promote_node

从 pgpool 提升一个节点

pcp_promote_node -v -d -h 192.168.56.100 -p 9898 -U pgpool -n 1

[root@pg1 pgpool-II]# pcp_promote_node --help
pcp_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_detach_node

从 pgpool 分离一个节点

pcp_detach_node -n 1 -U pgpool

[root@pg1 pgpool-II]# pcp_detach_node --help
pcp_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_attach_node

给 pgpool 关联一个节点

pcp_attach_node -v -d -n 1 -U pgpool

执行 pcp_attach_node 命令后,用 show pool_nodes 查看节点时会看到 status=waiting。此时需要退出所有的连接,再登录时就是 up 了。

[root@pg1 pgpool-II]# pcp_attach_node --help
pcp_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_node_count

获取 pgpool 节点数量

pcp_node_count -v -d -U pgpool

[root@pg1 pgpool-II]# pcp_node_count --help
pcp_node_count - display the total number of nodes under pgpool-II's control
Usage:
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

pcp_node_info

获取 pgpool 节点信息

pcp_node_info -v -d -n 0 -U pgpool

[root@pg1 pgpool-II]# pcp_node_info --help
pcp_node_info - display a pgpool-II node's information
Usage:
pcp_node_info [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)-n, --node-id=NODEID   ID of a backend node-a, --all              display all backend nodes information-d, --debug            enable debug message (optional)-v, --verbose          output verbose messages-?, --help             print this help

pcp_pool_status

获取 pgpool 的连接池状态

pcp_pool_status -v -d -U pgpool

[root@pg1 pgpool-II]# pcp_pool_status --help
pcp_pool_status - display pgpool configuration and status
Usage:
pcp_pool_status [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

pcp_proc_count

获取 pgpool 进程列表

pcp_proc_count -v -d -U pgpool

[root@pg12 pgpool-II]# pcp_proc_count --help
pcp_proc_count - display the list of pgpool-II child process PIDs
Usage:
pcp_proc_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

pcp_proc_info

获取 pgpool 进程信息

pcp_proc_info -v -d -U pgpool

[root@pg12 pgpool-II]# pcp_proc_info --help
pcp_proc_info - display a pgpool-II child process' information
Usage:
pcp_proc_info [OPTION...] [process-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)-P, --process-id=PID   PID of the child process to get information for (optional)-a, --all              display all child processes and their available connection slots-d, --debug            enable debug message (optional)-v, --verbose          output verbose messages-?, --help             print this help

pcp_stop_pgpool

停止 pgpool

pcp_stop_pgpool -v -d -U pgpool

[root@pg12 pgpool-II]# pcp_stop_pgpool --help
pcp_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 nodespart of the watchdog cluster-d, --debug            enable debug message (optional)-v, --verbose          output verbose messages-?, --help             print this help

相关内容

热门资讯

中证A500ETF摩根(560... 8月22日,截止午间收盘,中证A500ETF摩根(560530)涨1.19%,报1.106元,成交额...
A500ETF易方达(1593... 8月22日,截止午间收盘,A500ETF易方达(159361)涨1.28%,报1.104元,成交额1...
何小鹏斥资约2.5亿港元增持小... 每经记者|孙磊    每经编辑|裴健如 8月21日晚间,小鹏汽车发布公告称,公司联...
中证500ETF基金(1593... 8月22日,截止午间收盘,中证500ETF基金(159337)涨0.94%,报1.509元,成交额2...
中证A500ETF华安(159... 8月22日,截止午间收盘,中证A500ETF华安(159359)涨1.15%,报1.139元,成交额...
科创AIETF(588790)... 8月22日,截止午间收盘,科创AIETF(588790)涨4.83%,报0.760元,成交额6.98...
创业板50ETF嘉实(1593... 8月22日,截止午间收盘,创业板50ETF嘉实(159373)涨2.61%,报1.296元,成交额1...
港股异动丨航空股大幅走低 中国... 港股航空股大幅下跌,其中,中国国航跌近7%表现最弱,中国东方航空跌近5%,中国南方航空跌超3%,美兰...
电网设备ETF(159326)... 8月22日,截止午间收盘,电网设备ETF(159326)跌0.25%,报1.198元,成交额409....
红利ETF国企(530880)... 8月22日,截止午间收盘,红利ETF国企(530880)跌0.67%,报1.034元,成交额29.0...