Linux LVS + heartbeat

Source: Internet
Author: User
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

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.