设为首页 收藏本站
查看: 1425|回复: 0

[经验分享] lvs-DR模型

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-11-8 08:26:41 | 显示全部楼层 |阅读模式
                      
  • 部署规划

QQ截图20161108082619.png

2.设备ip规划:
  因为只是本机摸拟,设备全部用虚拟机,包括机器、路由器、交换机都可用vmware搞定。

除R1、C、S1是真实设备,其它都为虚拟设备,简单介绍下每个设备的情况。
R1:所在公司网络路由器。
C:自已的电脑。
S1:采用桥接模式就相当于连入了这个交换机,从而成为这网络的一部分,而这个网络一般就叫VMnet0。(不一定准切,但是这个道理)
S2:采用仅主机模式就接入了这个交换机,这个网络一般就叫VMnet1。
DR:两个网卡,一个桥接模式,一个仅主机模式。
N[1-n]:Nginx服务器,采用一个网卡,采用仅主机模式。
T[1-n]:Tomcat服务器,采用一个网卡,采用仅主机模式。
R2:软路由,采用两个网卡,一个桥接模式,一个仅主机模式。
设备名
接口名
ip
默认网关
子网掩码
接入模式
C
本机网卡
192.168.13.121
192.168.13.1
255.255.255.0
-
R1
lan口
192.168.13.1
-
255.255.255.0
-
R2
wan口
192.168.13.125
192.168.13.1
255.255.255.0
桥接
R2
lan口
192.168.19.6
-
255.255.255.0
仅主机
DR
eth0
192.168.13.210(vip)
192.168.13.1
255.255.255.0
桥接
DR
eth1
192.168.19.3
192.168.19.6
255.255.255.0
仅主机
N1
eth0
192.168.19.4
192.168.19.6
255.255.255.0
仅主机
N1
lo:0
192.168.13.210(vip)
-
255.255.255.255
-
N2
eth0
192.168.19.5
192.168.19.6
255.255.255.0
仅主机
N2
lo:0
192.168.13.210(vip)
-
255.255.255.255
-
T1
eth0
192.168.19.7
192.168.19.6
255.255.255.0
仅主机
T2
eth0
192.168.19.8
192.168.19.6
255.255.255.0
仅主机
T3
eth0
192.168.19.9
192.168.19.6
255.255.255.0
仅主机
T4
eth0
192.168.19.10
192.168.19.6
255.255.255.0
仅主机

3.虚拟机网络配置
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
N[1-n]主机lo:0接口上的vip在后面步骤设置。
/**DR eth0**/
[iyunv@server ~]#ifconfig eth0 192.168.13.210 netmask 255.255.255.0 up
[iyunv@server ~]#route add default gw 192.168.13.1 dev eth0
/**vip所在网卡都加一条特殊路由,意思是以目标地址进来的请求数据包,
那么响应数据包的源地址都应为该设备上的ip地址**/
[iyunv@server ~]#route add -host 192.168.13.210  dev eth0
/**DR eth1**/
[iyunv@server ~]#ifconfig eth1 192.168.19.3 netmask 255.255.255.0 up
[iyunv@server ~]#route add default gw 192.168.19.6 dev eth1
[iyunv@server ~]#vi /etc/rc.local
ifconfig eth0 192.168.13.210 netmask 255.255.255.0 up
route add default gw 192.168.13.1 dev eth0
ifconfig eth1 192.168.19.3 netmask 255.255.255.0 up
route add default gw 192.168.19.6 dev eth1
:wq
/**N1 eth0**/
[iyunv@server ~]#ifconfig eth0 192.168.19.4 netmask 255.255.255.0 up
[iyunv@server ~]#route add default gw 192.168.19.6 dev eth0
[iyunv@server ~]#vi /etc/rc.local
ifconfig eth0 192.168.19.4 netmask 255.255.255.0 up
route add default gw 192.168.19.6 dev eth0
:wq
/**N2 eth0**/
[iyunv@server ~]#ifconfig eth0 192.168.19.5 netmask 255.255.255.0 up
[iyunv@server ~]#route add default gw 192.168.19.6 dev eth0
[iyunv@server ~]#vi /etc/rc.local
ifconfig eth0 192.168.19.5 netmask 255.255.255.0 up
route add default gw 192.168.19.6 dev eth0
:wq
/**T1 eth0**/
[iyunv@server ~]#ifconfig eth0 192.168.19.7 netmask 255.255.255.0 up
[iyunv@server ~]#route add default gw 192.168.19.6 dev eth0
[iyunv@server ~]#vi /etc/rc.local
ifconfig eth0 192.168.19.7 netmask 255.255.255.0 up
route add default gw 192.168.19.6 dev eth0
:wq
/**T2 eth0**/
[iyunv@server ~]#ifconfig eth0 192.168.19.8 netmask 255.255.255.0 up
[iyunv@server ~]#route add default gw 192.168.19.6 dev eth0
[iyunv@server ~]#vi /etc/rc.local
ifconfig eth0 192.168.19.8 netmask 255.255.255.0 up
route add default gw 192.168.19.6 dev eth0
:wq
/**T3 eth0**/
[iyunv@server ~]#ifconfig eth0 192.168.19.9 netmask 255.255.255.0 up
[iyunv@server ~]#route add default gw 192.168.19.6 dev eth0
[iyunv@server ~]#vi /etc/rc.local
ifconfig eth0 192.168.19.9 netmask 255.255.255.0 up
route add default gw 192.168.19.6 dev eth0
:wq
/**T4 eth0**/
[iyunv@server ~]#ifconfig eth0 192.168.19.10 netmask 255.255.255.0 up
[iyunv@server ~]#route add default gw 192.168.19.6 dev eth0
[iyunv@server ~]#vi /etc/rc.local
ifconfig eth0 192.168.19.10 netmask 255.255.255.0 up
route add default gw 192.168.19.6 dev eth0
:wq






