In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The following will give you a focus on haproxy+mysql load balancing, hoping to give you some help in practical application. Load balancing involves a lot of things, and there are not many theories. There are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.
This article focuses on haproxy+mysql load balancing, which is integrated with the previously built redis+ssm after completion.
(note: two mysql databases are used here, and two virtual machines are installed, and master-master replication has been successfully implemented. If necessary, please see 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 downloading, cp to a specific directory / usr/local
2. Install haproxy
Decompress "tar-zxvf haproxy-1.7.9.tar.gz" in this directory, and "cd haproxy-1.7.9" after compression is completed.
Execute the installation command "make TARGET=linux3100 CPU=x86_64 PREFIX=/usr/local/haproxy-1.7.9"
"make install PREFIX=/usr/local/haproxy-1.7.9"
3. Configure and start after installation is complete
Create a haproxy.cfg configuration file at the root of the installation directory, which is required at startup.
Enter the haproxy.cfg file to modify
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 Running mode (http | tcp | health) 14 log global15 option dontlognull16 option redispatch # serverId after the corresponding server hangs Force direct to another healthy server 17 retries 3 # if the connection fails three times, the server does not need 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 detection 25 maxconn 600 # most Dalian connections 26 27 listen mysql28 bind 0.0.0.0 listen mysql28 bind 23306 # proxy port 29 mode tcp # mode TCP30 option mysql-check user haproxy # Mysql Health check root is the mysql login user name 31 balance roundrobin # scheduling algorithm 32 server mysql1 192.168.40.128mysql 3306 weight 1 check inter 1s rise 2 fall 2 # Health check plus check33 server mysql2 192.168.40.130V 3306 weight 1 check inter 1s rise 2 fall 234 listen stats # Monitoring 35 mode http36 bind 0.0.0.0 server mysql1 888837 Stats enable38 stats uri / dbs39 stats realm Global\ statistics40 stats auth admin:admin
After the configuration file, you can start it, but before that, because the database is a load balancer, you need to synchronize data and access data, and you need to create an identical account to meet the access demand. and the account copied by the master needs to be changed to the same, in order to directly grant the user full permissions. Grammar check out my mysql-related blog: http://www.cnblogs.com/cuijiale/p/8034319.html, which is all mentioned. We've already laid down the trap of ok, so I'll start the service here (in order for haproxy to monitor two databases, you need to create a haproxy user with an empty password).
. / usr/local/haproxy-1.7.9/sbin/haproxy-f / usr/local/haproxy-1.7.9/haproxy.cfg
After startup, you can check it through the command. Start up. Everything's fine.
Use http://192.168.40.128:8888/dbs" remotely to check the monitoring situation. All the configurations used here come from
Login password is configured here is admin/admin. You can see that the two mysql we configured have been monitored.
4. Integrate smm
In the configuration diagram above, you can see port 23306 that we asked haproxy to listen on, so this port needs to be connected in the configuration file.
Everything is ready to start the redis cluster
After all 6 master and slave nodes of redis are started, start web service access
And the data is perfect. All ok, so that our high-availability, high-performance, high-expansion read-write separation architecture for SSM WEB application + redis cluster + mysql load balancing is completed, and there are many defects, which will be gradually remedied later. The architecture also needs to use nginx to load balance web applications to reduce the pressure on application servers.
After reading the above focus on haproxy+mysql load balancing, if you have anything else you need to know, you can find out what you are interested in in the industry information or find our professional and technical engineers who have more than ten years of experience in the industry.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.