Haproxy 為 mysql 做負載平衡

來源:互聯網
上載者:User

標籤:

tar zxvf haproxy-1.4.21.tar.gzcd haproxy-1.4.21uname -rvim /etc/haproxy.cfgglobal        #日誌        log 127.0.0.1    local0        maxconn 4096        chroot /tmp        uid  0        gid  0        daemon        nbproc 2        pidfile logs/haproxy.pid        #debug           #quiet   defaults        log     127.0.0.1       local3        mode    http        #option  httplog           #option  httpclose           option  dontlognull        #option  forwardfor           option  redispatch        retries 2        maxconn 2000        contimeout 3000        clitimeout 30000        srvtimeout 30000        balance roundrobin        bind-process 1#監控狀態頁配置listen stats        mode http        bind 0.0.0.0:8080        stats enable        stats   uri     /dbstat        stats   realm Global\ statistics        #身分識別驗證        stats auth admin:hello123listen  mysql_proxy        #代理連接埠        bind 0.0.0.0:33060        #模式 TCP        mode tcp        #調度演算法        balance roundrobin        #mysql健全狀態檢查        option mysql-check        #健全狀態檢查加上check        server  s1 192.168.1.42:3306 weight 3 check port 3306 inter 1s rise 2 fall 2        server  s3 192.168.1.43:3306 weight 3 check port 3306 inter 1s rise 2 fall 2        #啟動服務/usr/local/haproxy/sbin/haproxy -f /etc/haproxy.cfg#殺掉服務pkill haproxy#啟動指令碼vim /etc/init.d/haproxy========================================#! /bin/shset -ePATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/haproxy/sbinPROGDIR=/usr/local/haproxyPROGNAME=haproxyDAEMON=$PROGDIR/sbin/$PROGNAMECONFIG=/etc/haproxy.cfgPIDFILE=$PROGDIR/logs/$PROGNAME.pidDESC="HAProxy daemon"SCRIPTNAME=/etc/init.d/$PROGNAME# Gracefully exit if the package has been removed.test -x $DAEMON || exit 0start(){        echo -n "Starting $DESC: $PROGNAME"        $DAEMON -f $CONFIG        echo "."}stop(){        echo -n "Stopping $DESC: $PROGNAME"        haproxy_pid=cat $PIDFILE        kill $haproxy_pid        echo "."}restart(){        echo -n "Restarting $DESC: $PROGNAME"        $DAEMON -f $CONFIG -p $PIDFILE -sf $(cat $PIDFILE)        echo "."}case "$1" in  start)        start        ;;  stop)        stop        ;;  restart)        restart        ;;  *)        echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2        exit 1        ;;esacexit 0=================================================chmod +x /etc/init.d/haproxy#啟動服務/etc/init.d/haproxy start

 

參考:

http://www.2cto.com/database/201412/357835.html

http://blog.sina.com.cn/s/blog_5f66526e0100om1x.html

Haproxy 為 mysql 做負載平衡

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.