LVS DR模式启动脚本
admin
2023-01-25 01:00:05
0

LVS DR模式启动脚本
1、DR脚本:
[root@ipvs ~]# cat /etc/rc.local
#!/bin/sh
#

This script will be executed after all the other init scripts.

You can put your own initialization stuff in here if you don't

want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
#/usr/local/apache/bin/apachectl -f /usr/local/apache/conf/httpd.conf -k start
/root/dr_start.sh
[root@ipvs ~]# cat dr_start.sh
#!/bin/bash

ifconfig eth0:0 192.168.1.100
ipvsadm -A -t 192.168.1.100:80 -s wlc
ipvsadm -a -t 192.168.1.100:80 -r 192.168.1.102:80 -g -w 2
ipvsadm -a -t 192.168.1.100:80 -r 192.168.1.105:80 -g -w 1
ipvsadmin -Ln

2、realserver脚本:
[root@web100 ~]# cat /etc/rc.local
#!/bin/sh
#

This script will be executed after all the other init scripts.

You can put your own initialization stuff in here if you don't

want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
#/usr/local/apache/bin/apachectl -f /usr/local/apache/conf/httpd.conf -k start
/root/rs_start.sh
[root@web100 ~]# cat rs_start.sh
#!/bin/bash

echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
ifconfig lo:0 192.168.1.100 netmask 255.255.255.255
route add -host 192.168.1.100 dev lo:0
ifconfig
route -n

VIP和RIP不在同一网段:
LVS DR模式启动脚本
gateway配置:
[root@gateway ~]# ip addr
2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:eb:92:bc brd ff:ff:ff:ff:ff:ff
inet 192.168.1.102/24 brd 192.168.1.255 scope global eth0
inet6 fe80::20c:29ff:feeb:92bc/64 scope link
valid_lft forever preferred_lft forever
3: eth2: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:eb:92:c6 brd ff:ff:ff:ff:ff:ff
inet 192.168.11.102/24 brd 192.168.11.255 scope global eth2
inet6 fe80::20c:29ff:feeb:92c6/64 scope link
valid_lft forever preferred_lft forever
4: eth3: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:eb:92:d0 brd ff:ff:ff:ff:ff:ff
inet 192.168.10.102/24 brd 192.168.10.255 scope global eth3
inet6 fe80::20c:29ff:feeb:92d0/64 scope link
valid_lft forever preferred_lft forever

[root@gateway ~]# sysctl -p
net.ipv4.ip_forward = 1

