在RedHat EL 4.0 中实现高可用WEB负载均衡群集
2009-04-30 11:08:37 来源:WEB开发网一、Director配置
1、设置网络接口地址
[root @director root] # vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.0.255
HWADDR=00:0C:29:A2:BD:B5
IPADDR=192.168.0.160
NETMASK=255.255.255.0
NETWORK=192.168.0.0
ONBOOT=yes
2、编辑 lvs 脚本
[root @director root] # vi /etc/init.d/lvsdr
#!/bin/bash
VIP=192.168.0.222
RIP1=192.168.0.249
RIP2=192.168.0.251
/etc/rc.d/init.d/funcions
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
/sbin/ipvsadm -a -t $VIP:80 -r $RIP1:80 -g
/sbin/ipvsadm -a -t $VIP:80 -r $RIP2:80 -g
#Run Lvs
/sbin/ipvsadm
;;
stop)
echo "close LVS Directorsever"
/sbin/ipvsadm -C
/sbin/ifconfig eth0:0 down
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
# 保存并退出,将该文件设置为可执行文件
[root @director root] # chmod 755 /etc/init.d/lvsdr
3、安装 ipvsadm
[root @ Director root] # modprobe –l | grep ipvs
更多精彩
赞助商链接