Tags: redis mysql cluster load balancerThis 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
First, load Balancing introduction
Main open source software LVs, keepalived, Haproxy, Nginx and so on;
The LVS belongs to 4 layer (network OSI 7 layer model), Nginx belongs to 7 layer, Haproxy can be considered as 4 layer, can be used as 7 layer;
Keepalived load balancing function is in fact LVS;
LVS This 4-layer load
Resttemplate can be automatically configured to use the Ribbon. To create a load balancing resttemplate create a resttemplate @Bean and use the @loadbalanced qualifier.Warning: resttemplate beans are no longer created with automatic configuration. It must be created by a single application.@Configurationpublic class MyConfiguration { @LoadBalanced @Bean RestTemplate restTemplate() { return new RestTemplate(); }}public class MyClass
Resttemplate can be automatically configured to use the Ribbon. To create a load balancing resttemplate create a resttemplate @Bean and use the @loadbalanced qualifier.Warning: resttemplate beans are no longer created with automatic configuration. It must be created by a single application.@Configurationpublic class MyConfiguration { @LoadBalanced @Bean RestTemplate restTemplate() { return new RestTemplate(); }}public class MyClass
Resttemplate can be automatically configured to use the Ribbon. To create a load balancing resttemplate create a resttemplate @Bean and use the @loadbalanced qualifier.Warning: resttemplate beans are no longer created with automatic configuration. It must be created by a single application. Br/> @Configuration@LoadBalanced@BeanRestTemplate restTemplate() { return new RestTemplate();}}public class MyClass {br/> @Autowiredpublic String doOtherStuff()
:229406(224.0KiB) TX Bytes:229406(224.0KiB) [Email protected] keepalived]# Ipvsadm-lnip Virtual Server version1.2.1(size=4096) Prot localaddress:port Scheduler Flags-remoteaddress:port Forward Weight activeconn inactconntcp192.168.103.100: theWRR Persistent --192.168.103.101: theRoute1 0 0-192.168.103.105: theRoute1 0 0If the NODE3 does not turn off the firewall, the ETH0:1 network card is also enabled, so be careful to shu
Logs_path= "/data/logs/"#将日志改名Mkdir-p ${logs_path}${date-d "Yesterday" + "%Y"}/${date-d "Yesterday" + "%m"}/MV ${logs_path}access.log ${logs_path}${date-d "Yesterday" + "%Y"}/${date-d "Yesterday" + "%m"}/access_${date-d "yester Day "+"%y%m%d "}.log#重启Nginx服务, regenerate the Access.log fileService Nginx Reload#创建计划任务#crontab-|* * * */bin/bash/data/logs.shLoad BalancingUpstream My_server_pool {}Copies the specified input file into the specified output file, and can be converted to a format during
If you have not set up the nginx environment, please refer to my previous blog
Nginx Load Balancing
Lab Environment
Win7: tomcat6 + jdk6 + memcached
Linux: vmware9 + Ubuntu + jdk6 + nginx + tomcat6 + memcached
First, install memcached in windows.
Memcached-1.2.6-win32-bin.zip, 64-bit can also
Install memcached.exe-D install as a Windows Service
Memcached.exe-d start
Configure the memcached port, HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Servi
detecting the Nginx process ID and then using the KILL command to force the kill process.Query Nginx Process:PS Aux|grep Nginx8.2.6 Restart Service:1. Stop and restart (recommended):Restarting the nginx is equivalent to stopping and starting the Stop command before executing the start command. As follows:./nginx-s quit./nginx2. Reload the configuration file:When the configuration file of Ngin x nginx.conf Modified, for the configuration to take effect need to restart Nginx, use-s reload do not
instances on two different physical hosts.
Use case: Make sure that each member in the HA group is configured on a different virtual Machine Manager (physical host).
Set up
Let's pause for a moment and take a look at the symbols and conventions used in this article, as well as some considerations for setting up the environment.
Commands executed as root on the system are prefixed with root@host#.
Use the user@host# sudo as root on the system to
system version : Ubuntu 14.04.3 LTSServer Preparation :lb01-> ifconfig Display Result: 192.168.91.136 effect: Install keepalived and Nginxlb02-> ifconfig Display Result: 192.168.91.135 effect: Install keepalived and Nginxweb01-> ifconfig Display Result: 192.168.91.134 effect: Install Nginx is responsible for showing index.html pageweb02-> ifconfig Display Result: 192.168.91.137 effect: Install Nginx is responsible for showing index.html pageOperating principle1 Nginx acts as a Web server on WEB0
ipvsadm start ipvsadm -C #清除内核虚拟服务器表中的所有记录 ipvsadm -A -t 12.0.0.1:80 -s rr #创建虚拟服务器 ipvsadm -a -t 12.0.0.1:80 -r 192.168.10.51:80 -m ipvsadm -a -t 12.0.0.1:80 -r 192.168.10.52:80 -m ipvsadm
Options for the IPVSADM management tool use:
-A: Indicates adding a virtual server
-T: Used to specify the VIP address and TCP port
-S: Used to specify load balancing scheduling algo
"/>Or we modify the dir parameter modification.650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/76/41/wKiom1ZN5E-BlKU9AABxyOzJQvQ126.png "title=" Image.png "alt=" Wkiom1zn5e-blku9aabxyozjqvq126.png "/>Then execute this script![Email protected] ~]# sh/usr/local/sbin/lvs_dr.shSiocaddrt:file existsAfter the implementation of the problem, it is because we have just executed, opened the eth0:0 so we have to shut down the network and then open.Continue to modify Dir's configuration file:vim
About haproxy
Provides high availability, Server Load balancer, and proxy Based on TCP and HTTP applications, and supports Virtual Hosts. It is a free, fast, and reliable solution. Haproxy is especially suitable for websites with extremely high loads, which usually require session persistence or layer-7 processing. Haproxy runs on the current hardware and suppor
0.0 112680 976 pts/0 R+ 18:25 0:00 grep --color=auto keepAlso need to be performed on two RSsh /usr/local/sbin/lvs_dr_rs.sh4. TestingTest Method 1:Enter the VIP in the browser 192.168.242.110 and then deliberately stop an RS nginx service, then refresh the browser to see the results.Test Method 2:In the scheduler, execute the relevant command to view the number of connections:[[emailprotected] ~]# ipvsadm -lnIP Virtual Server version 1.2.1
Resttemplate can be automatically configured to use the Ribbon. To create a load balancing resttemplate create a resttemplate @Bean and use the @loadbalanced qualifier.Warning: resttemplate beans are no longer created with automatic configuration. It must be created by a single application.@Configurationpublic class MyConfiguration { @LoadBalanced @Bean RestTemplate restTemplate() { return new RestTemplate(); }}public class MyClass
RestTemplateCan be automatically configured to use the Ribbon. Create RestTemplate RestTemplate @Bean and use qualifiers to create load balancing @LoadBalanced .Warning: No longer created with automatic configurationRestTemplateBean. It must be created by a single application.@Configuration Public classmyconfiguration {@LoadBalanced @Bean resttemplate resttemplate () {return Newresttemplate (); }} Public classMyClass {@AutowiredPrivateresttemplate re
RestTemplateCan be automatically configured to use the Ribbon. Create RestTemplate RestTemplate @Bean and use qualifiers to create load balancing @LoadBalanced .Warning: No longer created with automatic configurationRestTemplateBean. It must be created by a single application.@Configuration Public classmyconfiguration {@LoadBalanced @Bean resttemplate resttemplate () {return Newresttemplate (); }} Public classMyClass {@AutowiredPrivateresttemplate res
Azure Load Balancing
Load Balancing Overview:
Microsoft Azure provides load balancing services for virtual machines (IAAS) and cloud services (PAAs) hosted in it. Server Load balancer supports application scaling and provides appl
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.