




已阅读5页,还剩8页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
LVS集群技术由 wensong 在 周四, 2006-04-06 23:13 提交 LVS集群技术作者:FunBSD最后更新:2005年5月18日目录 Preface IPVS HeatBeat Ldirectord Patch Scripts Reference Preface集群技术主要分为三大类: 高可用性(High Available Cluster),例:Linux-HA 负载均衡(Load balancing Cluster),例:LVS、MOSIX 高性能计算(High Performance Computing),例:Beowulf 我们这里使用RedHat AS 3.x,LVS,Linux-HA,Ldirectord,构造一个高可用的负载均衡集群系统。如图:各层的作用: Load Balancer(负载均衡器):Load Balancer是整个集群系统的前端,负责把客户请求转发到Real Server上。Backup是备份Load Balancer,当Load Balancer不可用时接替它,成为实际的Load Balancer。Load Balancer通过Ldirectord监测各Real Server的健康状况。在Real Server不可用时把它从群中剔除,恢复时重新加入。 Server Array(服务器群):Server Array是一组运行实际应用服务的机器,比如WEB, Mail, FTP, DNS, Media等等。在实际应用中,Load Balancer和Backup也可以兼任Real Server的角色。 Shared Storage(共享存储):Shared Storage为所有Real Server提供共享存储空间和一致的数据内容。 各服务器IP分配:Virtual IP:0Load Balancer:1Backup:2Real Server 1:01Real Server 2:02Real Server 3:03IPVSIPVS是LVS集群系统的核心软件,它的主要作用是: 安装在Load Balancer上,把发往Virtual IP的请求转发到Real Server上。 IPVS的负载均衡机制有三种,这里使用IP Tunneling机制: Virtual Server via NAT Virtual Server via IP Tunneling Virtual Server via Direct Routing IPVS的负载调度算法有十种: 轮叫(Round Robin) 加权轮叫(Weighted Round Robin) 最少链接(Least Connections) 加权最少链接(Weighted Least Connections) 基于局部性的最少链接(Locality-Based Least Connections) 带复制的基于局部性最少链接(Locality-Based Least Connections with Replication) 目标地址散列(Destination Hashing ) 源地址散列(Source Hashing) 最短期望延迟(Shortest Expected Delay) 无须队列等待(Never Queue) IPVS安装主要包括三方面: 在Load Banlancer上安装IPVS内核补丁 在Load Banlancer上安装IPVS管理软件 在Real Server上安装ARP hidden内核补丁 关于如何编译内核请参考其他文档,这里使用从UltraMonkey下载的已编译好的内核。在Load Banlancer、Backup和Real Server上使用同一内核,IPVS和ARP hidden都已编译在这个内核里:wget /download/2.0.1/rh.el.3.0/RPMS/mkinitrd-3.5.13-1.um.1.i386.rpmwget /download/2.0.1/rh.el.3.0/RPMS/kernel-2.4.21-27.0.2.EL.um.1.i686.rpmwget /download/2.0.1/rh.el.3.0/RPMS/kernel-smp-2.4.21-27.0.2.EL.um.1.i686.rpmrpm -Fhv mkinitrd-3.5.13-1.um.1.i386.rpmrpm -Fhv kernel-2.4.21-27.0.2.EL.um.1.i686.rpm在Load Banlancer和Backup上安装IPVS管理软件:wget /software/kernel-2.4/ipvs-1.0.10.tar.gztar zxf ipvs-1.0.10.tar.gzcd ipvs-1.0.10/ipvs/ipvsadmmake installchkconfig -del ipvsadm配置IPVS(/etc/sysconfig/ipvsadm),添加Real Server:-A -t 0:80 -s rr-a -t 0:80 -r 1:80 -i-a -t 0:80 -r 2:80 -i-a -t 0:80 -r 01:80 -i-a -t 0:80 -r 02:80 -i-a -t 0:80 -r 03:80 -i相关链接:Kernel:/IPVS和IPVSadm:/software/ipvs.htmlARP hidden:http:/www.ssi.bg/ja/#hidden注意事项:1. Kernel,IPVS,IPVSadm,ARP hidden之间的版本必须对应。2. 自己编译内核时,从/下载标准内核源文件,不要使用发行版的内核源文件。3. Kernel 2.4.28和2.6.10及以上版本已内置IPVS,有些Linux发行版也在其内核里编译了IPVS。4. ARP hidden可以用arp_ignore/arp_announce或者arptables代替 HeartBeatHeartBeat是Linux-HA的高可用性集群软件,它的主要作用是: 安装在Load Balancer和Backup上,运行于active/standby模式。当Load Balancer失效时,Backup自动激活,成为实际的Load Balancer。 切换到active模式时,按顺序启动Virtual IP、IPVS和Ldirectord。切换到standby模式时,按顺序关闭Ldirectord、IPVS和Virtual IP。 HeartBeat串口线连接测试方法:在Load Balancer上:cat /dev/ttyS0修改主机名(/etc/hosts): localhost.localdomain localhost1 loadbalancer2 backup安装:groupadd -g 694 haclientuseradd -u 694 -g haclient haclusterrpm -ivh /mnt/cdrom/RedHat/RPMS/glib2-devel-*wget /libnet/dist/libnet.tar.gztar zxf libnet.tar.gzcd libnet./configure makemake installwget /download/heartbeat-1.99.4-tar.gztar zxf heartbeat-1.99.4.tar.gzcd heartbeat-1.99.4./ConfigureMe configure -disable-swig -disable-snmp-subagentmakemake installcp doc/ha.cf doc/haresources doc/authkeys /etc/ha.d/cp ldirectord/ldirectord.cf /etc/ha.d/chkconfig -add heartbeatchkconfig -del ldirectord 主配置文件(/etc/ha.d/ha.cf):#debugfile /var/log/ha-debuglogfile /var/log/ha-loglogfacility local0keepalive 2deadtime 30warntime 10initdead 120udpport 694baud 19200serial /dev/ttyS0mcast eth0 694 1 0# 当主节点恢复后,是否自动切回auto_failback on# stonith用来保证共享存储环境中的数据完整性#stonith baytech /etc/ha.d/conf/stonith.baytech# watchdog能让系统在出现故障1分钟后重启该机器。这个功能可以帮助服务器在确实停止心跳后能够重新恢复心跳。# 如果使用该特性,则在内核中装入softdog内核模块,用来生成实际的设备文件,输入insmod softdog加载模块。# 输入grep misc /proc/devices(应为10),输入cat /proc/misc | grep watchdog(应为130)。# 生成设备文件:mknod /dev/watchdog c 10 130 。#watchdog /dev/watchdognode loadbalancernode backup# 默认heartbeat并不检测除本身之外的其他任何服务,也不检测网络状况。# 所以当网络中断时,并不会进行Load Balancer和Backup之间的切换。# 可以通过ipfail插件,设置ping nodes来解决这一问题。详细说明参考hearbeat文档。#ping ping_group group1 respawn root /usr/lib/heartbeat/ipfailapiauth ipfail gid=root uid=root# 其他一些插件可以在/usr/lib/heartbeat下找到#apiauth ipfail uid=hacluster#apiauth ccm uid=hacluster#apiauth cms uid=hacluster#apiauth ping gid=haclient uid=alanr,root#apiauth default gid=haclient资源文件(/etc/ha.d/haresources):loadbalancer lvs IPaddr:0/24/eth0 ipvsadm ldirectord认证文件(/etc/ha.d/authkeys),选取一种认证方式,这个文件的权限必须是600:auth 11 crc#2 sha1 sha1_any_password#3 md5 md5_any_password相关链接:Linux-HA: ldirectord安装HeartBeat过程中,已经自动安装了Ldirectord,它的作用是: 监测Real Server,当Real Server失效时,把它从Load Balancer列表中删除,恢复时重新添加。 配置(/etc/ha.d/ldirectord.cf):# Global Directiveschecktimeout=3checkinterval=1fallback=:80autoreload=yeslogfile=/var/log/ldirectord.logquiescent=yes# A sample virual with a fallback that will override the gobal settingvirtual=0:80real=1:80 ipipreal=2:80 ipipreal=01:80 ipipreal=02:80 ipipreal=03:80 ipipfallback=:80 gateservice=httprequest=test.htmlreceive=Test Pagevirtualhost=scheduler=rr#persistent=600#netmask=55protocol=tcp在每个Real Server的中添加监控页:echo Test Page /var/www/html/test.html Patch在启动集群系统之前,我们认为包括Load Balancer和Backup在内的所有服务器都是Real Server。在服务器上添加以下脚本/etc/init.d/tunl,用来配置tunl端口,应用arp补丁:#!/bin/sh# chkconfig: 2345 70 10# description: Config tunl port and apply arp patch VIP=0. /etc/rc.d/init.d/functionscase $1 instart)echo Tunl port startingifconfig tunl0 $VIP netmask 55 broadcast $VIP upecho 1 /proc/sys/net/ipv4/ip_forwardecho 1 /proc/sys/net/ipv4/conf/all/hiddenecho 1 /proc/sys/net/ipv4/conf/tunl0/hidden;stop)echo Tunl port closingifconfig tunl0 downecho 1 /proc/sys/net/ipv4/ip_forwardecho 0 /proc/sys/net/ipv4/conf/all/hidden;*)echo Usage: $0 start|stopexit 1esac如果有多个Virutal IP,可以使用tunl0:0,tunl0:1.。chmod 755 /etc/init.d/tunlchkconfig -add tunl 在Load Balancer和Backup上,这个脚本的启动级必须先于heartbeat,关闭级必须后于heartbeat。Scripts在HeartBeat资源文件(/etc/ha.d/haresources)中定义了实现集群所需的各个软件的启动脚本。这些脚本必须放在/etc/init.d或者/etc/ha.d/resource.d目录里,启动顺序不能变:loadbalancer lvs IPaddr:0/24/eth0 ipvsadm ldirectordIPaddr的作用是启动Virutal IP,它是HeartBeart自带的一个脚本。ipvsadm的作用是在启动的时候把所有Real Server加入群中。ldirectord的作用是启动ldirectord监控程序。lvs的作用是为启动Load Balancer做准备,关闭tunl端口,取消arp补丁:#!/bin/sh# chkconfig: 2345 90 10# description: Preparing for Load Balancer and Real Server switching VIP=0. /etc/rc.d/init.d/fun
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 安装施工合同范本
- 矿山建设工程合同范本
- 装饰木板采购合同范本
- 劳务合同范本文库
- 获得性大疱性表皮松解症护理查房
- 供暖服务评估合同
- 混凝土单包工合同范本
- 自建铺面出售合同范本
- 简易加盟餐饮合同范本
- 订单农业合同范本 俄语
- 粮食仓储(粮库)安全生产标准化管理体系全套资料汇编(2019-2020新标准实施模板)
- 喜茶运营管理手册和员工操作管理手册
- 比亚迪汉DM-i说明书
- 心肾综合征及其临床处理
- 普通高中课程方案
- 2022年山东高考生物试卷真题及答案详解(精校版)
- GB/T 38936-2020高温渗碳轴承钢
- 高考地理一轮复习课件 【知识精讲+高效课堂】 农业区位因素及其变化
- 教师专业发展与名师成长(学校师范专业公共课)
- 互通立交设计课件
- 生物竞赛辅导 动物行为学第七章 行为发育(38)课件
评论
0/150
提交评论