Haproxy implementing MySQL Slave load Balancing

Source: Internet
Author: User
Tags haproxy

Simply draw a diagram:

first, the server planning192.168.116.132 (Master)--write operations192.168.116.129 (SLAVE1)--read Operation192.168.116.131 (SLAVE2)--read Operation192.168.116.130 (Haproxy)--Agent
MySQL master-slave replication configuration skipped. Second, installation configuration HaproxyInstalling Haproxy
Tar zxf haproxy-1.4.21.tar.gzcd haproxy-1.4.21make target=linux26 prefix=/app/haproxy make install PREFIX=/app/ Haproxymkdir/app/haproxy/{conf,log}

configuration Haproxy

Vi/app/haproxy/conf/haproxy.cfg #添加如下内容global log 127.0.0.1 local3 info #日志相关 log 127.0.0.1 local3 n Otice maxconn 10240 chroot/app/haproxy uid root gid root daemon pidfile/app/ha Proxy/log/haproxy.piddefaults #log Global Mode http #option httplog #option Dontlognul L option redispatch retries 3 option Redispatch maxconn 4096 contimeout 5        0000 clitimeout 50000 Srvtimeout 50000listen mysql-proxy bind 0.0.0.0:33307 #代理端口 Mode TCP #模式 TCP option Mysql-check user Haproxy #mysql健康检查, haproxy users without any permissions, and no password balance RO Undrobin #调度算法 Server mysql1-129 192.168.116.129:3306 weight 1 check inter 1s rise 2 fall 2 #健康检查加上chec K Server mysql2-131 192.168.116.131:3306 weight 1 check inter 1s rise 2 fall 2listen stats #监控 mode HTTP bind 0.0.0.0:19999 stats enable stats Uri/dbs stats Realm global\ statistics stats auth ad Min:admin

Start Haproxy

/app/haproxy/sbin/haproxy-f/app/haproxy/conf/haproxy.cfg
Open your browser to view:Http://192.168.116.130:19999/dbsUser name and password: admin/admin

Haproxy implementing MySQL Slave load Balancing

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.