4.安装软件
在每台机上把防火墙都先关闭,避免干扰。dr上一定要关闭,因为ipvs和iptables不能同时开。

1
2
3
[iyunv@server ~]#chkconfig iptables off
[iyunv@server ~]#service iptables stop
[iyunv@server ~]#setenforce



(1)在N1和N2上安装nginx
  nginx-1.6.2.tar.gz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[iyunv@server ~]#yum install gcc gcc-c++ make automake autoconf libtool pcre* zlib openssl openssl-devel
[iyunv@server ~]#mv nginx-1.6.2.tar.gz /usr/local/src
[iyunv@server ~]#cd /usr/local/src
[iyunv@server src]#tar -zxvf nginx-1.6.2.tar.gz
[iyunv@server src]#cd nginx-1.6.2
[iyunv@server src]#./configure
[iyunv@server src]#make
[iyunv@server src]#make install
[iyunv@server src]#cd /usr/local/nginx
[iyunv@server nginx]#echo "test nginx 192.168.19.4" > html/index.html /**在N1上执行**/
[iyunv@server nginx]#echo "test nginx 192.168.19.5" > html/index.html /**在N2上执行**/
[iyunv@server nginx]#sbin/nginx /**启动nginx**/
[iyunv@server nginx]#vi /etc/rc.local
  /usr/local/nginx/sbin/nginx
  :wq



(2)安装tomcat(略)
(3)在DR上安装ipadm和ipvs(ipvs模块编绎在linux内核不用安装)
1
2
  [iyunv@server nginx]#grep -i 'vs' /boot/config-2.6.32-642.el6.x86_64 /**查看ipvs模块是否存在**/
  [iyunv@server nginx]#yum install ipvsadm



5.配置N[1-n]的lo:0接口的vip

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/**N1和N2 设置禁用arp的内核参数,为了让别的主机发现不要它,不与外界通迅**/
[iyunv@server ~]#sysctl -w net.ipv4.conf.lo.arp_announce=2
[iyunv@server ~]#sysctl -w net.ipv4.conf.all.arp_announce=2
[iyunv@server ~]#sysctl -w net.ipv4.conf.lo.arp_ignore=1
[iyunv@server ~]#sysctl -w net.ipv4.conf.all.arp_ignore=1
/**N1和N2 lo:0**/
/**禁止这个网卡与外界通迅,设置广播为自已,掩码4个255,表示网络中只有自已本身一个主机**/
[iyunv@server ~]#ifconfig lo:0 192.168.13.210 broadcast 192.168.13.210 netmask 255.255.255.255 up
/**vip所在网卡都加一条特殊路由,意思是以目标地址进来的请求数据包,
那么响应数据包的源地址都应为该设备上的ip地址**/
[iyunv@server ~]#route add -host 192.168.13.210 dev lo:0
[iyunv@server ~]#vi /etc/rc.local
sysctl -w net.ipv4.conf.lo.arp_announce=2
sysctl -w net.ipv4.conf.all.arp_announce=2
sysctl -w net.ipv4.conf.lo.arp_ignore=1
sysctl -w net.ipv4.conf.all.arp_ignore=1
ifconfig lo:0 192.168.13.210   broadcast 192.168.13.210  netmask 255.255.255.255 up
route add -host 192.168.13.210  dev lo:0
:wq




6.开启DR并添加nginx服务
1
2
3
4
5
6
7
8
9
10
[iyunv@server ~]#ipvsadm -C
[iyunv@server ~]#ipvsadm -A -t 192.168.13.210:80 -s wlc
[iyunv@server ~]#ipvsadm -a -t 192.168.13.210:80 -r 192.168.19.4 -g -w 1
[iyunv@server ~]#ipvsadm -a -t 192.168.13.210:80 -r 192.168.19.5 -g -w 2
[iyunv@server ~]#ipvsadm -L -n
[iyunv@server ~]#vi /etc/rc.local
ipvsadm -A -t 192.168.13.210:80 -s wlc
ipvsadm -a -t 192.168.13.210:80 -r 192.168.19.4 -g -w 1
ipvsadm -a -t 192.168.13.210:80 -r 192.168.19.5 -g -w 2
:wq



6.测试
QQ截图20161108082625.png


                   


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-297140-1-1.html 上篇帖子: LVS:三种负载均衡方式比较 下篇帖子: LVS-net实验 模型
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表