尹雪松*_*尹雪松 2 cluster-computing haproxy mariadb galera
我使用 haproxy 作为 mariadb galera 集群的 banlancer,它可以正常连接并执行一些操作,但几秒钟后我想再次进行一些搜索,但在查询错误期间丢失了连接。请参阅下图的错误。
这是我的 haproxy.cfg
defaults
log global
mode tcp
option tcplog
option dontlognull
option http-server-close
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 50000ms
timeout server 50000ms
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
Run Code Online (Sandbox Code Playgroud)
以及 haproxy.cfg 中 mariadb 集群的余额
listen mariadb_cluster_writes 0.0.0.0:50613
## A failover pool for writes to ensure writes only hit one node at a time.
mode tcp
#option httpchk
option tcpka
option mysql-check user haproxy
server node65 172.27.12.65:3306 check weight 2
server node64 172.27.12.64:3306 check weight 1
server node67 172.27.12.67:3306 check weight 1
listen mariadb_cluster_reads 0.0.0.0:50614
## A load-balanced pool for reads to utilize all nodes for reads.
mode tcp
balance leastconn
#option httpchk
option tcpka
option mysql-check user haproxy
server node65 172.27.12.65:3306 check weight 1
server node64 172.27.12.64:3306 check weight 1
server node67 172.27.12.67:3306 check weight 1
Run Code Online (Sandbox Code Playgroud)
有人有想法吗?
我想我找到了原因。Haproxy本身有服务器和客户端的超时,我将服务器超时和客户端超时设置为与mysql超时相同,即8小时。现在看起来是这样的:
defaults
log global
mode tcp
option tcplog
option dontlognull
option http-server-close
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 480m
timeout server 480m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
Run Code Online (Sandbox Code Playgroud)
希望可以帮助别人。
但是我使用mariadb集群,它是master和master架构,所有节点都可以插入,所以我更改了haproxy.cfg,现在看起来像这样:
# Global settings
global
log 127.0.0.1 local2
maxconn 4000
daemon
defaults
log global
mode tcp
#option tcplog
option dontlognull
option tcp-smart-accept
option tcp-smart-connect
option redispatch
retries 3
timeout connect 5s
timeout client 480m
timeout server 480m
listen admin_stats
bind 0.0.0.0:50613
mode http
maxconn 10
stats refresh 30s
stats uri /stats
stats realm XingCloud\ Haproxy
stats auth admin:admin
listen galera_back
bind :50614
balance leastconn
server node65 172.27.12.65:3306 check weight 1
server node64 172.27.12.64:3306 check weight 1
server node67 172.27.12.67:3306 check weight 1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4712 次 |
| 最近记录: |