HAproxy端口转发到Mysql


参考文档:

https://blog.51cto.com/chenql/1898713
http://www.ttlsa.com/linux/haproxy-study-tutorial

配置文件:

[root@mysql haproxy]#        cat haproxy.cfg
global
        log 127.0.0.1 local2
        chroot /var/lib/haproxy
        pidfile /var/run/haproxy.pid
        maxconn 4000
        user haproxy
        group haproxy
        daemon
defaults
        mode tcp
        log global
        option httplog
        option dontlognull
        retries 3
        timeout http-request 10s
        timeout queue 1m
        timeout connect 10s
        timeout client 360m
        timeout server 360m
        timeout http-keep-alive 10s
        timeout check 10s
        maxconn 3000
## 定义一个监控页面,监听在1080端口,并启用了验证机制
listen stats
        mode http
        bind 0.0.0.0:1080
        stats enable
        stats hide-version
        stats uri /haproxyadmin?stats
        stats realm Haproxy\ Statistics
        stats auth admin:admin
        stats admin if TRUE
frontend mysql
        bind *:3333
        mode tcp
        #log global
        option tcplog
        default_backend mysqlservers
backend mysqlservers
        balance leastconn
        server dbsrv1 127.0.0.1:3357 check port 3357 rise 1 fall 2 maxconn 3000