[root@gateway ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.11.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth3
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth2
169.254.0.0 0.0.0.0 255.255.0.0 U 1004 0 0 eth3

192.168.1.101.61378 > 192.168.11.10.http: Flags [F.], cksum 0x8b64 (correct), seq 506, ack 283, win 16354, length 0

15:05:50.085817 00:0c:29:71:d0:bc (oui Unknown) > 00:0c:29:eb:92:d0 (oui Unknown), ethertype IPv4 (0x0800), length 60: (tos 0x0, ttl 64, id 16893, offset 0, flags [DF], proto TCP (6), length 40)
192.168.11.10.http > 192.168.1.101.61378: Flags [.], cksum 0xca51 (correct), seq 283, ack 507, win 245, length 0
15:05:50.085829 00:0c:29:eb:92:bc (oui Unknown) > 00:e0:4c:92:95:82 (oui Unknown), ethertype IPv4 (0x0800), length 54: (tos 0x0, ttl 63, id 16893, offset 0, flags [DF], proto TCP (6), length 40)

IPVS配置:
[root@ipvs ~]# ip addr
2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:0a:98:12 brd ff:ff:ff:ff:ff:ff
inet 192.168.11.103/24 brd 192.168.11.255 scope global eth0
inet 192.168.11.10/32 brd 192.168.11.10 scope global eth0:0
inet6 fe80::20c:29ff:fe0a:9812/64 scope link
valid_lft forever preferred_lft forever
3: eth2: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:0a:98:1c brd ff:ff:ff:ff:ff:ff
inet 192.168.10.103/24 brd 192.168.10.255 scope global eth2
inet6 fe80::20c:29ff:fe0a:981c/64 scope link
valid_lft forever preferred_lft forever

[root@ipvs ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.11.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth2
0.0.0.0 192.168.11.102 0.0.0.0 UG 0 0 0 eth0

ifconfig eth0:0 192.168.11.10 netmask 255.255.255.255
ipvsadm -A -t 192.168.11.10:80 -s rr
ipvsadm -a -t 192.168.11.10:80 -r 192.168.10.104:80 -g
ipvsadm -a -t 192.168.11.10:80 -r 192.168.10.105:80 -g
watch 'ipvsadm -Ln'

192.168.1.101.61361 > 192.168.11.10.http: Flags [.], cksum 0x086c (correct), seq 1, ack 1, win 16425, length 0

15:05:44.292746 00:0c:29:eb:92:c6 (oui Unknown) > 00:0c:29:0a:98:12 (oui Unknown), ethertype IPv4 (0x0800), length 60: (tos 0x0, ttl 127, id 25228, offset 0, flags [DF], proto TCP (6), length 40)
192.168.1.101.61361 > 192.168.11.10.http: Flags [.], cksum 0x086c (correct), seq 1, ack 1, win 16425, length 0
15:05:44.292837 00:0c:29:0a:98:1c (oui Unknown) > 00:0c:29:71:d0:bc (oui Unknown), ethertype IPv4 (0x0800), length 60: (tos 0x0, ttl 127, id 25228, offset 0, flags [DF], proto TCP (6), length 40)

web配置:
[root@web01 ~]# ip addr
2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:d3:56:4f brd ff:ff:ff:ff:ff:ff
inet 192.168.10.104/24 brd 192.168.10.255 scope global eth0
inet6 fe80::20c:29ff:fed3:564f/64 scope link
valid_lft forever preferred_lft forever

[root@web01 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.11.10 0.0.0.0 255.255.255.255 UH 0 0 0 lo
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
0.0.0.0 192.168.10.102 0.0.0.0 UG 0 0 0 eth0

echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
ifconfig lo:0 192.168.11.10 netmask 255.255.255.255
ifconfig
route add -host 192.168.11.10 dev lo:0

192.168.1.101.61361 > 192.168.11.10.http: Flags [S], cksum 0x6a33 (correct), seq 2012475181, win 8192, options [mss 1460,nop,wscale 2,nop,nop,sackOK], length 0

15:05:44.662926 00:0c:29:71:d0:bc (oui Unknown) > 00:0c:29:eb:92:d0 (oui Unknown), ethertype IPv4 (0x0800), length 66: (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52)
192.168.11.10.http > 192.168.1.101.61361: Flags [S.], cksum 0xcebb (correct), seq 4055011495, ack 2012475182, win 14600, options [mss 1460,nop,nop,sackOK,nop,wscale 6], length 0
15:05:44.662929 00:0c:29:eb:92:bc (oui Unknown) > 00:e0:4c:92:95:82 (oui Unknown), ethertype IPv4 (0x0800), length 66: (tos 0x0, ttl 63, id 0, offset 0, flags [DF], proto TCP (6), length 52)
192.168.11.10.http > 192.168.1.101.61361: Flags [S.], cksum 0xcebb (correct), seq 4055011495, ack 2012475182, win 14600, options [mss 1460,nop,nop,sackOK,nop,wscale 6], length 0
15:05:44.662972 00:e0:4c:92:95:82 (oui Unknown) > 00:0c:29:eb:92:c6 (oui Unknown), ethertype IPv4 (0x0800), length 60: (tos 0x0, ttl 128, id 25228, offset 0, flags [DF], proto TCP (6), length 40)
192.168.1.101.61361 > 192.168.11.10.http: Flags [.], cksum 0x086c (correct), seq 1, ack 1, win 16425, length 0
15:05:44.663432 00:0c:29:eb:92:c6 (oui Unknown) > 00:0c:29:0a:98:12 (oui Unknown), ethertype IPv4 (0x0800), length 60: (tos 0x0, ttl 127, id 25228, offset 0, flags [DF], proto TCP (6), length 40)
192.168.1.101.61361 > 192.168.11.10.http: Flags [.], cksum 0x086c (correct), seq 1, ack 1, win 16425, length 0
15:05:44.663434 00:0c:29:0a:98:1c (oui Unknown) > 00:0c:29:71:d0:bc (oui Unknown), ethertype IPv4 (0x0800), length 60: (tos 0x0, ttl 127, id 25228, offset 0, flags [DF], proto TCP (6), length 40)

上一篇:如何制作RPM包

下一篇:LVS持久连接

相关内容

热门资讯

德国总理:美国正在被伊朗羞辱 德国之声4月27日报道,德国总理默茨在访问一所学校时表示,在当前的持续冲突中,伊朗领导层正试图羞辱美...
理响中国|“长”歌以行,风云激... 光阴如梭,东方潮阔。这里是中国的长三角,世界的长三角。无论过去、现在还是未来,这片土地都因时代而生,...
白宫:特朗普及其国安团队开会讨... 新华社华盛顿4月27日电 美国白宫新闻秘书莱维特27日在记者会上证实,总统特朗普及其国家安全团队当天...
人民日报刊文:日本放开杀伤性武... 日本放开杀伤性武器出口推高地缘冲突风险(国际论坛)常思纯《人民日报》(2026年04月28日 第 0...
医疗保障法草案二审:明确生育保... 满足多样化健康保障需求本报记者 彭 波4月27日,医疗保障法草案二审稿提请十四届全国人大常委会第二十...
天津一景区发生自转旋翼机事故1... 澎湃新闻记者 吕新文中国民用航空华北地区管理局4月22日公布《豪客通航“10•1”天津长芦汉盐旅游区...
卡塔尔埃米尔与美国总统特朗普通... 当地时间24日,卡塔尔埃米尔塔米姆与美国总统特朗普通电话,重点就中东地区局势以及伊朗与美国谈判问题交...
男子30年前被扣押2859克黄... 澎湃新闻记者 王鑫家住辽宁省大连市的潘永嘉近日向澎湃新闻反映称,三十年前,他在大连周水子机场被盖州市...
商务部:取消反制欧盟两家金融机... 中华人民共和国商务部令二〇二六年 第1号鉴于欧盟已取消对中国两家金融机构的制裁措施,现公布《关于取消...
过去24小时共有5艘船只通过霍... 总台记者当地时间24日获悉,过去24小时内,共有5艘船只通过霍尔木兹海峡,其中包括一艘伊朗油轮。(总...