Chinaunix首页 | 论坛 | 博客
  • 博客访问: 876472
  • 博文数量: 275
  • 博客积分: 3904
  • 博客等级: 中校
  • 技术积分: 4605
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-17 21:10
文章分类

全部博文(275)

文章存档

2014年(9)

2013年(124)

2012年(142)

分类: 系统运维

2013-04-16 13:01:47

Linux集群-LVS(DR)+Heartbeat

LVS+Heartbeat

  


LVS1LVS2所完成一样的工作,那么配置脚本也相同。唯一不同的是heartbeat配置文件ha.cf心跳地址不同。

真实的webmysqlftp……配置一样

LVS配置

 #!/bin/bash

 ######lvs######

 ifconfig eth0:0 222.90.88.88 broadcast 222.90.88.88 netmask 255.255.255.255 up

 route add -host 222.90.88.88 dev eth0:0

  -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

Web配置

 #!/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

 

操作:

 四台LINUX主机(LVS1,LVS2SEV1,SEV2

 LVS1安装heartbeat

  #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(解压文件)

 #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.shLVS1vip.sh存放在/etc/init.d[开机时自启]

  ……

 #vim /ha.cf

  …….

  bcast eth0 #Linux (心跳检测网卡)

  …….

  ucast eth0 222.90.88.40 ping  LVS2

  …….

  node vip-server1  LVS1机器名)

  node vip-server2  LVS2机器名)

  …….

 #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.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

 

  LVS2安装heartbeat

  #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(解压文件)

 #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.shLVS1vip.sh存放在/etc/init.d[开机时自启]

  ……

 #vim /ha.cf

  …….

  bcast eth0 #Linux (心跳检测网卡)

  …….

  ucast eth0 222.90.88.30 ping  LVS1

  …….

  node vip-server1  LVS1机器名)

  node vip-server2  LVS2机器名)

  …….

 #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.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


 SER1操作

 #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

 

SER2操作

 #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


测试故障状态

 LVS2heartbeat停止,LVS1正常;SER1,SER2正常

 LVS1 heartbeat停止,LVS2正常;SER1,SER2正常

 LVS1正常,LVS2正常;SER1不正常,SER2正常

 LVS1正常,LVS2正常;SER1正常,SER2不正常

阅读(2961) | 评论(2) | 转发(6) |
给主人留下些什么吧!~~

7907979522013-04-17 17:17:00

来过啊  。。。。。。。有水平