zhouying23 发表于 2018-9-29 08:28:11

mysql cluster解决方案

global  
maxconn 40000
  
debug
  
#quiet
  
user haproxy
  
group haproxy
  
nbproc 1
  
log 127.0.0.1 local3
  
spread-checks 2
  
defaults
  
timeout server 3s
  
timeout connect 3s
  
timeout client 60s
  
timeout http-request 3s
  
timeout queue 3s
  
frontend db_write
  
bind 192.168.254.110:3306
  
default_backend cluster_db_write
  
frontend db_read
  
bind 192.168.254.120:3306
  
default_backend cluster_db_read
  
frontend web_haproxy_status
  
bind *:80
  
default_backend web_status
  
frontend monitor_mysql111
  
bind 127.0.0.1:9301
  
mode http
  
acl no_repl_mysql111 nbsrv(mysql111_replication) eq 0
  
acl no_repl_mysql112 nbsrv(mysql112_replication) eq 0
  
acl no_mysql111 nbsrv(mysql111_status) eq 0
  
acl no_mysql112 nbsrv(mysql112_status) eq 0
  
monitor-uri /dbs
  
monitor fail unless no_repl_mysql111 no_repl_mysql112 no_mysql112
  
monitor fail if no_mysql111 no_mysql112
  
frontend monitor_mysql112
  
bind 127.0.0.1:9302
  
mode http
  
acl no_repl_mysql111 nbsrv(mysql111_replication) eq 0
  
acl no_repl_mysql112 nbsrv(mysql112_replication) eq 0
  
acl no_mysql111 nbsrv(mysql111_status) eq 0
  
acl no_mysql112 nbsrv(mysql112_status) eq 0
  
monitor-uri /dbs
  
monitor fail unless no_repl_mysql111 no_repl_mysql112 no_mysql111
  
monitor fail if no_mysql111 no_mysql112
  
frontend monitor_mysql121
  
bind 127.0.0.1:9303
  
mode http
  
acl no_repl_mysql121 nbsrv(mysql121_replication) eq 0
  
acl no_repl_mysql111 nbsrv(mysql111_replication) eq 0
  
acl no_mysql112 nbsrv(mysql112_status) eq 1
  
monitor-uri /dbs
  
monitor fail if no_repl_mysql121
  
monitor fail if no_repl_mysql111no_mysql112
  
frontend monitor_mysql122
  
bind 127.0.0.1:9304
  
mode http
  
acl no_repl_mysql122 nbsrv(mysql122_replication) eq 0
  
acl no_repl_mysql111 nbsrv(mysql111_replication) eq 0
  
acl no_mysql112 nbsrv(mysql112_status) eq 1
  
monitor-uri /dbs
  
monitor fail if no_repl_mysql122
  
monitor fail if no_repl_mysql111 no_mysql112
  
frontend monitor_mysql123
  
bind 127.0.0.1:9305
  
mode http
  
acl no_repl_mysql123 nbsrv(mysql123_replication) eq 0
  
acl no_repl_mysql112 nbsrv(mysql112_replication) eq 0
  
acl no_mysql111 nbsrv(mysql111_status) eq 1
  
monitor-uri /dbs
  
monitor fail if no_repl_mysql123
  
monitor fail if no_repl_mysql112 no_mysql111
  
frontend monitor_mysql124
  
bind 127.0.0.1:9306
  
mode http
  
acl no_repl_mysql124 nbsrv(mysql124_replication) eq 0
  
acl no_repl_mysql112 nbsrv(mysql112_replication) eq 0
  
acl no_mysql111 nbsrv(mysql111_status) eq 1
  
monitor-uri /dbs
  
monitor fail if no_repl_mysql124
  
monitor fail if no_repl_mysql112 no_mysql111
  
frontend monitor_splitbrain
  
bind 127.0.0.1:9300
  
mode http
  
acl no_repl01 nbsrv(mysql111_replication) eq 0
  
acl no_repl02 nbsrv(mysql112_replication) eq 0
  
acl mysql111 nbsrv(mysql111_status) eq 1
  
acl mysql112 nbsrv(mysql112_status) eq 1
  
monitor-uri /dbs
  
