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

 另一版配置文件

global
        maxconn         20000
        ulimit-n    40012
        log             127.0.0.1 local0
        user            root
        group           root
        nbproc        2
        daemon

frontend test-proxy
        bind        *:3306
        mode            tcp
        log             global
        option          dontlognull
        option          nolinger
        maxconn         8000
    stats uri     /stats
    default_backend test-proxy-srv


backend test-proxy-srv
    mode            tcp
    balance         roundrobin
    option          nolinger
    server pos1 10.14.4.232:3306 check

 

posted on 2022-01-24 18:59  柴米油盐酱醋  阅读(458)  评论(0编辑  收藏  举报

导航