简单了解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

相关内容

热门资讯

江西第一封高考录取通知书送达!... 来源:江南都市报 江南都市报全媒体记者章娜前几日,江西省教育考试院发布了2025年普通高校招生提前本...
大城县举办听力健康公益义诊活动  栏目名称:《廊坊新闻》首播频道:新闻综合频道首播时间:19:40重播时间:22:00 次日10:0...
恋爱谈多久,可以谈婚论嫁? 恋爱谈多久,可以谈婚论嫁?大半年。这样的时间是很合理的。可以让你了解对方,可以保证婚姻的稳定。两年左...
一年关店1078家!这个曾经暴... 来源:品牌观察官营收涨了、利润也涨了,但门店却“哗哗”关掉了上千家!曾经门店狂飙、开店比便利店还快的...
资深专业机构投资者认定标准细化...   7月13日,上交所发布《发行上市审核规则适用指引第8号——资深专业机构投资者》(简称《资深专业机...
清凉书海度盛夏,南京江北图书馆... 转自:扬子晚报七月的周末热浪翻涌,南京江北图书馆内却坐满了读者,近2000个阅览座席在一座难求。家长...
我国最大盆地,超高压电力环网贯... 转自:中国能源报4197公里“能量环”!我国最大盆地超高压电力环网贯通。历时15年建设,总长4197...
上交所就发布实施进一步深化科创...   来源:上交所发布  为了落实《中国证监会关于在科创板设置科创成长层 增强制度包容性适应性的意见》...
集齐王牌开战!马斯克Space... 当地时间周六,马斯克旗下航天公司SpaceX向xAI注资20亿美元的消息传出,这已是马斯克近期在AI...