分类: LINUX
2012-07-05 16:23:24
O:\RHCA\群集_Cluster\Linux下群集服务之LB群集-lvs-DR模型.docx
Linux下群集服务之lvs-DR模型在企业网络中的应用案例
案例应用拓扑图:
案例应用实现详细步骤如下:
一.Client-pc客户端配
二. Director服务器配置
2.1 Director服务器ip地址配置
[root@junjie ~]# setup
[root@junjie ~]# service network restart
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
[root@junjie ~]# hostname director.junjie.com #注销重新登录
2.2 为director添加路由
10.106.6.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 0 0 0 eth0
0.0.0.0 10.106.6.254 0.0.0.0 UG 0 0 0 eth0
[root@director ~]# route add -host 10.106.6.254 dev eth0:0
10.106.6.254 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
10.106.6.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 0 0 0 eth0
0.0.0.0 10.106.6.254 0.0.0.0 UG 0 0 0 eth0 2.3 配置本地yum服务器:
[root@director ~]# vim /etc/yum.repos.d/server.repo
name=Red Hat Enterprise Linux server
name=Red Hat Enterprise Linux cluster
[root@director ~]# mount /dev/cdrom /mnt/cdrom/
mount: block device /dev/cdrom is write-protected, mounting read-only
2.4 安装配置dircetor服务器:
[root@director ~]# yum install -y ipvsadm
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
[root@director ~]# ipvsadm -A -t 10.106.6.254:80 -s rr
[root@director ~]# ipvsadm -a -t 10.106.6.254:80 -r 10.106.6.251 -g
[root@director ~]# ipvsadm -a -t 10.106.6.254:80 -r 10.106.6.252 -g
[root@director ~]# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
-> 10.106.6.252:80 Route 1 0 0
-> 10.106.6.251:80 Route 1 0 0
[root@director ~]# service ipvsadm save
Clearing the current IPVS table: [ OK ]
三.配置real-server-1的web服务器:
3.1 解决arp问题:
[root@junjie ~]# hostname r1.junjie.com
[root@r1 ~]# echo "net.ipv4.conf.all.arp_announce = 2" >> /etc/sysctl.conf
[root@r1 ~]# echo "net.ipv4.conf.lo.arp_announce = 2" >> /etc/sysctl.conf
[root@r1 ~]# echo "net.ipv4.conf.all.arp_ignore = 1" >> /etc/sysctl.conf
[root@r1 ~]# echo "net.ipv4.conf.lo.arp_ignore = 1" >> /etc/sysctl.conf
3.2 配置ip地址和路由
[root@r1 ~]# service network restart
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
10.106.6.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 0 0 0 eth0
0.0.0.0 10.106.6.254 0.0.0.0 UG 0 0 0 lo
[root@r1 ~]# route add -host 10.106.6.254 dev lo:0
10.106.6.254 0.0.0.0 255.255.255.255 UH 0 0 0 lo
10.106.6.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 0 0 0 eth0
0.0.0.0 10.106.6.254 0.0.0.0 UG 0 0 0 lo
3.3 配置Real-server-1的Web服务器:
[root@r1 ~]#mkdir /mnt/cdrom
[root@r1 ~]# mount /dev/cdrom /mnt/cdrom/
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@r1 ~]# rpm -ivh /mnt/cdrom/Server/httpd-2.2.3-31.el5.i386.rpm
warning: /mnt/cdrom/Server/httpd-2.2.3-31.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... #################################### [100%]
1:httpd ########################################### [100%]
[root@r1 ~]# echo "web1 -- real-server-1" > /var/www/html/index.html
Starting httpd: httpd: apr_sockaddr_info_get() failed for r1.junjie.com
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
3.4 客户端访问real-server-1的web服务:(桥接)
四.配置real-server2的web服务器:
4.1 解决arp问题:
[root@r2 ~]# echo "net.ipv4.conf.all.arp_announce = 2" >> /etc/sysctl.conf
[root@r2 ~]# echo "net.ipv4.conf.lo.arp_announce = 2" >> /etc/sysctl.conf
[root@r2 ~]# echo "net.ipv4.conf.all.arp_ignore = 1" >> /etc/sysctl.conf
[root@r2 ~]# echo "net.ipv4.conf.lo.arp_ignore = 1" >> /etc/sysctl.conf
4.2 配置ip地址和路由
[root@r2~]# service network restart
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
10.106.6.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 0 0 0 eth0
0.0.0.0 10.106.6.254 0.0.0.0 UG 0 0 0 lo
[root@r2 ~]# route add -host 10.106.6.254 dev lo:0
10.106.6.254 0.0.0.0 255.255.255.255 UH 0 0 0 lo
10.106.6.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 0 0 0 eth0
0.0.0.0 10.106.6.254 0.0.0.0 UG 0 0 0 lo
4.3 配置Real-server-2的Web服务器:
[root@r2 ~]#mkdir /mnt/cdrom
[root@r2 ~]# mount /dev/cdrom /mnt/cdrom/
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@r2 ~]# rpm -ivh /mnt/cdrom/Server/httpd-2.2.3-31.el5.i386.rpm
warning: /mnt/cdrom/Server/httpd-2.2.3-31.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... #################################### [100%]
1:httpd ########################################### [100%]
[root@r2 ~]#echo "web2 -- real-server-2" > /var/www/html/index.html l
[root@r2 ~]# service httpd start
Starting httpd: httpd: apr_sockaddr_info_get() failed for r2.junjie.vom
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
4.4 客户端访问real-server-2的web服务:(桥接)
5.1 客户端访问director的群集服务服务:(网卡使用桥接模式)http://10.106.6.254
5.2 客户端不断刷新,发现web2和web1交替出现,比率为1:1,说明依次轮询模式为RR
5.3在director上查看信息如下:轮询调度比几乎为1:1;
说明lvs调度方法是用的是RR模式
[root@director ~]# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.106.6.254:80 rr
-> 10.106.6.251:80 Route 1 0 14
-> 10.106.6.252:80 Route 1 0 14
关于Linux下集群服务简介和lvs的详解请参看我的博客:
http://xjzhujunjie.blog.51cto.com/3582724/850650
关于Linux下群集服务之LB集群-lvs-nat模式请参看我的博客:
http://xjzhujunjie.blog.51cto.com/3582724/850866
--xjzhujunjie
--2012/05/03