Haproxy load balancing for MySQL

Source: Internet
Author: User
Tags haproxy

TarZXVF haproxy-1.4. +.Tar. GZCD Haproxy-1.4. +uname-Rvim/etc/haproxy.cfgglobal #日志log127.0.0.1local0 Maxconn4096        chroot/tmp uid0GID0Daemon Nbproc2Pidfile Logs/haproxy.pid #debug #quiet defaults log127.0.0.1local3 mode http #option httplog #option httpclose option dont Lognull #option forwardfor option Redispatch retries2Maxconn -Contimeout theClitimeout30000Srvtimeout30000Balance Roundrobin bind-process1 #监控状态页配置Listen stats mode http bind0.0.0.0:8080stats enable stats URI/dbstat Stats Realm global\ statistics #身份验证stats auth Admin:hello123listen Mysql_pro XY #代理端口bind0.0.0.0:33060 #模式 tcp mode TCP #调度算法balance roundrobin #mysql健康检查 Option MySQL-Check #健康检查加上check server S1192.168.1.42:3306Weight3Check Port3306Inter 1s rise2Fall2Server S3192.168.1.43:3306Weight3Check Port3306Inter 1s rise2Fall2#启动服务/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 ifThe package has  been removed. Test-X $DAEMON | | Exit0start () {Echo-N"starting $DESC: $PROGNAME"$DAEMON-F $CONFIGEcho "."}stop () {Echo-N"stopping $DESC: $PROGNAME"Haproxy_pid=Cat$PIDFILEKill$haproxy _pidEcho "."}restart () {Echo-N"restarting $DESC: $PROGNAME"$DAEMON-F $CONFIG-P $PIDFILE-sf $ (Cat$PIDFILE)Echo "."} Case " $" inchstart) Start;  stop) stop;;  restart) restart;; *)        Echo "Usage: $SCRIPTNAME {Start|stop|restart}">&2Exit1        ;;EsacExit0=================================================chmod+x/etc/init.d/haproxy#启动服务/etc/init.d/haproxy start

Reference:

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

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

Haproxy load balancing for MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.