<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[张宴的博客]]></title> 
<link>http://zyan.cc/index.php</link> 
<description><![CDATA[Web系统架构与底层研发]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[张宴的博客]]></copyright>
<item>
<link>http://zyan.cc/post/393/</link>
<title><![CDATA[Memcached的代理服务器软件：magent使用小记[原创]]]></title> 
<author>张宴 &lt;net@s135.com&gt;</author>
<category><![CDATA[Cache与存储]]></category>
<pubDate>Sun, 18 Jan 2009 16:02:39 +0000</pubDate> 
<guid>http://zyan.cc/post/393/</guid> 
<description>
<![CDATA[ 
	　　[文章作者：张宴 本文版本：v1.0 最后修改：2009.01.19 转载请注明原文链接：<a href="http://blog.zyan.cc/post/393/" target="_blank">http://blog.zyan.cc/post/393/</a>]<br/><br/>　　magent是一款开源的Memcached代理服务器软件，其项目网址为：<br/><br/>　　<a href="http://code.google.com/p/memagent/" target="_blank">http://code.google.com/p/memagent/</a><br/><br/>　　一、安装步骤：<br/>　　1、编译安装libevent：<br/><div style="border-left: 0px dashed #D6C094; margin: 5px; padding: 3px; margin-bottom:0px; border: 1px dashed #00a0c6; background-color: #ffffff;">wget <a href="http://monkey.org/~provos/libevent-1.4.9-stable.tar.gz" target="_blank">http://monkey.org/~provos/libevent-1.4.9-stable.tar.gz</a><br/>tar zxvf libevent-1.4.9-stable.tar.gz<br/>cd libevent-1.4.9-stable/<br/>./configure --prefix=/usr<br/>make && make install<br/>cd ../</div><br/><br/>　　2、编译安装Memcached：<br/><div style="border-left: 0px dashed #D6C094; margin: 5px; padding: 3px; margin-bottom:0px; border: 1px dashed #00a0c6; background-color: #ffffff;">wget <a href="http://danga.com/memcached/dist/memcached-1.2.6.tar.gz" target="_blank">http://danga.com/memcached/dist/memcached-1.2.6.tar.gz</a><br/>tar zxvf memcached-1.2.6.tar.gz<br/>cd memcached-1.2.6/<br/>./configure --with-libevent=/usr<br/>make && make install<br/>cd ../</div><br/><br/>　　3、编译安装magent：<br/><div style="border-left: 0px dashed #D6C094; margin: 5px; padding: 3px; margin-bottom:0px; border: 1px dashed #00a0c6; background-color: #ffffff;">mkdir magent<br/>cd magent/<br/>wget <a href="http://memagent.googlecode.com/files/magent-0.5.tar.gz" target="_blank">http://memagent.googlecode.com/files/magent-0.5.tar.gz</a><br/>tar zxvf magent-0.5.tar.gz<br/>/sbin/ldconfig<br/>sed -i "s#LIBS = -levent#LIBS = -levent -lm#g" Makefile<br/>make<br/>cp magent /usr/bin/magent<br/>cd ../</div><br/><br/><hr/><br/>　　二、使用实例：<br/><div style="border-left: 0px dashed #D6C094; margin: 5px; padding: 3px; margin-bottom:0px; border: 1px dashed #00a0c6; background-color: #ffffff;">memcached -m 1 -u root -d -l 127.0.0.1 -p 11211<br/>memcached -m 1 -u root -d -l 127.0.0.1 -p 11212<br/>memcached -m 1 -u root -d -l 127.0.0.1 -p 11213<br/>magent -u root -n 51200 -l 127.0.0.1 -p 12000 -s 127.0.0.1:11211 -s 127.0.0.1:11212 -b 127.0.0.1:11213</div><br/>　　1、分别在11211、11212、11213端口启动3个Memcached进程，在12000端口开启magent代理程序；<br/>　　2、11211、11212端口为主Memcached，11213端口为备份Memcached；<br/>　　3、连接上12000的magent，set key1和set key2，根据哈希算法，key1被写入11212和11213端口的Memcached，key2被写入11212和11213端口的Memcached；<br/>　　4、当11211、11212端口的Memcached死掉，连接到12000端口的magent取数据，数据会从11213端口的Memcached取出；<br/>　　5、当11211、11212端口的Memcached重启复活，连接到12000端口，magent会从11211或11212端口的Memcached取数据，由于这两台Memcached重启后无数据，因此magent取得的将是空值，尽管11213端口的Memcached还有数据（此问题尚待改进）。<br/><br/>............<br/><br/>Tags - <a href="http://zyan.cc/tags/linux/" rel="tag">linux</a> , <a href="http://zyan.cc/tags/memcached/" rel="tag">memcached</a> , <a href="http://zyan.cc/tags/memcache/" rel="tag">memcache</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/393/#blogcomment2436</link>
<title><![CDATA[[评论] Memcached的代理服务器软件：magent使用小记[原创]]]></title> 
<author>dengjiuhong &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 19 Jan 2009 01:36:07 +0000</pubDate> 
<guid>http://zyan.cc/post/393/#blogcomment2436</guid> 
<description>
<![CDATA[ 
	3、连接上12000的magent，set key1和set key2，根据哈希算法，key1被写入11212和11213端口的Memcached，key2被写入11212和11213端口的Memcached；貌似key1是写入11211和11213？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/393/#blogcomment2437</link>
<title><![CDATA[[评论] Memcached的代理服务器软件：magent使用小记[原创]]]></title> 
<author>xi2008wang &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 19 Jan 2009 01:44:04 +0000</pubDate> 
<guid>http://zyan.cc/post/393/#blogcomment2437</guid> 
<description>
<![CDATA[ 
	已阅
]]>
</description>
</item><item>
<link>http://zyan.cc/post/393/#blogcomment2440</link>
<title><![CDATA[[评论] Memcached的代理服务器软件：magent使用小记[原创]]]></title> 
<author>稳压电源 &lt;fdsaf@126.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 19 Jan 2009 06:23:33 +0000</pubDate> 
<guid>http://zyan.cc/post/393/#blogcomment2440</guid> 
<description>
<![CDATA[ 
	很详细 谢谢了 &nbsp;学习中。。。<br/><br/><br/><a href="http://www.wuchenwenyaqi.com/cpzs.asp" target="_blank">稳压电源</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/393/#blogcomment2446</link>
<title><![CDATA[[评论] Memcached的代理服务器软件：magent使用小记[原创]]]></title> 
<author>Tim &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Tue, 20 Jan 2009 02:56:44 +0000</pubDate> 
<guid>http://zyan.cc/post/393/#blogcomment2446</guid> 
<description>
<![CDATA[ 
	感觉主要是容错功能吧，象 java memcached client 默认带了类似功能。<br/><br/><a href="http://www.whalin.com/memcached/HOWTO.txt" target="_blank">http://www.whalin.com/memcached/HOWTO.txt</a><br/><br/>By default the java client will failover to a new server when a server<br/>dies. &nbsp;It will also failback to the original if it detects that the<br/>server comes back (it checks the server in a falling off pattern).<br/><br/>If you want to disable this (useful if you have flapping servers),<br/>there are two settings to handle this.<br/><br/>&nbsp;&nbsp;pool.setFailover( false );<br/>&nbsp;&nbsp;pool.setFailback( false );
]]>
</description>
</item><item>
<link>http://zyan.cc/post/393/#blogcomment2451</link>
<title><![CDATA[[评论] Memcached的代理服务器软件：magent使用小记[原创]]]></title> 
<author>dd_macle &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 21 Jan 2009 05:06:15 +0000</pubDate> 
<guid>http://zyan.cc/post/393/#blogcomment2451</guid> 
<description>
<![CDATA[ 
	拜读了
]]>
</description>
</item><item>
<link>http://zyan.cc/post/393/#blogcomment2487</link>
<title><![CDATA[[评论] Memcached的代理服务器软件：magent使用小记[原创]]]></title> 
<author>沙加 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sun, 01 Feb 2009 10:18:23 +0000</pubDate> 
<guid>http://zyan.cc/post/393/#blogcomment2487</guid> 
<description>
<![CDATA[ 
	为什么不补充一点为什么需要使用这个代理的理由呢，也照顾一下俺们这些初级读者嘛~~
]]>
</description>
</item><item>
<link>http://zyan.cc/post/393/#blogcomment2527</link>
<title><![CDATA[[评论] Memcached的代理服务器软件：magent使用小记[原创]]]></title> 
<author>evil_knight &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 05 Feb 2009 15:02:09 +0000</pubDate> 
<guid>http://zyan.cc/post/393/#blogcomment2527</guid> 
<description>
<![CDATA[ 
	感觉在应用里面直接实现会少一个proxy层，效率会好，当然想应用无关的思想最好！呵呵！
]]>
</description>
</item><item>
<link>http://zyan.cc/post/393/#blogcomment2803</link>
<title><![CDATA[[评论] Memcached的代理服务器软件：magent使用小记[原创]]]></title> 
<author>todayboy &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 16 Mar 2009 02:49:27 +0000</pubDate> 
<guid>http://zyan.cc/post/393/#blogcomment2803</guid> 
<description>
<![CDATA[ 
	我的网站是php + oracle 的 ，我现在在phg上加了memcache ,也开启了memcached 进程，但感觉网站没有任何性情的改变，不知我那里错，张兄能不能写一篇 memcache比较完整的文章？？？？？？谢谢
]]>
</description>
</item><item>
<link>http://zyan.cc/post/393/#blogcomment2866</link>
<title><![CDATA[[评论] Memcached的代理服务器软件：magent使用小记[原创]]]></title> 
<author>向你学习 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Tue, 24 Mar 2009 03:06:21 +0000</pubDate> 
<guid>http://zyan.cc/post/393/#blogcomment2866</guid> 
<description>
<![CDATA[ 
	发现 你一处手误 <br/><br/>magent -u root -n 51200 -l 127.0.0.1 -p 12000 -s 127.0.0.1:11211 -s 127.0.0.1:11212 <u>-b</u> 127.0.0.1:11213<br/><br/>打下划线的部分应该 改成&nbsp;&nbsp;-s 吧？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/393/#blogcomment3971</link>
<title><![CDATA[[评论] Memcached的代理服务器软件：magent使用小记[原创]]]></title> 
<author>瞎玩 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 02 Sep 2009 03:36:26 +0000</pubDate> 
<guid>http://zyan.cc/post/393/#blogcomment3971</guid> 
<description>
<![CDATA[ 
	proxy 宕掉了呢？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/393/#blogcomment4160</link>
<title><![CDATA[[评论] Memcached的代理服务器软件：magent使用小记[原创]]]></title> 
<author>变压器 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 10 Oct 2009 02:17:48 +0000</pubDate> 
<guid>http://zyan.cc/post/393/#blogcomment4160</guid> 
<description>
<![CDATA[ 
	这个东西很详细 我在学习<br/><br/><br/><a href="http://www.wuchenwenyaqi.com/" target="_blank">变压器</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/393/#blogcomment4338</link>
<title><![CDATA[[评论] Memcached的代理服务器软件：magent使用小记[原创]]]></title> 
<author>天下小飞~ &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 02 Nov 2009 17:33:19 +0000</pubDate> 
<guid>http://zyan.cc/post/393/#blogcomment4338</guid> 
<description>
<![CDATA[ 
	哥们，你老牛了，改天去北京看看你吧
]]>
</description>
</item><item>
<link>http://zyan.cc/post/393/#blogcomment4954</link>
<title><![CDATA[[评论] Memcached的代理服务器软件：magent使用小记[原创]]]></title> 
<author>奇迹花园 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 05 Feb 2010 08:50:08 +0000</pubDate> 
<guid>http://zyan.cc/post/393/#blogcomment4954</guid> 
<description>
<![CDATA[ 
	5、当11211、11212端口的Memcached重启复活，连接到12000端口，magent会从11211或11212端口的Memcached取数据，由于这两台Memcached重启后无数据，因此magent取得的将是空值，尽管11213端口的Memcached还有数据（此问题尚待改进）。<br/>老兄，我想知道这个问题怎么解决。这个问题比较棘手。
]]>
</description>
</item><item>
<link>http://zyan.cc/post/393/#blogcomment6347</link>
<title><![CDATA[[评论] Memcached的代理服务器软件：magent使用小记[原创]]]></title> 
<author>jelly &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 14 Jul 2010 02:22:46 +0000</pubDate> 
<guid>http://zyan.cc/post/393/#blogcomment6347</guid> 
<description>
<![CDATA[ 
	重新从db中读取放入mc中呗
]]>
</description>
</item><item>
<link>http://zyan.cc/post/393/#blogcomment6359</link>
<title><![CDATA[[评论] Memcached的代理服务器软件：magent使用小记[原创]]]></title> 
<author>勇气的力量 &lt;wikkywu@163.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 15 Jul 2010 12:02:56 +0000</pubDate> 
<guid>http://zyan.cc/post/393/#blogcomment6359</guid> 
<description>
<![CDATA[ 
	5、当11211、11212端口的Memcached重启复活，连接到12000端口，magent会从11211或11212端口的Memcached取数据，由于这两台Memcached重启后无数据，因此magent取得的将是空值，尽管11213端口的Memcached还有数据（此问题尚待改进）。<br/>老兄，我想知道这个问题怎么解决。这个问题比较棘手。 <br/>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br/>这个是可以解决的。<br/>在get查询时，magent只在返回字节数小于0的情况下才查询备用服务器，对应主服务器down机。所以你要做的，就是在这个点判断返回的字节数，如果为5,&#039;END\r\n&#039;,则主服务器没有数据返回，这时需要强制它查询备用服务器。
]]>
</description>
</item>
</channel>
</rss>