首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PostgreSQL HA使用HAProxy和Patroni

PostgreSQL HA使用HAProxy和Patroni
EN

Database Administration用户
提问于 2020-04-06 06:35:27
回答 1查看 674关注 0票数 0

我目前正在尝试使用HAProxy为我的PostgreSQL集群(使用Patroni解决方案)部署负载平衡。现在,我已经能够成功地实现设置和负载平衡工作在一定程度上。我的HAProxy配置:

代码语言:javascript
复制
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应用的内部逻辑来进行连接。

这是我第一次实现负载平衡设置,因此感谢您的耐心。:)

EN

回答 1

Database Administration用户

发布于 2020-04-06 07:23:51

对于每个已知为只读的查询,应用程序必须使用端口5005 (不仅选择,因为某些SELECT可以调用自定义函数)。

票数 0
EN
页面原文内容由Database Administration提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://dba.stackexchange.com/questions/264393

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档