我的两台 postgresql 服务器配置为流式复制,运行良好。
Pgpool 配置为主从模式/负载平衡模式。
pgpool.conf:
listen_addresses = '*'
port = 9999
backend_hostname0 = 'master-postgres-ip'
backend_port0 = port-no
backend_weight0 = 1
backend_data_directory0 = 'data-dir'
backend_hostname1 = 'slave-postgres-ip'
backend_port1 = port-no
backend_weight1 = 1
backend_data_directory1 = 'data-dir'
load_balance_mode = on
master_slave_mode = on
master_slave_sub_mode='stream'
我预计所有的写查询都将转到主查询,而读查询将分布在两者之间。但是,所有的查询都只会掌握。但是,如果我停止 master,查询将成为奴隶。
有人可以告诉我可能出了什么问题吗?
pgpool 在启动时给出以下日志:
2015-11-03 17:25:56: pid 21284: LOG: find_primary_node: checking backend no 0
2015-11-03 17:25:56: pid 21284: LOG: find_primary_node: checking backend no 1
2015-11-03 17:25:56: pid 21284: DEBUG: SSL is requested but SSL support is not available
2015-11-03 17:25:56: pid 21284: DEBUG: authenticate kind = 3
2015-11-03 17:25:56: pid 21284: ERROR: failed to authenticate
2015-11-03 17:25:56: pid 21284: DETAIL: invalid authentication message response type, Expecting 'R' and received 'E'
2015-11-03 17:25:56: pid 21284: DEBUG: find_primary_node: no primary node found
最初,我设置
sr_check_period
为pgpool.conf
0(零)以禁用 SR 检查。我想避免这种检查并总是平衡负载。但这导致了问题。在我给这个属性一个非零值之后,负载平衡开始工作。
backend_hostname1 = 'master-postgres-ip'
- >这应该指向你的奴隶,而不是主人。