1 真实服务器real server 配置
1.1.1 Lvs_rs的配置。
在
/etc/rc.d/init.d/
中新建一个脚本。
注:我会提供已经写好的脚本,只需复制就行了,脚本名字叫
lvs_rs,
复制到
/etc/rc.d/init.d
下(如下)
lvs_rs
脚本代码
#!/bin/sh
# chkconfig: 2345 72 08
# description: Config realserver lo:0 port and apply arp patch
VIP=192.168.48.88 (
这个是服务器虚拟
ip
地址
)
. /etc/rc.d/init.d/functions
case $1 in
start)
echo "lo:0 port starting"
echo "0" >/proc/sys/net/ipv4/ip_forward
/sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
/sbin/route add -host $VIP 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
;;
stop)
echo "lo:0 port closing"
ifconfig lo:0 down
echo "1" > /proc/sys/net/ipv4/ip_forward
echo "0" > /proc/sys/net/ipv4/conf/all/arp_announce
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
chmod +x /etc/rc.d/init.d/lvs_rs
chkconfig --add lvs_rs
将
lvs_dr
和
lvs_switch
复制到
/etc/ha.d/resource.d/
注:
lvs_dr
和
lvs_switch
的脚本我会提供。(如下)
1.1.2 启动服务
主节点
备用节点都起动服务
service heartbeat start
/etc/ha.d/resource.d/ldirectord start
2 测试
查看主
lvs
的
ip
信息,现在
vip
在主
lvs
上面。
[root@LVS-1 ha.d]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:8F:E7:BB
inet addr:192.168.48.83 Bcast:192.168.48.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe8f:e7bb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:89174618 errors:0 dropped:0 overruns:0 frame:0
TX packets:89490628 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1239724978 (1.1 GiB) TX bytes:1269730040 (1.1 GiB)
Interrupt:67 Base address:0x2000
eth1 Link encap:Ethernet HWaddr 00:0C:29:8F:E7:C5
inet addr:192.168.48.96 Bcast:192.168.48.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe8f:e7c5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:434447 errors:0 dropped:0 overruns:0 frame:0
TX packets:47667 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:102561548 (97.8 MiB) TX bytes:4773970 (4.5 MiB)
Interrupt:67 Base address:0x2080
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:283823 errors:0 dropped:0 overruns:0 frame:0
TX packets:283823 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:34704953 (33.0 MiB) TX bytes:34704953 (33.0 MiB)
lo:0 Link encap:Local Loopback
inet addr:192.168.48.88 Mask:255.255.255.255
UP LOOPBACK RUNNING MTU:16436 Metric:1