<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[运维进行时]]></title> 
<link>https://www.liuts.com/index.php</link> 
<description><![CDATA[互联网运维与架构]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[运维进行时]]></copyright>
<item>
<link>https://www.liuts.com/post/188/</link>
<title><![CDATA[部署天涯LVS管理平台管理端[原创]]]></title> 
<author>刘天斯 &lt;liutiansi@gmail.com&gt;</author>
<category><![CDATA[LVS]]></category>
<pubDate>Wed, 10 Mar 2010 07:26:18 +0000</pubDate> 
<guid>https://www.liuts.com/post/188/</guid> 
<description>
<![CDATA[ 
	一、部署LAMP/LNMP+CodeIgniter框架(略)<br/>二、<a href="http://www.sysab.cn/a/tech/mail/2009/1103/4150.html" target="_blank">安装rrdtool</a><br/>三、下载管理平台包<br/>wget http://tianyalvs.googlecode.com/files/TianyaLVS.tar.gz<br/>cd "web root"<br/>tar -zxvf TianyaLVS.tar.gz<br/><strong>注意事项</strong><br/><br/>1、要求webroot/TianyaLVS/LVS、webroot/TianyaLVS/images/LVS目录可写。<br/>2、系统需.htaccess支持，除rewrite支持外apache还需添加：<br/><textarea name="code" class="c" rows="15" cols="100">
<Directory "/www/TianyaLVS">&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride All&nbsp;&nbsp; 
</Directory>
</textarea><br/><strong>修改项</strong><br/>cd TianyaLVS/TianyaLVSsystem/application/config<br/>vi config.php<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>//访问URL<br/>$config['base_url']&nbsp;&nbsp;= "http://localhost/";<br/>//站点目录位置<br/>$config['webroot']&nbsp;&nbsp;= '/www/TianyaLVS';<br/>//管理端应用程序位置<br/>$config['adminroot']&nbsp;&nbsp;= '/home/LVS';<br/></div></div><br/><br/>vi database.php<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>$db['default']['hostname'] = "localhost";<br/>$db['default']['username'] = "dbuser";<br/>$db['default']['password'] = "dbpass";<br/>$db['default']['database'] = "tianyalvs";<br/>$db['default']['dbdriver'] = "mysql";<br/></div></div><br/><br/>二、下载管理脚本<br/>cd /home<br/>wget http://tianyalvs.googlecode.com/files/LVS_shell.tar.gz<br/>tar -zxvf LVS_shell.tar.gz<br/><br/>#探测real server func状态<br/><strong>check.sh</strong><br/><br/>#并生成图<br/><strong>graph-lvs.sh</strong><br/>根据实际情况修改参数<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>WORKDIR="/www/TianyaLVS/LVS/$3/performance"<br/>RRDTOOL="/usr/bin/rrdtool"<br/>GRAPHS="/www/TianyaLVS/images/LVS/$3"<br/></div></div><br/><br/>＃获取、分析rrd<br/><strong>LVSgraph.py</strong><br/>根据实际情况修改参数，与database.php保持一致<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>LVSpath=/home/LVS<br/>import MySQLdb<br/>host='localhost'<br/>user='dbuser'<br/>passwd='dbpass'<br/>db='tianyilvs'<br/></div></div><br/><br/>＃func主模块<br/><strong>ModuleClass.py</strong><br/><br/>＃同步配置LB脚本<br/><strong>Production_realserver.sh</strong><br/>根据实际情况修改参数<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>realserversh=/home/LVS<br/></div></div><br/><br/>#LB脚本模板<br/><strong>rrealserver.sh.model</strong><br/><br/>#同步master的rrd文件<br/><strong>rsync.sh</strong><br/>根据实际情况修改参数<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>KEY=/home/rsync/rsync-key<br/>RUSER=rsyncuser<br/>RPATH=/home/lvs-rrd/performance<br/>LPATH=/www/TianyaLVS/LVS/$1<br/></div></div><br/>注：在配置该步骤前请确实已做好这一步“<a href="http://blog.liuts.com/post/59/" target="_blank">实践rsync+ssh实现代码同步</a>”，实施这一步后将会有KEY、RUSER参数值。<br/><br/>#lVS Performance<br/>*/1 * * * * /usr/local/bin/python /home/LVS/LVSgraph.py<br/><br/>四、访问http://localhost/，完成系统安装、配置。<br/><br/>如大家有什么疑问或感兴趣的话题可以通过weibo与我交流：<a href="http://t.qq.com/yorkoliu" target="_blank">http://t.qq.com/yorkoliu</a><br/>Tags - <a href="https://www.liuts.com/tags/lvs/" rel="tag">lvs</a> , <a href="https://www.liuts.com/tags/%25E6%259C%258D%25E5%258A%25A1%25E5%2599%25A8%25E7%25AB%25AF%25E8%2584%259A%25E6%259C%25AC/" rel="tag">服务器端脚本</a>
]]>
</description>
</item><item>
<link>https://www.liuts.com/post/187/</link>
<title><![CDATA[部署LVS+Keepalived平台[原创]]]></title> 
<author>刘天斯 &lt;liutiansi@gmail.com&gt;</author>
<category><![CDATA[LVS]]></category>
<pubDate>Wed, 10 Mar 2010 03:55:21 +0000</pubDate> 
<guid>https://www.liuts.com/post/187/</guid> 
<description>
<![CDATA[ 
	安装步骤如下：<br/>ln -s /usr/src/kernels/2<span style="color: #FF4500;">.6.9-89.0.9.EL-smp-x86_64</span>/&nbsp;&nbsp;/usr/src/linux<br/><span style="color: #FF6347;">2.6.9-89.0.9.EL-smp-x86_64</span>与uname -a内核配对。<br/><strong>下载</strong><br/>wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24.tar.gz<br/>wget http://www.keepalived.org/software/keepalived-1.1.15.tar.gz<br/><br/><strong>安装</strong><br/>tar zxvf ipvsadm-1.24.tar.gz<br/>cd ipvsadm-1.24<br/>make && make install<br/>cd ..<br/>tar zxvf keepalived-1.1.15.tar.gz<br/>cd keepalived-1.1.15<br/><strong>注意项</strong><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>Centos5.0以下需要修改以下configure才能通过。<br/>vi /usr/src/linux/include/linux/types.h<br/>/*<br/>typedef __u16 __bitwise __sum16;<br/>typedef __u32 __bitwise __wsum;<br/>*/<br/></div></div><br/>./configure<br/>make && make install<br/><br/>cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/<br/>cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/<br/>mkdir /etc/keepalived<br/>cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/<br/>cp /usr/local/sbin/keepalived /usr/sbin/<br/><br/>service keepalived start<br/><br/><strong>为了配合LVS平台，还需如下操作</strong><br/>1、<a href="http://www.sysab.cn/a/tech/mail/2009/1103/4150.html" target="_blank">安装RRDTOOL</a><br/>2、配置master端流量rrd数据采集<br/>cd /home<br/>wget http://tianyalvs.googlecode.com/files/lvs-rrd.tar.gz<br/>tar -zxvf lvs-rrd.tar.gz<br/>vi lvs-rrd/lvs.rrd.update<br/>根据用户实际情况来修改如下参数<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>RRDTOOL="/usr/bin/rrdtool"<br/>IPVSADM="/sbin/ipvsadm"<br/>WORKDIR="/home/lvs-rrd/performance"<br/></div></div><br/>3、定制采集作业<br/>*/2 * * * * /home/lvs-rrd/lvs.rrd.update 2> /dev/null > /dev/null<br/><br/>4、LVS管理平台端会定期来捉取performance中的*.rrd文件，用户可以通过ssh或ftp，系统默认采用rsync+ssh方式，配置可参考<a href="http://blog.liuts.com/post/59/" target="_blank">实践rsync+ssh实现代码同步</a><br/><br/><strong>问题总结</strong><br/>1、make keepalived时提示：<br/>make[2]: Leaving directory `/home/install/lvs/keepalived-1.1.15/keepalived/core'<br/>make[2]: Entering directory `/home/install/lvs/keepalived-1.1.15/keepalived/check'<br/>gcc -g -O2&nbsp;&nbsp;-I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_&nbsp;&nbsp;-c check_daemon.c<br/>In file included from /usr/src/linux/include/linux/netlink.h:5,<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from ../include/vrrp_netlink.h:35,<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from check_daemon.c:40:<br/>/usr/src/linux/include/linux/types.h:158: error: syntax error before "__sum16"<br/>/usr/src/linux/include/linux/types.h:158: warning: type defaults to `int' in declaration of `__sum16'<br/>/usr/src/linux/include/linux/types.h:158: warning: data definition has no type or storage class<br/>/usr/src/linux/include/linux/types.h:159: error: syntax error before "__wsum"<br/>/usr/src/linux/include/linux/types.h:159: warning: type defaults to `int' in declaration of `__wsum'<br/>/usr/src/linux/include/linux/types.h:159: warning: data definition has no type or storage class<br/>make[2]: *** [check_daemon.o] Error 1<br/>make[2]: Leaving directory `/home/install/lvs/keepalived-1.1.15/keepalived/check'<br/>make[1]: *** [all] Error 1<br/>make[1]: Leaving directory `/home/install/lvs/keepalived-1.1.15/keepalived'<br/>make: *** [all] Error 2<br/>解决：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>vi /usr/src/linux/include/linux/types.h<br/>/*<br/>typedef __u16 __bitwise __sum16;<br/>typedef __u32 __bitwise __wsum;<br/>*/<br/></div></div><br/><br/>2、master、backup的/var/log/messagse显示<br/>Nov 23 17:46:41 SN2008-06-070 Keepalived_vrrp: receive an invalid ip number count associated with VRID!<br/>Nov 23 17:46:41 SN2008-06-070 Keepalived_vrrp: bogus VRRP packet received on eth0 !!!<br/>Nov 23 17:46:41 SN2008-06-070 Keepalived_vrrp: VRRP_Instance(VI_1) Dropping received VRRP packet...<br/>Nov 23 17:46:42 SN2008-06-070 Keepalived_vrrp: receive an invalid ip number count associated with VRID!<br/>Nov 23 17:46:42 SN2008-06-070 Keepalived_vrrp: bogus VRRP packet received on eth0 !!!<br/>Nov 23 17:46:42 SN2008-06-070 Keepalived_vrrp: VRRP_Instance(VI_1) Dropping received VRRP packet...<br/><br/>解决：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>修改 virtual_router_id 的值，与网络中不能重复。<br/></div></div><br/><br/>3、在/var/log/messages中Keepalived_vrrp不生效，即无vrrp日志。<br/>解决：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>重新编译源码包，可能是由于修改types.h后才configure。<br/></div></div><br/><br/>如大家有什么疑问或感兴趣的话题可以通过weibo与我交流：<a href="http://t.qq.com/yorkoliu" target="_blank">http://t.qq.com/yorkoliu</a><br/>Tags - <a href="https://www.liuts.com/tags/lvs/" rel="tag">lvs</a> , <a href="https://www.liuts.com/tags/keepalived/" rel="tag">keepalived</a>
]]>
</description>
</item><item>
<link>https://www.liuts.com/post/185/</link>
<title><![CDATA[LVS管理平台使用手册(第二版)[原创]]]></title> 
<author>刘天斯 &lt;liutiansi@gmail.com&gt;</author>
<category><![CDATA[LVS]]></category>
<pubDate>Wed, 10 Mar 2010 02:51:44 +0000</pubDate> 
<guid>https://www.liuts.com/post/185/</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp; 由于第一版的LVS管理平台是整合到现有的运维系统中，现用CodeIgniter框架+certmaster+func重写了老的管理平台，比原系统更具有独立性，主要功能模块分为性能图表、数据中心、虚拟IP池、主机管理、监控模块、生成hosts、主机探测等功能，基本上是按F5－LTM管理平台思路来设计，下面只要对这几大块功能进行说明。<br/>项目托管地址：<a href="http://code.google.com/p/tianyalvs/" target="_blank">http://code.google.com/p/tianyalvs/</a><br/><strong>welcome</strong><br/><a href="https://www.liuts.com/attachment.php?fid=72" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=72" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0" width="700"/></a><br/><strong>1、性能图表</strong><br/>功能说明：以小时、日、星期、月、年的图表展示LVS SERVER、VIP、SERVER等流量情况，效果图如下：<br/><a href="https://www.liuts.com/attachment.php?fid=73" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=73" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0" width="700"/></a><br/><br/><strong>2、数据中心</strong><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;功能说明：管理LVS主机，一个LVS主机就是一个数据中心节点，功能包括新建、修改、生成、重载、图表、显示该组VIP等模块。<br/><a href="https://www.liuts.com/attachment.php?fid=74" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=74" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0" width="700"/></a><br/>2.1新建LVS节点：<br/><a href="https://www.liuts.com/attachment.php?fid=75" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=75" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0" width="700"/></a><br/>全局定义块 <br/>1、 email 通知。作用：有故障，发邮件报警。这是可选项目，建议不用，用 nagios 全面监<br/>控代替之。 <br/>2、 Lvs负载均衡器标识（lvs_id）。在一个网络内，它应该是唯一的。 <br/>3、 花括号“&#123;&#125;”。用来分隔定义块，因此必须成对出现。如果写漏了，keepalived运行时，不会得到预期的结果。由于定义块内存在嵌套关系，因此很容易遗漏结尾处的花括号，这点要特别注意。<br/><br/>VRRP 定义块 <br/>1、同步 vrrp 组 vrrp_sync_group。作用：确定失败切换（FailOver）包含的路由实个数。即在有2 个负载均衡器的场景，一旦某个负载均衡器失效，需要自动切换到另一个负载均衡器的实例是哪些？ <br/>2、实例组 group.至少包含一个 vrrp 实例。 <br/>3、Vrrp实例 vrrp_instance.实例名出自实例组 group 所包含的那些名字。 <br/>（1）实例状态 state.只有 MASTER和BACKUP 两种状态，并且需要大写这些单词。其中MASTER为工作状态，BACKUP 为备用状态。当 MASTER 所在的服务器失效时，BACKUP 所在的系统会自动把它的状态有 BACKUP 变换成 MASTER；当失效的MASTER所在的系统恢复时，BACKUP 从 MASTER 恢复到BACKUP 状态。 <br/>（2）通信接口 interface。对外提供服务的网络接口，如 eth0,eth1.当前主流的服务器都有2 个或2 个以上的接口，在选择服务接口时，一定要核实清楚。 <br/>（3）lvs_sync_daemon_inteface。 负载均衡器之间的监控接口，类似于 HA HeartBeat的心跳线。但它的机制优于 Heartbeat，因为它没有“裂脑”这个问题，它是以优先级这个机制来规避这个麻烦的。在DR 模式中，lvs_sync_daemon_inteface 与服务接口 interface 使用同一个网络接口。 <br/>（4）虚拟路由标识 virtual_router_id.这个标识是一个数字，并且同一个 vrrp 实例使用唯一的标识。即同一个 vrrp_stance,MASTER 和 BACKUP 的 virtual_router_id 是一致的，同时在整个 vrrp内是唯一的。 <br/>（5）优先级 priority.这是一个数字，数值愈大，优先级越高。在同一个vrrp_instance里，MASTER 的优先级高于 BACKUP。若 MASTER 的 priority 值为 150，那么 BACKUP的 priority 只能是140或更小的数值。 <br/>（6）同步通知间隔&nbsp;&nbsp;advert_int&nbsp;&nbsp;.MASTER与 BACKUP 负载均衡器之间同步检查的时间间隔，单位为秒。 <br/>（7）验证 authentication。包含验证类型和验证密码。类型主要有 PASS、AH 两种，通常使用的类型为 PASS，据说 AH 使用时有问题。验证密码为明文，同一 vrrp实例MASTER 与 BACKUP 使用相同的密码才能正常通信。 <br/><br/>4、 虚拟 ip 地址 virtual_ipaddress . 可以有多个地址，每个地址占一行，不需要指定子网掩码。注意：这个 ip必须与我们在 lvs客户端设定的 vip 相一致！<br/><br/>2.2、<a href="https://www.liuts.com/attachment.php?fid=19" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=19" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a>生成<br/>功能说明：在管理端生成配置文件并校验。<br/><br/>2.3、<a href="https://www.liuts.com/attachment.php?fid=23" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=23" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a>重载<br/>功能说明：将配置文件传输到LVS节点服务器并重启Keepalived服务。<br/><br/>2.3、<a href="https://www.liuts.com/attachment.php?fid=84" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=84" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a>图表<br/>功能说明：显示该LVS节点流量数据。<br/><br/><strong>3、虚拟IP池(VIP)</strong><br/>功能说明：添加、修改VIP池。<br/><a href="https://www.liuts.com/attachment.php?fid=76" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=76" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0" width="700"/></a><br/>3.1、添加图示：<br/><a href="https://www.liuts.com/attachment.php?fid=77" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=77" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0" width="700"/></a><br/>虚拟服务器 virtual_server定义块 <br/><br/>虚拟服务器定义是 keepalived框架最重要的项目了，是 keepalived.conf必不可少的部分。 <br/><br/>1、 虚拟服务器 virtual_server.&nbsp;&nbsp;这个 ip 来自于 vrrp 定义块的第“4”步，后面一个空格，然后加上端口号。定义一个vip，可以实现多个 tcp 端口的负载均衡功能。 <br/>（1）delay_loop。健康检查时间间隔，单位是秒。 <br/>（2）lb_algo. 负载均衡调度算法，互联网应用常使用 wlc或 rr。 <br/>（3）lb_kind. 负载均衡转发规则。一般包括 DR,NAT,TUN3 种，在我的方案中，都使用DR 的方式。 <br/>（4）persistence_timeout.会话保持时间，单位是秒。这个选项对动态网站很有用处：当用户从远程用帐号进行登陆网站时，有了这个会话保持功能，就能把用户的请求转发给同一个应用服务器。在这里，我们来做一个假设，假定现在有一个 lvs 环境，使用 DR 转发模式，真实服务器有 3 个，负载均衡器不启用会话保持功能。当用户第一次访问的时候，他的访问请求被负载均衡器转给某个真实服务器，这样他看到一个登陆页面，第一次访问完毕；接着他在登陆框填写用户名和密码，然后提交；这时候，问题就可能出现了—登陆不能成功。因为没有会话保持，负载均衡器可能会把第 2次的请求转发到其他的服务器。 <br/>（5）转发协议 protocol.一般有 tcp 和 udp两种。实话说，我还没尝试过 udp协议类的转发。<br/><strong>4、主机管理</strong><br/>功能说明：包括添加、修改、设置LB等功能模块。<br/><a href="https://www.liuts.com/attachment.php?fid=78" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=78" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0" width="700"/></a><br/>4.1、添加SERVER<br/><a href="https://www.liuts.com/attachment.php?fid=79" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=79" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0" width="700"/></a><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;真实服务器 real_server.也即服务器池。Real_server的值包括 ip地址和端口号。多个连续的真实 ip，转发的端口相同，是不是可以以范围表示？需要进一步实验。如写成real_server 61.135.20.1-10 80 . <br/>（1）权重 weight.权重值是一个数字，数值越大，权重越高。使用不同的权重值的目的在于为不同性能的机器分配不同的负载，性能较好的机器，负载分担大些；反之，性能差的机器，则分担较少的负载，这样就可以合理的利用不同性能的机器资源。<br/><br/>4.2、<a href="https://www.liuts.com/attachment.php?fid=85" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=85" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a>设置LB<br/>功能说明：设置所选服务器的LoopbackIP，只限于DR模式。<br/><strong>5、监控模块</strong><br/>功能说明：添加、删除、修改自定义监控名称。<br/><a href="https://www.liuts.com/attachment.php?fid=80" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=80" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0" width="700"/></a><br/>5.1、添加监控点<br/><a href="https://www.liuts.com/attachment.php?fid=81" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=81" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0" width="700"/></a><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;监控类型包括SSL_GET、HTTP_GET、TCP_CHECK、SMTP_CHECK、MISC_CHECK等，选择不同的监控类型会提示你输入不同的参数值，一般情况下选择管理员添加的类型即可满足，一些特殊应用的监控可以自定义去添加。<br/><br/>Sky同学写的LVS管理工具(桌面版)<br/><a href="http://blog.chinaunix.net/u3/102731/article_133142.html" target="_blank">http://blog.chinaunix.net/u3/102731/article_133142.html</a><br/><br/>如大家有什么疑问或感兴趣的话题可以通过weibo与我交流：<a href="http://t.qq.com/yorkoliu" target="_blank">http://t.qq.com/yorkoliu</a><br/>Tags - <a href="https://www.liuts.com/tags/lvs/" rel="tag">lvs</a> , <a href="https://www.liuts.com/tags/%25E7%25AE%25A1%25E7%2590%2586%25E5%25B9%25B3%25E5%258F%25B0/" rel="tag">管理平台</a> , <a href="https://www.liuts.com/tags/%25E7%25AC%25AC%25E4%25BA%258C%25E7%2589%2588/" rel="tag">第二版</a>
]]>
</description>
</item><item>
<link>https://www.liuts.com/post/172/</link>
<title><![CDATA[LVS管理平台使用手册(第一版)[原创]]]></title> 
<author>root &lt;admin@yourname.com&gt;</author>
<category><![CDATA[LVS]]></category>
<pubDate>Wed, 23 Dec 2009 01:53:52 +0000</pubDate> 
<guid>https://www.liuts.com/post/172/</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;为了更好管理、维护LVS平台，本人基于Django+certmaster+func开发了一套管理平台，主要功能模块分为性能图表、数据中心、虚拟IP池、主机管理、监控模块等功能，基本上是按F5－LTM管理平台思路来设计，下面只要对这几大块功能进行说明。<br/><strong>1、性能图表</strong><br/>功能说明：以小时、日、星期、月、年的图表展示LVS SERVER、VIP、SERVER等流量情况，效果图如下：<br/><a href="https://www.liuts.com/attachment.php?fid=27" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=27" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0" width="700"/></a><br/><strong>2、数据中心</strong><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;功能说明：管理LVS主机，一个LVS主机就是一个数据中心节点，功能包括新建、修改、生成、重载、图表、显示该组VIP等模块。<br/><a href="https://www.liuts.com/attachment.php?fid=16" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=16" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0" width="700"/></a><br/>2.1新建LVS节点：<br/><a href="https://www.liuts.com/attachment.php?fid=28" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=28" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/>全局定义块 <br/>1、 email 通知。作用：有故障，发邮件报警。这是可选项目，建议不用，用 nagios 全面监<br/>控代替之。 <br/>2、 Lvs负载均衡器标识（lvs_id）。在一个网络内，它应该是唯一的。 <br/>3、 花括号“&#123;&#125;”。用来分隔定义块，因此必须成对出现。如果写漏了，keepalived运行时，不会得到预期的结果。由于定义块内存在嵌套关系，因此很容易遗漏结尾处的花括号，这点要特别注意。<br/><br/>VRRP 定义块 <br/>1、同步 vrrp 组 vrrp_sync_group。作用：确定失败切换（FailOver）包含的路由实个数。即在有2 个负载均衡器的场景，一旦某个负载均衡器失效，需要自动切换到另一个负载均衡器的实例是哪些？ <br/>2、实例组 group.至少包含一个 vrrp 实例。 <br/>3、Vrrp实例 vrrp_instance.实例名出自实例组 group 所包含的那些名字。 <br/>（1）实例状态 state.只有 MASTER和BACKUP 两种状态，并且需要大写这些单词。其中MASTER为工作状态，BACKUP 为备用状态。当 MASTER 所在的服务器失效时，BACKUP 所在的系统会自动把它的状态有 BACKUP 变换成 MASTER；当失效的MASTER所在的系统恢复时，BACKUP 从 MASTER 恢复到BACKUP 状态。 <br/>（2）通信接口 interface。对外提供服务的网络接口，如 eth0,eth1.当前主流的服务器都有2 个或2 个以上的接口，在选择服务接口时，一定要核实清楚。 <br/>（3）lvs_sync_daemon_inteface。 负载均衡器之间的监控接口，类似于 HA HeartBeat的心跳线。但它的机制优于 Heartbeat，因为它没有“裂脑”这个问题，它是以优先级这个机制来规避这个麻烦的。在DR 模式中，lvs_sync_daemon_inteface 与服务接口 interface 使用同一个网络接口。 <br/>（4）虚拟路由标识 virtual_router_id.这个标识是一个数字，并且同一个 vrrp 实例使用唯一的标识。即同一个 vrrp_stance,MASTER 和 BACKUP 的 virtual_router_id 是一致的，同时在整个 vrrp内是唯一的。 <br/>（5）优先级 priority.这是一个数字，数值愈大，优先级越高。在同一个vrrp_instance里，MASTER 的优先级高于 BACKUP。若 MASTER 的 priority 值为 150，那么 BACKUP的 priority 只能是140或更小的数值。 <br/>（6）同步通知间隔&nbsp;&nbsp;advert_int&nbsp;&nbsp;.MASTER与 BACKUP 负载均衡器之间同步检查的时间间隔，单位为秒。 <br/>（7）验证 authentication。包含验证类型和验证密码。类型主要有 PASS、AH 两种，通常使用的类型为 PASS，据说 AH 使用时有问题。验证密码为明文，同一 vrrp实例MASTER 与 BACKUP 使用相同的密码才能正常通信。 <br/><br/>4、 虚拟 ip 地址 virtual_ipaddress . 可以有多个地址，每个地址占一行，不需要指定子网掩码。注意：这个 ip必须与我们在 lvs客户端设定的 vip 相一致！<br/><br/>2.2、<a href="https://www.liuts.com/attachment.php?fid=19" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=19" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a>生成<br/>功能说明：在管理端生成配置文件并校验。<br/><br/>2.3、<a href="https://www.liuts.com/attachment.php?fid=23" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=23" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a>重载<br/>功能说明：将配置文件传输到LVS节点服务器并重启Keepalived服务。<br/><br/>2.3、<a href="https://www.liuts.com/attachment.php?fid=21" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=21" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a>图表<br/>功能说明：显示该LVS节点流量数据。<br/><br/><strong>3、虚拟IP池(VIP)</strong><br/>功能说明：添加、修改VIP池。<br/><a href="https://www.liuts.com/attachment.php?fid=26" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=26" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0" width="700"/></a><br/>3.1、添加图示：<br/><a href="https://www.liuts.com/attachment.php?fid=15" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=15" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/>虚拟服务器 virtual_server定义块 <br/><br/>虚拟服务器定义是 keepalived框架最重要的项目了，是 keepalived.conf必不可少的部分。 <br/><br/>1、 虚拟服务器 virtual_server.&nbsp;&nbsp;这个 ip 来自于 vrrp 定义块的第“4”步，后面一个空格，然后加上端口号。定义一个vip，可以实现多个 tcp 端口的负载均衡功能。 <br/>（1）delay_loop。健康检查时间间隔，单位是秒。 <br/>（2）lb_algo. 负载均衡调度算法，互联网应用常使用 wlc或 rr。 <br/>（3）lb_kind. 负载均衡转发规则。一般包括 DR,NAT,TUN3 种，在我的方案中，都使用DR 的方式。 <br/>（4）persistence_timeout.会话保持时间，单位是秒。这个选项对动态网站很有用处：当用户从远程用帐号进行登陆网站时，有了这个会话保持功能，就能把用户的请求转发给同一个应用服务器。在这里，我们来做一个假设，假定现在有一个 lvs 环境，使用 DR 转发模式，真实服务器有 3 个，负载均衡器不启用会话保持功能。当用户第一次访问的时候，他的访问请求被负载均衡器转给某个真实服务器，这样他看到一个登陆页面，第一次访问完毕；接着他在登陆框填写用户名和密码，然后提交；这时候，问题就可能出现了—登陆不能成功。因为没有会话保持，负载均衡器可能会把第 2次的请求转发到其他的服务器。 <br/>（5）转发协议 protocol.一般有 tcp 和 udp两种。实话说，我还没尝试过 udp协议类的转发。<br/><strong>4、主机管理</strong><br/>功能说明：包括添加、修改、设置LB等功能模块。<br/><a href="https://www.liuts.com/attachment.php?fid=24" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=24" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0" width="700"/></a><br/>4.1、添加SERVER<br/><a href="https://www.liuts.com/attachment.php?fid=25" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=25" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;真实服务器 real_server.也即服务器池。Real_server的值包括 ip地址和端口号。多个连续的真实 ip，转发的端口相同，是不是可以以范围表示？需要进一步实验。如写成real_server 61.135.20.1-10 80 . <br/>（1）权重 weight.权重值是一个数字，数值越大，权重越高。使用不同的权重值的目的在于为不同性能的机器分配不同的负载，性能较好的机器，负载分担大些；反之，性能差的机器，则分担较少的负载，这样就可以合理的利用不同性能的机器资源。<br/><br/>4.2、<a href="https://www.liuts.com/attachment.php?fid=18" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=18" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a>设置LB<br/>功能说明：设置所选服务器的LoopbackIP，只限于DR模式。<br/><strong>5、监控模块</strong><br/>功能说明：添加、删除、修改自定义监控名称。<br/><a href="https://www.liuts.com/attachment.php?fid=29" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=29" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0" width="700"/></a><br/>5.1、添加监控点<br/><a href="https://www.liuts.com/attachment.php?fid=17" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=17" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><a href="https://www.liuts.com/attachment.php?fid=30" target="_blank"><img src="https://www.liuts.com/attachment.php?fid=30" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;监控类型包括SSL_GET、HTTP_GET、TCP_CHECK、SMTP_CHECK、MISC_CHECK等，选择不同的监控类型会提示你输入不同的参数值，一般情况下选择管理员添加的类型即可满足，一些特殊应用的监控可以自定义去添加。<br/><br/>如大家有什么疑问或感兴趣的话题可以通过weibo与我交流：<a href="http://t.qq.com/yorkoliu" target="_blank">http://t.qq.com/yorkoliu</a><br/>Tags - <a href="https://www.liuts.com/tags/lvs/" rel="tag">lvs</a> , <a href="https://www.liuts.com/tags/%25E7%25AE%25A1%25E7%2590%2586%25E5%25B9%25B3%25E5%258F%25B0/" rel="tag">管理平台</a>
]]>
</description>
</item>
</channel>
</rss>