免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3726 | 回复: 3
打印 上一主题 下一主题

redhat linux AS3.0 使用IPVSADM 和arptables做负载均衡 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-01-12 11:21 |只看该作者 |倒序浏览
最近公司要用LVS做负载均衡,系统使用的Redhat AS3.0, 网上合适的文档不多,要么是hidden arp配置的选项没有,要么需要打补丁,改内核,非常的麻烦。经过几天的努力和测试,查询大量的文档和LVS资料,终于找到了一个比较方便的,不需要修改内核的方法,发出来给大家共享。
一、LVS--DR  configuration
1、ENV
OS:RedHat AS3
Packeage:ipvsadm-1.21-9.ipvs108.i386.rpm
2、system architecture
director server:10.64.20.112
real server1:10.64.20.110
real server2:10.64.20.111
VIP:10.64.20.113
real server1 and 2 Ip address are configured on eth0
we first assume all servers are finished installed.

3. director server configuration:
#install ipvsadm
rom -ivh ipvsadm-1.21-9.ipvs108.i386.rpm

#confiigure ip forward and redirects
echo "0" >/proc/sys/net/ipv4/ip_forward
echo "1" >/proc/sys/net/ipv4/conf/default/send_redirects
echo "1" >/proc/sys/net/ipv4/conf/lo/send_redirects

#configure VIP address
/sbin/ifconfig eth0:0 10.64.20.113 broadcast 10.64.20.113 netmask 255.255.255.255 up
/sbin/route add -host 10.64.20.113 dev eth0:0

#configre ipvsadm
ipvsadm -C
ipvsadm -A -t 10.64.20.113:http -s rr
ipvsadm -a -t 10.64.20.113:http -r 10.64.20.111 -g -w 1
ipvsadm -a -t 10.64.20.113:http -r 10.64.20.110 -g -w 1

4. real server1 config

#configure ip forward
echo "0" >/proc/sys/net/ipv4/ip_forward

#configure VIP on realserver and route
/sbin/ifconfig lo:0 10.64.20.113 broadcast 10.64.20.113 netmask 255.255.255.255 up
/sbin/route add -host 10.64.20.113 dev lo:0

#hidden arp request
arptables -A IN -d 10.64.20.113 -j DROP
arptables -A OUT -o lo -d  10.64.20.113 -j mangle --mangle-ip-s  10.64.20.113
arptables -A OUT -o eth0 -d  10.64.20.113 -j mangle --mangle-ip-s  10.64.20.110
arptables -A OUT -o eth1 -d  10.64.20.113 -j mangle --mangle-ip-s  <real_ip_on_eth1>  (if you have eth1 connect to network)
5. real server2 config

#configure ip forward
echo "0" >/proc/sys/net/ipv4/ip_forward

#configure VIP on realserver and route
/sbin/ifconfig lo:0 10.64.20.113 broadcast 10.64.20.113 netmask 255.255.255.255 up
/sbin/route add -host 10.64.20.113 dev lo:0
#hidden arp request
arptables -A IN -d 10.64.20.113 -j DROP
arptables -A OUT -o lo -d  10.64.20.113 -j mangle --mangle-ip-s  10.64.20.113
arptables -A OUT -o eth0 -d  10.64.20.113 -j mangle --mangle-ip-s  10.64.20.111
arptables -A OUT -o eth1 -d  10.64.20.113 -j mangle --mangle-ip-s  <real_ip_on_eth1>  (if you have eth1 connect to network)

6. check with IE.
on Director server check ipvsadm list:
#ipvsadm -L


二、LVS--TUN  configuration
1、ENV
OS:RedHat AS3
Packeage:ipvsadm-1.21-9.ipvs108.i386.rpm
2、system architecture
director server:10.64.20.112
real server1:10.64.20.110
real server2:10.64.20.111
VIP:10.64.20.113
real server1 and 2 Ip address are configured on eth0
we first assume all servers are finished installed.

3. Director Server
#!/bin/bash
#set ip_forward on for vs-tun director(1 on, 0 off)
echo "0" >/proc/sys/net/ipv4/ip_forward
#add ethernet device and routing for VIP
/sbin/ifconfig eth0:0 10.64.20.113 broadcast 10.64.20.113 netmask 255.255.255.255 up
/sbin/route add -host 10.64.20.113 dev eth0:0
ipvsadm -C
ipvsadm -A -t 10.64.20.113:http -s rr
ipvsadm -a -t 10.64.20.113:http -r 10.64.20.110 -i -w 1
ipvsadm -a -t 10.64.20.113:http -r 10.64.20.111 -i -w 1

4.real server 1
       

#!/bin/bash
#set_realserver_ip_forwarding to OFF(1 on, 0 off)
echo "0" >/proc/sys/net/ipv4/ip_forward

#install_readserver_vip
insmod ipip
ifconfig tunl0 10.64.20.113 broadcast 10.64.20.113 netmask 255.255.255.255 up
route add -host 10.64.20.113 dev tunl0

#hiding interface tunl0, will not arp
arptables -A IN -d 10.64.20.113 -j DROP
arptables -A OUT -o tunl0 -d  10.64.20.113 -j mangle --mangle-ip-s  10.64.20.113
arptables -A OUT -o eth0 -d  10.64.20.113 -j mangle --mangle-ip-s  10.64.20.110
arptables -A OUT -o eth1 -d  10.64.20.113 -j mangle --mangle-ip-s  <real_ip_on_eth1>  (if you have eth1 connect to network)

5.real server 2
       

#!/bin/bash
#set_realserver_ip_forwarding to OFF(1 on, 0 off)
echo "0" >/proc/sys/net/ipv4/ip_forward

#install_readserver_vip
insmod ipip
ifconfig tunl0 10.64.20.113 broadcast 10.64.20.113 netmask 255.255.255.255 up
route add -host 10.64.20.113 dev tunl0

#hiding interface tunl0, will not arp
arptables -A IN -d 10.64.20.113 -j DROP
arptables -A OUT -o tunl0 -d  10.64.20.113 -j mangle --mangle-ip-s  10.64.20.113
arptables -A OUT -o eth0 -d  10.64.20.113 -j mangle --mangle-ip-s  10.64.20.111
arptables -A OUT -o eth1 -d  10.64.20.113 -j mangle --mangle-ip-s  <real_ip_on_eth1>  (if you have eth1 connect to network)

6. check with IE.
on Director server check ipvsadm list:
#ipvsadm -L

论坛徽章:
0
2 [报告]
发表于 2007-01-13 19:34 |只看该作者
这样有检测real server么?

论坛徽章:
0
3 [报告]
发表于 2007-01-15 13:34 |只看该作者

用AS4最简单了,装cluster光盘的ipvsadm、piranha

可实现LVS服务器冗余、real server检测。可通过图形界面很方便的配置

论坛徽章:
0
4 [报告]
发表于 2007-02-03 10:43 |只看该作者
楼主呢  后续问题有介绍么
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP