Zookeeper
High-availability LVS cluster configuration for direct routing:
Scheduling Server IP Address: (106.3.43.240) 192.168.11.100. The Node servers are 192.168.11.101 and 192.168.11.102 respectively.
1. Install ipvsadmin:
1. Yum-y install ipvsadmin (the first method is recommended)
2. Download http://www.linuxvirtualserver.org/software/and find the desired region:
Note that the corresponding kernel version
Ipvsadm-1.24.tar.gz
Tar zxvf ipvsadm-1.24.tar.gz
CD ipvsadm-1.24
Make
Make install
To compile properly, you need to connect the kernel as a software to the installation directory:
Ln-S/usr/src/kernels/2.6.9-22. EL-i686 // usr/src/Linux
CD ipvsadm-1.24
Make
Make install
Ii. Configure the scheduling Server:
1. Add nodes:
Clear first:
/Sbin/ipvsadm-C
Add:
/Sbin/ipvsadm-a-t 192.168.11.100: 80-s RR # (if session persistence is required,-P is set to 300 s by default)
/Sbin/ipvsadm-a-t 192.168.11.100: 80-r 192.168.11.101: 80-G
/Sbin/ipvsadm-a-t 192.168.11.100: 80-r 192.168.11.102: 80-G
#/Sbin/ipvsadm-a-t $ VIP: 80-r $ rip3: 80-g (multiple nodes)
#/Sbin/ipvsadm-d-r $ VIP: 80-r $ rip3: 80-g (delete node)
Note: 1. Option-A indicates adding a server,-T indicates the VIP address and TCP port, and-R indicates the rip address and TCP port, -M indicates that the NAT cluster mode (-G
Dr mode and-I Tun mode).-W is used to set the weight and then set the weight (when the weight is 0, the node is suspended ).
2. When you need to delete the entire virtual server, use option-D and specify the virtual IP address. You do not need to specify a node. For example, if "ipvsadm-D-T 192.168.11.101: 80" is executed, the virtual server is deleted.
2. Add a virtual IP address to the first NIC (Internet) and route it (only one NIC with its address 106.3.43.240 ):
/Sbin/ifconfig eth0: 0 192.168.11.100 broadcast 192.168.11.255 netmask 255.255.255.255 up
/Sbin/route add-host 192.168.11.100 Dev eth0: 0
3. Run LVS
/Sbin/ipvsadm
4. You can run the following script:
# Vi/etc/init. d/lvsrs
#! /Bin/sh
# Description: Start LVS of directorserver
VIP = 192.168.11.100
Rip1 = 192.168.11.101
Rip2 = 192.168.11.102
# Ripn = 192.168.11.103 ~ 254 (add other nodes)
GW = 192.168.11.1
./Etc/rc. d/init. d/functions
Case $1 in
Start)
Echo "Start LVS of directorserver"
# Set the virtual IP Address
/Sbin/ifconfig eth0: 0 $ VIP broadcast $ VIP netmask 255.255.255.255 up
/Sbin/route add-host $ VIP Dev eth0: 0
# Clear ipvs table
/Sbin/ipvsadm-C
# Set LVS
/Sbin/ipvsadm-a-t $ VIP: 80-s RR # (if session persistence is required,-P is maintained for 300 seconds by default)
/Sbin/ipvsadm-a-t $ VIP: 80-r $ rip1: 80-G
/Sbin/ipvsadm-a-t $ VIP: 80-r $ rip2: 80-G
#/Sbin/ipvsadm-a-t $ VIP: 80-r $ rip3: 80-G
# Run LVS
/Sbin/ipvsadm
# End
;;
Stop)
Echo "Close LVS directorserver"
/Sbin/ipvsadm-C
;;
*)
Echo "Usage: $0 {START | stop }"
Exit 1
Esac
(-S RR uses the wheel call algorithm. If you want to modify other algorithms, you can change the RR. ipvsadm-h to view help. -G is the direct routing mode using LVS working dr)
3. Configure the node Server:
1. Configure the network:
/Sbin/ifconfig lo: 0 192.168.11.100 broadcast 192.168.11.255 netmask 255.255.255.255 up
/Sbin/route add-host 192.168.11.100 Dev lo: 0
2. Modify sysct1.conf:
Sysctl-W net. ipv4.ip _ forward = 0
Sysctl-W net. ipv4.conf. Lo. arp_ignore = 1
Sysct1-W net. ipv4.conf. Lo. arp_announce = 2
Sysct1-W net. ipv4.conf. All. arp_ignore = 1
Sysct1-W net. ipv4.conf. All. arp_announce = 2
Or:
Echo "1">/proc/sys/NET/IPv4/CONF/LO/arp_ignore
Echo "2">/proc/sys/NET/IPv4/CONF/LO/arp_announce
Echo "1">/proc/sys/NET/IPv4/CONF/All/arp_ignore
Echo "2">/proc/sys/NET/IPv4/CONF/All/arp_announce
Or VI sysctl
Net. ipv4.ip _ forward = 0
Net. ipv4.conf. Lo. arp_ignore = 1
Net. ipv4.conf. Lo. arp_announce = 2
Net. ipv4.conf. All. arp_ignore = 1
Net. ipv4.conf. All. arp_announce = 2
Run: sysctl-P
3. write the script as follows:
#! /Bin/bash
# Description: Start RealServer
VIP = 192.168.11.100
/Sbin/ifconfig lo: 0 $ VIP broadcast $ VIP netmask 255.255.255.255 up
/Sbin/route add-host $ VIP Dev lo: 0
Echo "1">/proc/sys/NET/IPv4/CONF/LO/arp_ignore
Echo "2">/proc/sys/NET/IPv4/CONF/LO/arp_announce
Echo "1">/proc/sys/NET/IPv4/CONF/All/arp_ignore
Echo "2">/proc/sys/NET/IPv4/CONF/All/arp_announce
Sysctl-P
# End
Iv. test:
Test: Start the HTTPd service on the RealServer respectively (the WWW/html folder of the node server can be mounted together with Nas)
Run echo "this is realserver1">/var/www/html/index.html in realserver1.
Run echo "this is realserver2">/var/www/html/index.html in realserver2.
Open the IE browser and enter http: // 192.168.11.100. You can see this is realserver1 and this is realserver1.
View node status:
# Ipvsadm-l-N
View the load connection status:
# Ipvsadm-lnc
LVS Load Scheduling Algorithm
For different network services and Configuration Requirements, The LVS scheduler provides a variety of different load scheduling algorithms. The four most commonly used algorithms include round robin, Weighted Round Robin, and least
Connections and weighted least connections.
Round Robin
The actual number of connections and system load of the management server.
Weighted Round Robin (Weighted Round Robin): requests for received access are distributed in turn based on the processing capabilities of the Real Server. The scheduler can automatically query the load conditions of each node.
And dynamically adjust its weight. In this way, servers with high processing capabilities can take on more access traffic.
Least connections (least connections): allocates requests based on the number of established connections on the Real Server. Requests are preferentially distributed to nodes with the least number of connections. For example
If the performance of all server nodes is similar, this method can better balance the load.
Weighted Least connections (weighted least connections): When the performance of server nodes varies greatly, the weights can be automatically adjusted for the Real Server.
High nodes will carry a larger proportion of active connection load.
5. Add backup to the scheduling Server:
1. Download heartbeatak or install Yum-y install heartbeat directly.
(Need to install: epel-release package, 32 bit: wget http://mirrors.sohu.com/fedora-epel/6/i386/epel-release-6-8.noarch.rpm 64 bit: wgethttp: // mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm)
Modify the epel. Repo file:
Compile/etc/yum. Repos. d/epel. Repo and make the following changes:
# Baseurl = http://download.fedoraproject.org/pub/epel/6/?basearch
Using list = https://mirrors.fedoraproject.org/metalink? Epel-6 & arch = $ basearch
Changed:
Baseurl = http://download.fedoraproject.org/pub/epel/6/?basearch
# Items list = https://mirrors.fedoraproject.org/metalink? Epel-6 & arch = $ basearch
2. Configure heartbeat
# Chkconfig -- levels 235 heartbeat on
Copy three files:
# Cp/usr/share/doc/heartbeat-3.0.4/ha. Cf/etc/ha. d/# configuration file of HA. Cf ha
# Cp/usr/share/doc/heartbeat-3.0.4/haresources/etc/ha. d/# haresources resource file
# Cp/usr/share/doc/heartbeat-3.0.4/authkeys/etc/ha. d/# authentication file between HA nodes
Configuration:
# Vi/etc/ha. d/ha. cf
Debugfile/var/log/ha-Debug
Logfile/var/log/ha-Log
Logfacility local0
Keepalive 2
Deadtime 30
Warntime 10
Initdead 120
Udpport 694
Ucast eth1 1.1.1.2 # Heartbeat
Auto_failback on
Node DR1
Node Dr2
Ping 172.16.1.1 172.16.1.11 # IP address of the gateway and another node
Respawn hacluster/usr/lib/heartbeat/ipfail
Deadping 30
Apiauth ipfail uid = hacluster
Use_logd Yes
Conn_logd_time 60
# Vi/etc/ha. d/authkeys # define the authenticated keys
Auth 1
1 CRC
# Chmod 600/etc/ha. d/authkeys modify authkeys File Permissions
# Vi/etc/ha. d/haresources # configure ha Resources
DR1 ipaddr: 192.168.11.100/24/eth0 httpd
Start heartbeat:
# Service heartbeat start