mysql 从读负载

global
#log 127.0.0.1	local0
log 127.0.0.1	local3 info
#log loghost	local0 info
maxconn 4096
chroot /usr/local/haproxy
uid nobody
gid nobody
daemon
debug
#quiet
 
defaults
log	global
mode	tcp
#option	httplog
option	dontlognull
retries	3
option redispatch
maxconn	2000
contimeout	5000
clitimeout	50000
srvtimeout	50000
 
frontend mysql
bind 192.168.0.107:3306
maxconn 3000
default_backend mysql_slave
 
 
backend	mysql_slave 
#cookie	SERVERID rewrite
mode tcp
balance	roundrobin
#balance	source
#balance	leastconn
contimeout 10s
timeout check 2s
option httpchk OPTIONS * HTTP/1.1
Host: www
server	mysql_192_168_0_104_3306 192.168.0.104:3306 weight 1 check port 9300 inter 5s rise 2 fall 3
server	mysql_192_168_0_104_3307 192.168.0.104:3307 weight 1 check port 9301 inter 5s rise 2 fall 3
#server	mysql_192_168_0_106_3306 192.168.0.106:3306 weight 1 check port 9300 inter 5s rise 2 fall 3
 
listen  admin_status
mode  http
bind 192.168.0.107:8000
option httplog
log global
stats enable
stats refresh 30s
stats hide-version
stats realm Haproxy Statistics
stats uri  /admin-status
stats auth  admin:123456
stats admin if TRUE

原文地址:https://www.cnblogs.com/hzcya1995/p/13351099.html