monitor fail unless no_repl01 no_repl02 mysql111 mysql112
  
backend mysql111_replication
  
mode tcp
  
balance roundrobin
  
option tcpka
  
option httpchk
  
server mysql111 192.168.254.111:3306 check port 9201 inter 1s rise 1 fall 1
  
backend mysql112_replication
  
mode tcp
  
balance roundrobin
  
option tcpka
  
option httpchk
  
server mysql112 192.168.254.112:3306 check port 9201 inter 1s rise 1 fall 1
  
backend mysql121_replication
  
mode tcp
  
balance roundrobin
  
option tcpka
  
option httpchk
  
server mysql121 192.168.254.121:3306 check port 9201 inter 1s rise 1 fall 1
  
backend mysql122_replication
  
mode tcp
  
balance roundrobin
  
option tcpka
  
option httpchk
  
server mysql122 192.168.254.122:3306 check port 9201 inter 1s rise 1 fall 1
  
backend mysql123_replication
  
mode tcp
  
balance roundrobin
  
option tcpka
  
option httpchk
  
server mysql123 192.168.254.123:3306 check port 9201 inter 1s rise 1 fall 1
  
backend mysql124_replication
  
mode tcp
  
balance roundrobin
  
option tcpka
  
option httpchk
  
server mysql124 192.168.254.124:3306 check port 9201 inter 1s rise 1 fall 1
  
backend mysql111_status
  
mode tcp
  
balance roundrobin
  
option tcpka
  
option httpchk
  
server mysql111 192.168.254.111:3306 check port 9200 inter 1s rise 2 fall 2
  
backend mysql112_status
  
mode tcp
  
balance roundrobin
  
option tcpka
  
option httpchk
  
server mysql112 192.168.254.112:3306 check port 9200 inter 1s rise 2 fall 2
  
backend cluster_db_write
  
mode tcp
  
option tcpka
  
balance roundrobin
  
option httpchk GET /dbs
  
server mysql111 192.168.254.111:3306 weight 1 check port 9201 inter 1s rise 5 fall 1
  
server mysql112 192.168.254.112:3306 weight 1 check port 9201 inter 1s rise 5 fall 1 backup
  
server mysql111_backup 192.168.254.111:3306 weight 1 check port 9301 inter 1s rise 2 fall 2 addr 127.0.0.1 backup
  
server mysql112_backup 192.168.254.112:3306 weight 1 check port 9302 inter 1s rise 2 fall 2 addr 127.0.0.1 backup
  
backend cluster_db_read
  
mode tcp
  
option tcpka
  
balance roundrobin
  
option httpchk GET /dbs
  
server mysql111 192.168.254.111:3306 weight 1 track cluster_db_write/mysql111
  
server mysql112 192.168.254.112:3306 weight 1 track cluster_db_write/mysql112
  
server mysql111_backup 192.168.254.111:3306 weight 1 track cluster_db_write/mysql111_backup
  
server mysql112_backup 192.168.254.112:3306 weight 1 track cluster_db_write/mysql112_backup
  
server mysql111_splitbrain 192.168.254.111:3306 weight 1 check port 9300 inter 1s rise 1 fall 2 addr 127.0.0.1
  
server mysql112_splitbrain 192.168.254.112:3306 weight 1 check port 9300 inter 1s rise 1 fall 2 addr 127.0.0.1
  
server mysql121_slave 192.168.254.121:3306 weight 1 check port 9303 inter 1s rise 5 fall 1 addr 127.0.0.1
  
server mysql122_slave 192.168.254.122:3306 weight 1 check port 9304 inter 1s rise 5 fall 1 addr 127.0.0.1
  
server mysql123_slave 192.168.254.123:3306 weight 1 check port 9305 inter 1s rise 5 fall 1 addr 127.0.0.1
  
server mysql124_slave 192.168.254.124:3306 weight 1 check port 9306 inter 1s rise 5 fall 1 addr 127.0.0.1
  
backend web_status
  
mode http
  
stats enable
  
#stats scope
  
#stats hide-version
  
stats refresh 5s
  
stats uri /status
  
stats realm Haproxy/statistics
  
stats auth copy:copy


页: [1]
查看完整版本: mysql cluster解决方案