2011-04-14 16:27:52| 分类: Linux Cluster | 标签: |举报 |字号大中小 订阅
u 拓扑描述
根据实际网络情况可在
后端web服务器1:192.168.15.233
后端web服务器2:192.168.15.234
负载服务器master:wlan-192.168.15.253
Lan-10.0.0.1
负载服务器backup:192.168.15.236
u Real机配置
需根据具体网络环境设置(a或b)
a. 设置网关
/etc/sysconfig/network-scripts/ifcfg-eth0 添加
GATEWAY=10.0.0.1
b.添加默认网关
route add default gw 10.0.0.1 (提示:删除则用delete)
u 调度器ipvsadm设置
#echo 1 > /proc/sys/net/ipv4/ip_forward (开启路由机制)
[root@localhost ~]# cat /root/ipvsadm.sh
#!/bin/sh
VIP=192.168.15.253
VIP_LAN=10.0.0.1
RIP1=10.0.0.233
RIP2=10.0.0.234
case "$1" in
start)
echo " start LVS "
# set the Virtual IP Address
# /sbin/modprobe ipip
# /sbin/ifconfig eth0:0 $VIP broadcast $VIP netmask 255.255.255.255 up
# /sbin/route add -host $VIP dev eth0:0
/sbin/ifconfig eth0:2 $VIP_LAN netmask 255.255.255.0 broadcast 10.0.0.255 up
/sbin/ipvsadm -C
/sbin/ipvsadm -A -t $VIP:80 -s wlc
/sbin/ipvsadm -a -t $VIP:80 -r $RIP1:80 -m -w 1
/sbin/ipvsadm -a -t $VIP:80 -r $RIP2:80 -m -w 1
;;
stop)
echo "close LVS Director"
/sbin/ipvsadm -C
/sbin/ifconfig eth0:2 down
# /sbin/modprobe -r ipip
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
测试验证正常
u Master Keepalived配置
[root@localhost ~]# vi /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
88fly@163.com
chenhaibo@myhexin.com
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server smtp.163.com
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 5
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.15.253
}
}
virtual_server 192.168.15.253 80 {
#delay_loop 10
lb_algo wlc
lb_kind NAT
# persistence_timeout 1
protocol TCP
# sorry_server 127.0.0.1 80
real_server 10.0.0.233 80 {
weight 1
TCP_CHECK {
connect_timeout 1
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 10.0.0.234 80 {
weight 1
TCP_CHECK {
connect_timeout 1
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
backup机对应修改即可
u 验证配置
关闭ipvsadm—> /root/ipvsadm.sh stop
添加IP /sbin/ifconfig eth0:2 10.0.0.1 netmask 255.255.255.0 broadcast 10.0.0.255 up
启动keepalived验证 service keepalived start
评论