简单了解pgpool

简单了解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 nodes
                         part of the watchdog cluster
  -d, --debug            enable debug message (optional)
  -v, --verbose          output verbose messages
  -?, --help             print this help
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yang_z_1

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值