Linux Cluster- LVS (DR) + heartbeat
LVS + heartbeat
Lvs1AndLvs2The configuration script is the same for the same job. The only difference is thatHeartbeatConfiguration FileHa. cfThe heartbeat address is different.
AuthenticWeb,MySQL,FTP...... Same Configuration
LVSConfiguration
#! /Bin/bash
###### LVS ######
Ifconfig eth0: 0 222.90.88.88 broadcast 222.90.88.88 netmask 255.255.255 up
Route add-host 222.90.88.88 Dev eth0: 0
Ipvsadm-C
Ipvsadm-a-t 222.90.88.88: 80-s rr
Ipvsadm-a-t 222.90.90.88.88: 80-r 222.90.88.10-G
Ipvsadm-a-t 222.90.90.88.88: 80-r 222.90.88.20-G
Ipvsadm
WebConfiguration
#! /Bin/bash
###### Real Server ######
Ifconfig lo: 0 222.90.88.88 broadcast 222.90.88.88 netmask 255.255.255.255 up
Route add-host 222.90.88.88 Dev lo: 0
###### Ipvsadm ######
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
Operation:
FourLinuxHost (Lvs1, lvs2AndSev1, sev2)
Lvs1InstallHeartbeat
# Rpm-IVH heartbeat-pils-2.1.3-3.el5.centos.i386.rpm
# Rpm-IVH heartbeat-stonith-2.1.3-3.el5.centos.i386.rpm
# Rpm-IVH heartbeat-2.1.3-3.el5.centos.i386.rpm
# Rpm-Q heartbeat-d(Decompress the file)
# Cd/usr/share/docheartbeat-2.1.3/
# Cp authkeys ha. Cf haresources/etc/ha. d
# Cd/etc/ha. d
# Vim authkeys
......
Auth 1
1 CRC
......
# Vim/haresources
......
Vip-server1 222.90.88.88 VIP. Sh(Lvs1,VIP. ShStored in/Etc/init. d [Auto Start upon startup])
......
# Vim/ha. cf
.......
Bcast eth0 # Linux(Heartbeat detection Nic)
.......
Ucast eth0 222.90.88.40(Ping lvs2)
.......
Node vip-server1(Lvs1Machine name)
Node vip-server2(Lvs2Machine name)
.......
# Chmod 600 authkeys
# Vim/etc/init. d/VIP. Sh
#! /Bin/sh
Ifconfig eth0: 0 222.90.88.88 broadcast 222.90.88.88 netmask 255.255.255 up
Route add-host 222.90.88.88 Dev eth0: 0
###### Setup ipvs ######
Ipvsadm-C
Ipvsadm-a-t 222.90.88.88: 80-s rr
Ipvsadm-a-t 222.90.88.88: 80-r 222.90.88.10-G
Ipvsadm-a-t 222.90.88.88: 80-r 222.90.88.20-G
Ipvsadm
# Chmod 777 VIP. Sh
#/Etc/init. d/VIP. Sh
Lvs2InstallHeartbeat
# Rpm-IVH heartbeat-pils-2.1.3-3.el5.centos.i386.rpm
# Rpm-IVH heartbeat-stonith-2.1.3-3.el5.centos.i386.rpm
# Rpm-IVH heartbeat-2.1.3-3.el5.centos.i386.rpm
# Rpm-Q heartbeat-d(Decompress the file)
# Cd/usr/share/docheartbeat-2.1.3/
# Cp authkeys ha. Cf haresources/etc/ha. d
# Cd/etc/ha. d
# Vim authkeys
......
Auth 1
1 CRC
......
# Vim/haresources
......
Vip-server1 222.90.88.88 VIP. Sh(Lvs1,VIP. ShStored in/Etc/init. d [Auto Start upon startup])
......
# Vim/ha. cf
.......
Bcast eth0 # Linux(Heartbeat detection Nic)
.......
Ucast eth0 222.90.88.30(Ping lvs1)
.......
Node vip-server1(Lvs1Machine name)
Node vip-server2(Lvs2Machine name)
.......
# Chmod 600 authkeys
# Vim/etc/init. d/VIP. Sh
#! /Bin/sh
Ifconfig eth0: 0 222.90.88.88 broadcast 222.90.88.88 netmask 255.255.255 up
Route add-host 222.90.88.88 Dev eth0: 0
###### Setup ipvs ######
Ipvsadm-C
Ipvsadm-a-t 222.90.88.88: 80-s rr
Ipvsadm-a-t 222.90.88.88: 80-r 222.90.88.10-G
Ipvsadm-a-t 222.90.88.88: 80-r 222.90.88.20-G
Ipvsadm
# Chmod 777 VIP. Sh
#/Etc/init. d/VIP. Sh
Ser1Operation
# Vim/etc/init. d/LVS. Sh
#! /Bin/sh
###### RealServer ######
Ifconfig lo: 0 222.90.88.88 broadcast 222.90.88.88 netmask 255.255.255.255 up
Route add-host 222.90.88.88 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
# Vim/var/www/html/index.html
This is ser1
# Service httpd start
Ser2Operation
# Vim/etc/init. d/LVS. Sh
#! /Bin/sh
###### RealServer ######
Ifconfig lo: 0 222.90.88.88 broadcast 222.90.88.88 netmask 255.255.255.255 up
Route add-host 222.90.88.88 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
# Vim/var/www/html/index.html
This is ser2
# Service httpd start
Test Fault status
Lvs2heartbeatStop,Lvs1Normal;Ser1, ser2Normal
Lvs1 heartbeatStop,Lvs2Normal;Ser1, ser2Normal
Lvs1Normal,Lvs2Normal;Ser1Abnormal, Ser2Normal
Lvs1Normal,Lvs2Normal;Ser1Normal, Ser2Abnormal