CentOS 5 lvs+piranha实现隧道模式负载均衡
原文:http://www.hiadmin.com/?p=862
一。需要的软件包
1. ipvsadm-1.24-8.1.i386.rpm
2. modcluster-0.8-27.el5.i386.rpm
3. piranha-0.8.4-7.el5.i386.rpm
4. system-config-cluster-1.0.39-1.0.noarch.rpm
5. php-5.1.6-5.el5.i386.rpm
6. php-cli-5.1.6-5.el5.i386.rpm
7. php-common-5.1.6-5.el5.i386.rpm
8. http*
或者选择系统自带的 Cluster 套件可以直接安装。
二。系统架构。
Virtual IP :192.168.1.20(VIP 对外提供服务器的ip地址,也就是域名解析到的地址。)
Load Balance : 192.168.1.16(LB12)
Real Server:192.168.1.14(r14)、192.168.1.15(r15)
二.LVS Server的安装设置(LB12):
1。安装
# rpm -ivh *
安装完包以后,会生成最主要的几个文件分别是:/etc/sysconfig/ha/lvs.cf,/etc/init.d/piranha-gui,/etc/init.d/pulse
2。设置piranha管理密码
# piranha-passwd
按照提示输入管理密码
3。启动 web 服务和piranha
# service httpd start
# service piranha-gui start
4。配置lvs
配置lvs主要通过piranha提供的http方式完成。
4.1。访问http://192.168.1.16:3636/
4.2。点击“Login”,再弹出的登陆框输入用户名:piranha,密码是前面通过piranha-passwd设置的密码,“确定”。
具体的配置可以参考http://www.dvdshop.com.cn/manual/redhat_AS_3.0_CS/index.html 第12章。
注意:控制面板-〉VIRTUAL SERVERS ->Virtual IP Address: 设置VIP地址。
4.3。启用数据转发
# vi /etc/sysctl.conf
将
net.ipv4.ip_forward = 0
改为
net.ipv4.ip_forward = 1
注意:重新启动系统一个此设置才会生效。
传统文档的lvs节点配置现在都由piranha图形工具来完成,因此不需要使用命令行来配置。
5。ipvsadm启动
# service ipvsadm start
如果在重新启动的时候,提示说/etc/sysconfig/ipvsadm不存在。那么
# touch /etc/sysconfig/ipvsadm
三.Real Server的设置(r14、r15):
1。创建IP Tunnel
# ifconfig tunl0 192.168.1.20 netmask 255.255.255.255 broadcast 192.168.1.20 up
2。将tunl0加入路由表(routing table)
# route add -host 192.168.1.20 dev tunl0
这四句目的是为了关闭ARP广播响应
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 1 > /proc/sys/net/ipv4/conf/tunl0/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/tunl0/arp_announce
注意:上面的语句只是临时关闭。服务器重新启动以后设置就自动消失了。
如果需要让设置长时间有效那么,进行如下操作:
# vi /etc/sysctl.conf
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.tunl0.arp_ignore = 1
net.ipv4.conf.tunl0.arp_announce = 2
下面的语句恢复原始设置。
echo 0 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 0 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 0 > /proc/sys/net/ipv4/conf/tunl0/arp_ignore
echo 0 > /proc/sys/net/ipv4/conf/tunl0/arp_announce
注意:上面的语句只是临时恢复。服务器重新启动以后设置就自动消失了。
如果需要让设置长时间有效那么,进行如下操作:
# vi /etc/sysctl.conf
net.ipv4.conf.all.arp_ignore = 0
net.ipv4.conf.all.arp_announce = 0
net.ipv4.conf.tunl0.arp_ignore = 0
net.ipv4.conf.tunl0.arp_announce = 0
五月 9th, 2011 at 21:17
Recent Favourite Sites…
[...]below you’ll see my links page http://www.yeastinfectiontreatmentcure.net/links/ with some excellent sites that I think you should definitely visit[...]…
七月 10th, 2011 at 22:36
Recommeneded websites…
[...]Here are some of the sites we recommend for our visitors[...]……
九月 12th, 2011 at 02:50
Great website…
[...]we like to honor many other internet sites on the web, even if they aren’t linked to us, by linking to them. Under are some webpages worth checking out[...]……
十月 14th, 2011 at 15:10
Fashion Stud Earrings…
[...]高进波博客 – 零起点一步配置你的linux服务器,linux博客,linux教程,web架构 » Blog Archive » CentOS 5 lvs+piranha实现隧道模式负载均衡[...]…
十月 23rd, 2011 at 22:54
Prestashop Themes…
[...]高进波博客 – 零起点一步配置你的linux服务器,linux博客,linux教程,web架构 » Blog Archive » CentOS 5 lvs+piranha实现隧道模式负载均衡[...]…
十月 31st, 2011 at 08:01
How do i use frame or iframe to put facebook or else to blogspot?…
I need to see facebook live from my blogspot page…..