05.haproxy+mysql Load Balancer integrated Redis cluster +SSM

Source: Internet
Author: User
Tags mysql load balancing mysql login haproxy redis cluster









This article focuses on the Haproxy+mysql load balancing, after the completion of the building with the previous REDIS+SSM to integrate



(Note: Here are two MySQL databases, installed two virtual machines, have successfully implemented primary master replication, if necessary, please check my other blog: http://www.cnblogs.com/cuijiale/p/8039421.html)



1, first download the latest Haproxy installation package: haproxy-1.7.9.tar.gz



After the download is complete, the CP is in a specific directory/usr/local



2, Installation Haproxy



Unzip "TAR-ZXVF haproxy-1.7.9.tar.gz" in this directory, after compression is complete "CD haproxy-1.7.9"



Execute the Install command "make target=linux3100 cpu=x86_64 prefix=/usr/local/haproxy-1.7.9"



"Make Install prefix=/usr/local/haproxy-1.7.9"









3. Configuration starts after installation is complete



Create the Haproxy.cfg configuration file at the root of the installation directory, as needed at startup.






Enter Haproxy.cfg file modification


1 global 2 log 127.0.0.1 local2 #log related 3 maxconn 4096 4 chroot / var / lib / haproxy 5 pidfile /var/run/haproxy.pid 6 user haproxy 7 daemon 8 stats socket / var / lib / haproxy / stats 9 # debug10 # quiet11 12 defaults13 mode tcp #haproxy operating mode (http | tcp | health) 14 log global15 option dontlognull16 option redispatch #serverId forces the server to be redirected to another healthy server 17 retries 3 #Three times the connection fails, the server No 18 timeout http-request 10s19 timeout queue 1m20 timeout connect 10s #connection timeout 21 timeout client 1m #client timeout 22 timeout server 1m #server timeout 23 timeout http-keep-alive 10s24 timeout check 10s #heartbeat Detect 25 maxconn 600 #maximum number of connections 26 27 listen mysql28 bind 0.0.0.0:23306 #proxy port 29 mode tcp #mode TCP30 option mysql-check user haproxy #mysql health check root for mysql login user name 31 balance roundrobin #scheduling algorithm 32 server mysql1 192.168.40.128:3306 weight 1 check inter 1s rise 2 fall 2 #health check plus check33 server mysql2 192.168.40.130:3306 weight 1 check inter 1s rise 2 fall 234 listen stats #monitoring 35 mode http36 bind 0.0.0.0: 888837 stats enable38 stats uri / dbs39 stats realm Global \ statistics40 stats auth admin: admin

Configuration file, it can be started, but before this, because the database is load balanced, need to synchronize data and access to data, need to create an identical account to respond to the access requirements, and the primary master replication account needs to be changed to the same, in order to facilitate the direct granting of the user full permissions. Grammar view my MySQL related blog: http://www.cnblogs.com/cuijiale/p/8034319.html, which all mentioned. Ok the pit of the platoon we've been lying down, here I start the service (in order for Haproxy to monitor two database information, you need to create a separate haproxy user, the password is empty).



./usr/local/haproxy-1.7.9/sbin/haproxy-f/usr/local/haproxy-1.7.9/haproxy.cfg






It can be viewed by command after launch. Start everything OK



Remotely use "Http://192.168.40.128:8888/dbs" to view monitoring conditions the configuration used here is all from









Login password Here is the configuration of the admin/admin can see our configuration of the two MySQL has been monitored.



4. Integrated SMM



In the above configuration diagram, we can see the 23306 port that we let haproxy listen to, so we need to connect this port in the configuration file.






All ready, start Redis cluster









After the Redis master-Slave 6 node starts all, start the Web service access






Data is also perfectly available. Everything OK so we a SSM Web application +redis cluster +mysql load balancer high availability, high performance, high expansion of the read and write separation architecture is completed, there are many flaws, and then will be self-completion, the architecture also need to use Nginx to load balance Web applications, Reduce application server stress.



Which is not the place, also hope you can point out, thank you






05.haproxy+mysql Load Balancer integrated Redis cluster +SSM


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.