我目前正在尝试使用HAProxy为我的PostgreSQL集群(使用Patroni解决方案)部署负载平衡。现在,我已经能够成功地实现设置和负载平衡工作在一定程度上。我的HAProxy配置:
global
maxconn 100
defaults
log global
mode tcp
retries 2
timeout client 30m
timeout connect 4s
timeout server 30m
timeout check 5s
listen stats
mode http
bind *:7000
stats enable
stats uri /
listen read_write
bind *:5004
option httpchk OPTIONS /master
http-check expect status 200
default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
server pg1 IP:5432 maxconn 100 check port 8008
server pg2 IP:5432 maxconn 100 check port 8009
listen read_only
bind *:5005
mode tcp
balance roundrobin
http-check expect status 200
default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
server pg1 IP:5432 maxconn 100 check port 8008
server pg2 IP:5432 maxconn 100 check port 8009但是,我的问题是应用程序将如何与HAProxy进行只读请求交互。应用程序是否需要使用端口5005连接,或者是否存在由HAProxy应用的内部逻辑来进行连接。
这是我第一次实现负载平衡设置,因此感谢您的耐心。:)
发布于 2020-04-06 07:23:51
对于每个已知为只读的查询,应用程序必须使用端口5005 (不仅选择,因为某些SELECT可以调用自定义函数)。
https://dba.stackexchange.com/questions/264393
复制相似问题