安装 haproxy

安装 haproxy

yum install haproxy

 

配置 haproxy 后台管理

vi /etc/haproxy/haproxy.cfg

 

后台监控

listen statspage

    bind *:8888   

    stats enable 

    stats hide-version  

    stats uri /admin?stats   

    #stats auth xiao:linux   

    #stats admin if TRUE 

listen  mysql

        bind 0.0.0.0:23306    #代理端口

        mode tcp              #模式 TCP

        #option mysql-check user root   #mysql健康检查  root为mysql登录用户名

        balance roundrobin            #调度算法

        server mysql1 192.168.175.131:3306 check port 3306 maxconn 300

        server mysql2 192.168.175.132:3306 check port 3306 maxconn 300

 

 

注释掉http相关选项

#   option                  httplog

#   option http-server-close

#   option forwardfor       except 127.0.0.0/8

#   timeout http-request    10s

 

 

 

启动 haproxy

/usr/sbin/haproxy -f /etc/haproxy/haproxy2.cfg

 

posted @ 2016-03-29 15:23  jlx351312  阅读(144)  评论(0编辑  收藏  举报