Centos6.4 Configuring LVS + Piranha High Availability Load Balancing

  

1. Introduction to LVS

1. Provide high availability and load balancing capabilities for application servers to meet the needs of large concurrent access 2. Cost savings. An alternative to commercial hardware load balancers, offering start-up IT companies a low-cost solution. Ideal.

Second, software introduction

1. LVS Introduction LVS is an open source software, founded by Dr. Zhang Wenzhao, who graduated from National University of Defense Technology in May 1998, can realize the simplicity of LINUX platform. Load balancing. LVS is an acronym for Linux Virtual Server, which means a Linux virtual server.
1.1 Working Principle LVS consists of a front-end load balancer (LB) and a back-end real server (Real Server, RS) group. The RSs can be connected via a LAN or WAN. The structure is transparent to the user, and the user can only see one virtual server (Virtual Server) as the LB, and does not see the RS group providing the service. When the user's request is sent to the virtual server, the LB forwards the user request to the RS according to the set packet forwarding policy and the load balancing scheduling algorithm. The RS then returns the result of the user request to the user. Like the request packet, the return mode of the response packet is also related to the packet forwarding policy.
1.2 Three-tier structure (1) Load Balancer: The scheduler is the front end of the entire cluster system and is responsible for forwarding client requests to the Real Server.
Backup is the backup load scheduler. When Master Load Balancer is unavailable, Backup is replaced and becomes Master Load Balancer. Load Balancer monitors the health of each Real Server through Ldirectord. Remove the Real Server from the group when it is unavailable, and rejoin it when it is restored. (2) Server pool: Server pool is a group of machines running actual application services, such as WEB, Mail, FTP, DNS, Media, etc. (3) Shared Storage: Shared Storage provides shared storage and consistent data content for all Real Servers. 1.3 Implementation Mode 1) Virtual Server via NAT2) Virtual Server via IP Tunneling 3) Virtual Server via Direct Routing 1.4 Scheduling Algorithm

There are ten kinds of IPVS load scheduling algorithms:


Round Robin
Weighted Round Robin
Least Connections
Weighted Least Connections
Locality-Based Least Connections)
Locality-Based Least Connections with Replication
Destination Hashing
Source Hashing
Shortest Expectation Delay (Shortest Expected Delay)
No Queue Waiting (Never Queue)

2. Piranha Introduction A web configuration software similar to keepalived, the advantages are convenient and intuitive, and can be configured in 30 minutes. LVS-based load balancing high availability solution.
2.1 Piranha Components > Pluse is responsible for the health status detection between the master scheduler and the backup scheduler, the heartbest communication process. > Lvsd Lvsd process activity In the LVS router, read /etc/sysconfig/ha/lvs.cf, call ipvsadm to build and maintain the IPVS routing table, and assign nanny to each configured LVS service. > Ipvsadm This service updates and maintains the IPVS routing table in the kernel. The LVS process adds, modifies or deletes the IPVS routing table by calling ipvsadm. > Nanny Nanny exists in a router whose state is Active. Through this process, the active state scheduler can detect the status of each realserver while managing the monitoring load status. Each service defined in each realserver has an independent nanny process management. > Send_arp When the active scheduler fails, the standby scheduler calls send_arp to switch the virtual address to the backup scheduler. And send commands on the public network and the local area network to turn off the lvsd process, and at the same time start the LVSD process that backs up the weapon.

3. Configuration 3.1 Scheme IP Information List

Name IP Heartbeat Address

LVS-Active 192.168.2.167 /24 10.0.0.1/32

LVS -Backup 192.168.2.165/24 10.0.0.2/32

Real-Server1 192.168.0.112

Real-Server2 192.168.0.113

LVS-VIP 192.168.2.168

3.2 Configuration Environment:

Director: CentOS 6.4

RealServer: Windows
Server Enterprise 2003, CentOS 6.4

Configuration: VS/DR (direct routing)

Software: ipvsadm+piranha

3.3.1 Install lvs, Piranha, PHP
.

#yum install ipvsadm modcluster piranha system‐config‐cluster php php‐cli php‐common

3.3.2 Configuring Piranha Master LVS Server
#vim /etc/sysctl.conf //Modify the system parameters Net.ipv4.ip_forward = 1 //Change the default 0 to 1, open IP forwarding #sysctl – p //execute the command immediately effective

3.3.2.2 start piranha service

#/etc/init.d/piranha-gui start //Start piranha service

#/usr/sbin/piranha-passwd //Set piranha login password

Open with browser management page: http: //localhost: 3636 Figure:

landing page management username: piranha password: input (execution /usr /sbin /piranha-passwd) after the password

< Br>3.3.3 Configuring the main LVS server
Click GLOBAL SETINGS > Primary server public IP : 192.168.2.167
Primary server private IP ( May be blank) : 10.0.0.1 //Heartbeat address
Use network Type : Direct Routing //Direct routing method
Click ACCEPT //Deposit


3.3.4 Configuration Backup Server (not to deploy the backup LVS direct view 3.3.5)
Click ENABLE to activate a redundant server
Redundant server public IP: 192.168.2.165 //Backup LVS address
Heartbeat interval (seconds): 6 //heartbeat network detection time
Assume dead after (seconds): 18 //death transfer time
Heartbeat runs on port: 539 //monitored port
Monitor NIC links for failures: failures do not check //link card options
Syncdaemon: //uncheck synchronization daemon options

3.3.5 virtual server configuration & gt; click on vIRTUAL sERVER & gt; ADD
Add a heart record and edit
name : LVS-VIP //Custom Name
Application port :80 //Monitor Use port number
Protocol :tcp //Monitor network protocol type
Virtual IP Address:192.168.2.168 //Virtual server IP address
Virtual IP Network Mask: 255.255.255.255 //Virtual service mask
Device: p4p1:0 //Virtual IP device host>
Re-entry time: 15 //Remove time after RS ​​removal
Service timeout: 6 //Visit time after RS ​​failure
> Scheduling: WRR //scheduling algorithm
Persistence: 30 //maintain time
Persistence Network Mask:255.255.255.255 //Mask

Copyright © Windows knowledge All Rights Reserved