Haproxy performs Load Balancing for mysql and haproxymysql

Source: Internet
Author: User

Haproxy performs Load Balancing for mysql and haproxymysql
1. First install haproxywget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.24.tar.gztar zcvf haproxy-1.4.24.tar.gzcd haproxy-1.4.24Make TARGET = linux26 PREFIX =/usr/local/haproxy # Install haproxy on/usr/local/haproxymake install PREFIX=/usr/local/haproxy# The PREFIX must be in uppercase; otherwise, it cannot be installed in the specified directory/usr/local/haproxy.2. Create the haproxy. cfg configuration file under/usr/local/haproxy/etc. Content:
global        log 127.0.0.1Local0 info # log related        log 127.0.0.1local1 notice        maxconn 4096        chroot /usr/local/haproxy        uid root        gid root        daemon        #debug        #quiet        pidfile /usr/local/haproxy/haproxy.pid defaults        log     global        mode    http        #option httplog        option  dontlognull        retries 3        option redispatch        maxconn         2000        contimeout      5000        clitimeout      50000        srvtimeout      50000 listen  mysql        bind 0.0.0.0:23306# Proxy Port        Mode tcp # mode TCP        Option mysql-check user root # mysql health check root is the mysql Login user Name        Balance roundrobin # Scheduling Algorithm        server mysql1 192.168.153.128:3306 weight 1 check  inter 1s rise 2 fall 2 # Health check plus check        server mysql2 192.168.153.134:3306 weight 1 check  inter 1s rise 2 fall 2Listen stats # monitoring           mode http           bind 0.0.0.0:8888           stats enable           stats uri /dbs           stats realm Global\ statistics           stats auth admin:admin
# Option mysql-check user root # comment out the mysql health check root as the mysql Login user Name
Start mysql service for both users. 3. Start [root @ web2 etc] #/usr/local/haproxy/sbin/haproxy-f/usr/local/haproxy/etc/haproxy. cfg
[Root @ web2 etc] # cd ../sbin/
[Root @ web2 sbin] # ls
Haproxy
[Root @ web2 sbin] # ps-ef | grep haproxy
Root 4223 1 0 18:12? 00:00:00/usr/local/haproxy/sbin/haproxy-f/usr/local/haproxy/etc/haproxy. cfg
Root 4228 3754 0 00:00:00 pts/0 grep haproxy
[Root @ web2 sbin] #4. Access ip: 8888/dbs enter admin to log on

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.