Simple setting of Server Load balancer LVS in Linux

Source: Internet
Author: User
Article Title: Linux Server Load balancer LVS simple settings. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   Simple terms:
  
Director: Front-End Server Load balancer that runs lvs. Currently, it can only be Linux. For FreeBSD, the performance is unknown. Loadbalance can be implemented for services such as web, ftp, cache, mms, and even mysql.
  
RealServer: the backend server that requires Server Load balancer. It can be a variety of systems, including Linux, Solaris, Aix, BSD, and Windows. Even Director itself can be used as RealServer.
  
After the Spring Festival, I have been busy and confused. My head has been turning too fast. In the afternoon, I am a little idle. Recently, more than N of my friends want to perform load balancing in the web mode, briefly describe the lvs settings (not involving HA and Mult-homing), as the brain is well rested: p
  
Lvs Linux Virtual Server and Linux Server Load balancer are not described much. We will not discuss it with DNS round robin and comparison of some commercial products. For details, refer to the LVS website, support LVS-NAT, LVS-DR, LVS-TUNL three different ways, nat is not a lot, here a brief introduction of DR, TUNL mode.
  
The DR mode is suitable for all realservers under the same network segment, that is, connected to the same vswitch.
  
The TUNL mode allows the RealServer to be arbitrary and can be fully cross-region and spatial. It can be achieved as long as the system supports Tunnel (Win2k3 does not seem to support ......)
  
You can use the Tunl Method for further expansion.
  
The Director system is RHEL3 + ClusterSuite (I am a lazy, so I am too lazy to make a kernel patch: p)
  
RealServer system: Rhel3 + noarp patch
  
   Ctor ctor settings:
  
You need to set/etc/sysconfig/ha/lvs in ctor. cf, and after ClusterSuite is installed, start the pulse Service (Redhat lvs service, you can also manually). Below is a simple lvs setting (director HA is not set), man lvs. cf. Check the detailed settings. RHEL3 has a detailed manual.
  
203. x. x. a is the Director Public IP address.
  
203. x. x. B is the IP address of the domain name for Loadbance.
  
203. x. x. c is the first RealServer.
  
203. x. x. d is the second RealServer.
  
# Cat/etc/sysconfig/ha/lvs. cf
  
Serial_no = 45
  
Primary = 203. x. x.
  
Service = lvs
  
Rsh_command = ssh
  
Backup_active = 0
  
Backup = 0.0.0.0
  
Heartbeat = 1
  
Heartbeat_port = 539
  
Keepalive = 10
  
Deadtime = 20
  
Network = direct (change the Tunl mode to tunnel)
  
Nat_nmask = 255.255.255.255.255
  
Reservation_conflict_action = preempt
  
Debug_level = NONE
  
Virtual www.test.com {
  
Active = 1
  
Address = 203. x. x. B eth0: 0
  
Vip_nmask = 255.255.255.255
  
Port = 80
  
Send = "GET/HTTP/1.0 \ r \ n"
  
Ct = "HTTP"
  
Load_monitor = uptime
  
Schedlc = wlc
  
Protocol = tcp
  
Timeout = 10
  
Reentry = 15
  
Quiesce_server = 0
  
Server r1 {
  
Address = 203. x. x. c
  
Active = 1
  
Weight = 1
  
}
  
Server r2 {
  
Address = 203. x. x. d
  
Active = 1
  
Weight = 1
  
}
  
}
  
The above settings are used to balance the web access of a domain name. Director uses ssh to regularly collect the load on the RealServer, and then decides the distribution of Loadbalance. The allocation method is WLC, start the pulse service and check whether there are any configuration errors in/var/log/message. The settings in RHEL3 are very convenient and simple.
  
   RealServer Configuration:
  
The RS system is Rhel3, which requires different settings for DR and Tunl, but the key is the arp problem. The noarp module used here, of course, arptables are also provided in Rhel3 to cooperate with lvs (the effect may not be good). Here we will introduce noarp.
  
Noarp compilation is not introduced. After configure install, insmod noarp adds noarp to the kernel and then needs to execute
  
Noarpctl add 203. x. x. B 203. x. x.
  
This is to redirect all arp requests to 203. x. x. B to 203. x. x. a (Director), and then create a virtual ip address to complete the routing.
  
You need to set up a NIC for DR, and set it to eth0 or lo.
  
Ifconfig eth0: 1 203. x. x. B netmask quota limit 255 up
  
Enable the Tunl virtual Nic In tunl mode.
  
Ifconfig tunl0 203. x. x. B netmask running 255.255.255 up
  
Same settings on RealServer2
  
Start apache on two realservers
  
Check the connection on ctor
  
Ipvsadm-Ln
  
Check the current load distribution.
  
There is no doubt about the stability of lvs. The LVS in Rhas2.1 and Rhel3 is extremely stable during the 4-year usage of this lazy person. The access volume is nearly 10 KB from hundreds of online users at the time, you only need to add the RealServer after the load, but the LVS of Rhas2.1 does not support Tunl. We recommend that you use Rhel3 for Loadbalance in the tunl mode.
  
   A few additional questions:
  
Lvs has been stable over the past two years, and there have been a lot of applications. maillist has been very active. You can find answers to some questions in maillist. I don't need to look at it as I was: p.
  
The above is just a simple lvs application. Other complex applications can be searched on the lvs homepage and maillist.
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.