#!/bin/bash## lvsdrrs init script to hide loopback interfaces on LVS-DR# Real servers. Modify this script to suit# your needs. You at least need to set the correct VIP address(es).## Script to start LVS DR real server.## chkconfig: 2345 20 80# description: LVS DR real server## You must set the VIP address to use here:VIP=10.0.0.20/etc/rc.d/init.d/functionscase "$1" instart) # Start LVS-DR real server on this machine. 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 /sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up;;stop) # Stop LVS-DR real server loopback device(s). /sbin/ifconfig lo:0 down;;status) # Status of LVS-DR real server. islothere=`/sbin/ifconfig lo:0 | grep $VIP` isrothere=`netstat -rn | grep "lo" | grep $VIP` if [ ! "$islothere" -o ! "$isrothere" ];then # Either the route or the lo:0 device # not found. echo "LVS-DR real server Stopped." else echo "LVS-DR Running." fi;;*) # Invalid entry. echo "$0: Usage: $0 {start|status|stop}" exit 1;;esac
# /etc/init.d/lvs start
7、启动相关
在RS1\RS2上启动
/etc/init.d/lvs start
在DR1/DR2上启动
/etc/init.d/heartbeat start
然后就可以测试了
看到有的网站上写的需要给主备heartbeat写脚本,其实是不需要的。--------------------------------------------HA主备切换报错,无法切换ERROR: Could not send gratuitous arps. rc=127
解决办法:ldd /usr/lib/heartbeat/send_arp,看看读取的libnet.so.0属于哪个路径,如果没有的话,弄个软连接过去吧。
libnet.so.1 => not found