<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>I@laoer.com &#187; keepalived</title>
	<atom:link href="http://i.laoer.com/tag/keepalived/feed" rel="self" type="application/rss+xml" />
	<link>http://i.laoer.com</link>
	<description>技术、生活、感悟 -- Laoer的博客</description>
	<lastBuildDate>Mon, 15 Feb 2010 08:36:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>LVS和Nginx的一些杂记</title>
		<link>http://i.laoer.com/lvs-keepalived-nginx.html</link>
		<comments>http://i.laoer.com/lvs-keepalived-nginx.html#comments</comments>
		<pubDate>Fri, 03 Apr 2009 04:47:22 +0000</pubDate>
		<dc:creator>Laoer</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[keepalived]]></category>
		<category><![CDATA[LVS]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://i.laoer.com/?p=245</guid>
		<description><![CDATA[LVS（Linux Virtual Server）是章文嵩博士创立的开源项目，可以帮助我们建立高可用性和高扩展性的Linux集群，LVS性能非常好，在暂时不能花费巨资购买F5、NetDispatcher之类硬件的时期，LVS还是能够很好的满足需要的。
LVS的Linux组件IPVS在新版本的Linux内核里已经支持，不需要单独再安装，可以通过命令
lsmod &#124;grep ip_vs
检查内核是否支持IPVS。
ipvsadm是LVS的管理软件，在编译安装的时候要注意，先做一个ln连接，类似
ln -s /usr/src/kernels/2.6.9-42.EL-smp-i686 /usr/src/linux
或
ln -s /usr/src/kernels/2.6.18-8.el5-x86_64 /usr/src/linux
keepalived是一个很方便的LVS管理工具，只要需要配置keepalived的配置文件就可以了，不用一条一条的执行ipvsadm命令了。
将keepalived加为服务的方法（keepalived默认安装在/usr/local/etc下）
cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/
mkdir /etc/keepalived
cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/sbin/keepalived /usr/sbin/
关于虚拟IP与真实服务器IP的端口对应问题
在测试中，发现虚拟IP的端口只能和真实服务器IP的端口对应，比如虚拟IP的端口是80，后面对应的真实服务器的端口也只能是80，不能任意配置，真实服务器的端口，让我非常的不解，是我配置错误？还是LVS或keepalived得问题呢？
在Nginx服务器里也可以实现简单的Load Balance，举例
upstream tomcats {
ip_hash;
server 127.0.0.1:8080 max_fails=3 fail_timeout=30s;
server 127.0.0.1:8280 max_fails=3 fail_timeout=30s;
}
server {
location / {
proxy_pass http://tomcats;
}
}
其中，ip_hash的作用在于很据用IP做hash算法，分配到相应的后端服务上，这样的话，用可以基本上固定的分配到某台机子上，就不用担心Session的问题，fail_timeout和max_fails是指在单位时间重试的次数，如果连接不成功，则不会再向其转发请求。
]]></description>
			<content:encoded><![CDATA[<p>LVS（<a href="http://www.linuxvirtualserver.org/" target="_blank">Linux Virtual Server</a>）是章文嵩博士创立的开源项目，可以帮助我们建立高可用性和高扩展性的Linux集群，LVS性能非常好，在暂时不能花费巨资购买F5、NetDispatcher之类硬件的时期，LVS还是能够很好的满足需要的。</p>
<p>LVS的Linux组件IPVS在新版本的Linux内核里已经支持，不需要单独再安装，可以通过命令</p>
<p>lsmod |grep ip_vs</p>
<p>检查内核是否支持IPVS。</p>
<p><a href="http://www.linuxvirtualserver.org/software/ipvs.html" target="_blank">ipvsadm</a>是LVS的管理软件，在编译安装的时候要注意，先做一个ln连接，类似</p>
<p>ln -s /usr/src/kernels/2.6.9-42.EL-smp-i686 /usr/src/linux<br />
或<br />
ln -s /usr/src/kernels/2.6.18-8.el5-x86_64 /usr/src/linux</p>
<p><a href="http://www.keepalived.org/" target="_blank">keepalived</a>是一个很方便的LVS管理工具，只要需要配置keepalived的配置文件就可以了，不用一条一条的执行ipvsadm命令了。</p>
<p>将keepalived加为服务的方法（keepalived默认安装在/usr/local/etc下）</p>
<p>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/</p>
<p>关于虚拟IP与真实服务器IP的端口对应问题<br />
在测试中，发现虚拟IP的端口只能和真实服务器IP的端口对应，比如虚拟IP的端口是80，后面对应的真实服务器的端口也只能是80，不能任意配置，真实服务器的端口，让我非常的不解，是我配置错误？还是LVS或keepalived得问题呢？</p>
<p>在Nginx服务器里也可以实现简单的Load Balance，举例</p>
<p>upstream tomcats {<br />
ip_hash;<br />
server 127.0.0.1:8080 max_fails=3 fail_timeout=30s;<br />
server 127.0.0.1:8280 max_fails=3 fail_timeout=30s;<br />
}<br />
server {<br />
location / {<br />
proxy_pass http://tomcats;<br />
}<br />
}</p>
<p>其中，ip_hash的作用在于很据用IP做hash算法，分配到相应的后端服务上，这样的话，用可以基本上固定的分配到某台机子上，就不用担心Session的问题，fail_timeout和max_fails是指在单位时间重试的次数，如果连接不成功，则不会再向其转发请求。</p>
]]></content:encoded>
			<wfw:commentRss>http://i.laoer.com/lvs-keepalived-nginx.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
