http://wangwq.blog.51cto.com/8711737/1852212
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
vim
/usr/local/bin/lvs_real
.sh
#! /bin/sh
# descript :start RealServer.
VIP=192.168.30.88
.
/etc/rc
.d
/init
.d
/functions
case
"$1"
in
start)
echo
"start LVS of RealServer"
/sbin/ifconfig
lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
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
;;
stop)
/sbin/ifconfig
lo:0 down
echo
"close LVS of RealServer"
echo
"0"
>
/proc/sys/net/ipv4/conf/lo/arp_ignore
echo
"0"
>
/proc/sys/net/ipv4/conf/lo/arp_announce
echo
"0"
>
/proc/sys/net/ipv4/conf/all/arp_ignore
echo
"0"
>
/proc/sys/net/ipv4/conf/all/arp_announce
;;
*)
echo
"Usage : $0 {start|stop}"
exit
1
esac
|
1
|
/usr/local/bin/lvs_real
.sh start
|
1
|
ip addr
|
1
2
3
4
5
6
7
8
9
|
vim
/etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8087 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8088 -j ACCEPT
-A INPUT -pvrrp -j ACCEPT
:wq 保存退出
service iptables restart
|
1
2
3
4
|
vim
/etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8087 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8088 -j ACCEPT
|
1
2
3
4
|
vim
/etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8087 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8088 -j ACCEPT
|
1
2
3
|
vim
/etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
|
1
2
3
|
vim
/etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
|
1
|
service iptables restart
|
1
|
/etc/init
.d
/keepalived
restart
|
1
|
tail
-f
/var/log/messages
|
1
|
ip addr
|
1
|
tail
-f
/var/log/messages
|