LVS 的NAT模式配置
NAT模式实验环境:
1.实验模拟通过192.168.0.144 向外提供服务
2.通过director接受和响应用户的请求,通过director的LVS功能,把用户的
请求通过realserver来真正的处理
3.realserver 提供web处理功能
4.拓扑图如下
http://img1.运维网.com/attachment/201109/8/3237944_1315465842uYob.png
一、配置realserver (两台realserver配置相同,以realserver1为例)
[*]配置ip和对应的网关
1) ip配置
http://img1.运维网.com/attachment/201109/8/3237944_131546584535tr.png
2)网关配置
http://img1.运维网.com/attachment/201109/8/3237944_1315465846OBea.png
3) 测试连通性
http://img1.运维网.com/attachment/201109/8/3237944_1315465847vte0.png
http://img1.运维网.com/attachment/201109/8/3237944_1315465848MEAZ.png
2. 安装配置apache
1)安装
http://img1.运维网.com/attachment/201109/8/3237944_1315465850WDo5.png
2)添加网页 (为了测试两个realserver上的web提供不同的网页内容)
#vim /var/www/html/index.html 添加如下内容
http://img1.运维网.com/attachment/201109/8/3237944_1315465851JvPf.png
realserver2 为“test for realserver2”
3) 启动apache
http://img1.运维网.com/attachment/201109/8/3237944_1315465851SMfs.png
4)内部测试
#elinks 10.0.0.10
http://img1.运维网.com/attachment/201109/8/3237944_1315465852JmT4.png
#elinks 10.0.0.11
http://img1.运维网.com/attachment/201109/8/3237944_1315465853LRUH.png
二、配置 director
1)配置ip
#ifconfig eth0 10.0.0.1 (不在测试,上边测试过了)
#ifconfig eth1 192.168.0.144
2)打开本机的路由转发功能
临时修改:
http://img1.运维网.com/attachment/201109/8/3237944_1315465854mNxB.png
永久修改: #vim /etc/sysctl.conf , 把net.ipv4.ip_forward = 0 中的 0 改为 1
http://img1.运维网.com/attachment/201109/8/3237944_1315465856ajWl.png
3) 安装和配置ipvsadm
安装:
http://img1.运维网.com/attachment/201109/8/3237944_1315465858jUVf.png
配置:
1)添加规则 (这里使用rr算法,下面测试时会测试i其他算法,管理算法的介绍,上篇博客有)
http://img1.运维网.com/attachment/201109/8/3237944_1315465859VVEw.png
2)添加realserver
http://img1.运维网.com/attachment/201109/8/3237944_1315465860BG0y.png
三、测试
1、rr算法测试 (请求的页面会轮巡的改变)
http://img1.运维网.com/attachment/201109/8/3237944_1315465864VNU8.png
http://img1.运维网.com/attachment/201109/8/3237944_1315465867eH7A.png
压力测试:
使用命令: #ab –c 10 –n 5000 http://192.168.0.144/index.html
响应速度: Requests per second: 1713.12 [#/sec] (mean) ##每秒1713 次
http://img1.运维网.com/attachment/201109/8/3237944_1315465872yMEZ.png
测试统计
使用命令: #watch –n 1 'ipvsadm –L –n' #两台realserver的响应数基本上是1:1
http://img1.运维网.com/attachment/201109/8/3237944_1315465873pSqL.png
2、wlc 算法测试
1)修改ipvsadm 的使用算法和权重值
http://img1.运维网.com/attachment/201109/8/3237944_1315465874xc2a.png
2)压力测试
响应速度:每秒2000次左右
http://img1.运维网.com/attachment/201109/8/3237944_1315465878jiZK.png
3)测试统计: 比例接近权重值之比3:1
http://img1.运维网.com/attachment/201109/8/3237944_1315465880PhKF.png
3 nq 算法测试
1)修改算法
2)压力测试 响应速度:1400次左右
http://img1.运维网.com/attachment/201109/8/3237944_1315465887JmHo.png
3)测试统计
http://img1.运维网.com/attachment/201109/8/3237944_1315465889hUhi.png
页:
[1]