[文章作者:张宴 本文版本:v1.0 最后修改:2009.01.19 转载请注明原文链接:http://blog.zyan.cc/post/393/]

  magent是一款开源的Memcached代理服务器软件,其项目网址为:

  http://code.google.com/p/memagent/

  一、安装步骤:
  1、编译安装libevent:
wget http://monkey.org/~provos/libevent-1.4.9-stable.tar.gz
tar zxvf libevent-1.4.9-stable.tar.gz
cd libevent-1.4.9-stable/
./configure --prefix=/usr
make && make install
cd ../


  2、编译安装Memcached:
wget http://danga.com/memcached/dist/memcached-1.2.6.tar.gz
tar zxvf memcached-1.2.6.tar.gz
cd memcached-1.2.6/
./configure --with-libevent=/usr
make && make install
cd ../


  3、编译安装magent:
mkdir magent
cd magent/
wget http://memagent.googlecode.com/files/magent-0.5.tar.gz
tar zxvf magent-0.5.tar.gz
/sbin/ldconfig
sed -i "s#LIBS = -levent#LIBS = -levent -lm#g" Makefile
make
cp magent /usr/bin/magent
cd ../




  二、使用实例:
memcached -m 1 -u root -d -l 127.0.0.1 -p 11211
memcached -m 1 -u root -d -l 127.0.0.1 -p 11212
memcached -m 1 -u root -d -l 127.0.0.1 -p 11213
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

  1、分别在11211、11212、11213端口启动3个Memcached进程,在12000端口开启magent代理程序;
  2、11211、11212端口为主Memcached,11213端口为备份Memcached;
  3、连接上12000的magent,set key1和set key2,根据哈希算法,key1被写入11212和11213端口的Memcached,key2被写入11212和11213端口的Memcached;
  4、当11211、11212端口的Memcached死掉,连接到12000端口的magent取数据,数据会从11213端口的Memcached取出;
  5、当11211、11212端口的Memcached重启复活,连接到12000端口,magent会从11211或11212端口的Memcached取数据,由于这两台Memcached重启后无数据,因此magent取得的将是空值,尽管11213端口的Memcached还有数据(此问题尚待改进)。



  三、整个测试流程:
[root@centos52 ~]# telnet 127.0.0.1 12000
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
stats
memcached agent v0.4
matrix 1 -> 127.0.0.1:11211, pool size 0
matrix 2 -> 127.0.0.1:11212, pool size 0
END
set key1 0 0 8
zhangyan
STORED
set key2 0 0 8
zhangyan
STORED
quit
Connection closed by foreign host.


[root@centos52 ~]# telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
get key1
END
get key2
VALUE key2 0 8
zhangyan
END
quit
Connection closed by foreign host.


[root@centos52 ~]# telnet 127.0.0.1 11212
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
get key1
VALUE key1 0 8
zhangyan
END
get key2
END
quit
Connection closed by foreign host.


[root@centos52 ~]# telnet 127.0.0.1 11213
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
get key1
VALUE key1 0 8
zhangyan
END
get key2
VALUE key2 0 8
zhangyan
END
quit
Connection closed by foreign host.


模拟11211、11212端口的Memcached死掉
[root@centos52 ~]# ps -ef | grep memcached
root      6589     1  0 01:25 ?        00:00:00 memcached -m 1 -u root -d -l 127.0.0.1 -p 11211
root      6591     1  0 01:25 ?        00:00:00 memcached -m 1 -u root -d -l 127.0.0.1 -p 11212
root      6593     1  0 01:25 ?        00:00:00 memcached -m 1 -u root -d -l 127.0.0.1 -p 11213
root      6609  6509  0 01:44 pts/0    00:00:00 grep memcached
[root@centos52 ~]# kill -9 6589
[root@centos52 ~]# kill -9 6591
[root@centos52 ~]# telnet 127.0.0.1 12000
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
get key1
VALUE key1 0 8
zhangyan
END
get key2
VALUE key2 0 8
zhangyan
END
quit
Connection closed by foreign host.


模拟11211、11212端口的Memcached重启复活
[root@centos52 ~]# memcached -m 1 -u root -d -l 127.0.0.1 -p 11211
[root@centos52 ~]# memcached -m 1 -u root -d -l 127.0.0.1 -p 11212
[root@centos52 ~]# telnet 127.0.0.1 12000
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
get key1
END
get key2
END
quit
Connection closed by foreign host.






技术大类 » Cache与存储 | 评论(97) | 引用(8) | 阅读(107862)
杭州夜场招聘/杭州最好的夜场是哪里www.dongfangmeli.com
[2013-6-28 04:52]
来源:郑另希民
内容:杭州最好的夜场是www.dongfangmeli.com杭州东方魅力
杭州夜场招聘首选www.dongfangmeli.com
杭州最好的夜场是杭州东方魅力www.dongfangmeiliclub.com

杭州最好的ktv是哪儿?是杭州东方魅力www.dongfangmeiliclub.com

杭州夜场招聘首选杭州东方魅力www.dongfangmeiliclub.com

杭州最好的夜总会是杭州东方魅力www.dongfangmeiliclub.com

杭州东方魅力官方网站欢迎你 联系电话:13666653761 微信:dongfangmeili
django Email Homepage
2013-11-30 19:46
Uggs Sale the ideal idea Coach Outlet Online  enough time to search for many of reduction Ugg boot. Like big portions? If you began ready your apartment, Coach Outlet  it's always best to consider the most effective way direct to the stage it could be to utilise your inventory throughout Coach Factory Outlet  concern, or maybe you basically won't destination stuff not enough.we're anti- whitening tray because Coach Outlet Online  i will be enjoy just get germ dog breeders
ss
2014-2-25 14:25
Great blog. All posts have something to learn. Your work is very good and i appreciate you and hopping for some more informative posts.
IDRpoker.com Agen Texas Poker Online Indonesia Terpercaya | IDRpoker.com Agen Texas Poker Online Indonesia Terpercaya | Alfamart official partner merchandise FIFA piala dunia Brazil 2014
刷Q币 Homepage
2014-5-27 22:24
刷Q币 Homepage
2014-5-27 22:25
Steven Email Homepage
2015-3-19 02:57
Thank you for this post Weight Loss Tea
集体户口挂靠 Homepage
2015-4-28 12:58
支持一个
magent
2015-5-22 16:55
magent.c: In function ?.ritev_list?.magent.c:623: error: ?.SIZE_MAX?.undeclared (first use in this function)magent.c:623: error: (Each undeclared identifier is reported only oncemagent.c:623: error: for each function it appears in.)make: *** [magent.o] Error 1大神,出现这个错误,要怎吗解决啊
便宜点卡_殴飞数卡特卖频道_殴飞网上商城便宜
[2015-5-31 15:11]
来源:薛法三印
内容:便宜点卡http://temai.ofcard.com_殴飞数卡特卖频道_殴飞网上商城便宜...
提供手机话费充值,游戏点卡充值,公共事业缴费等,本站全部商品为欧飞官方货源,客服为欧飞官方7x24小时客服...游戏点卡充值,欧飞数卡,ofcard
Celine Homepage
2021-3-3 15:45
I learned a lot from the insight you shared here. It's good to learn more about this topic, and if you have some free time or you're curious about some celebrity basic information, you can visit celebrity heights and search for it.
Ieuan Ventura
2021-10-20 17:59
You are equal in your treatment to everyone and communicate with your peers respectfully. I am happy that i visit your page.  เว็บสล็อต
thomasfrank Email
2022-6-18 13:02
I am surprised about this post. It has a nice presentation, and clear layout, and the information is meaningful to me. Join quordle game to play some exciting word puzzle games. games io
shz Email
2022-6-29 20:13
I’m happy I located this blog! From time to time, students want to cognitive the keys of productive literary essays composing. Your first-class knowledge about this good post can become a proper basis for such people. nice one  online dealings
shz Email
2022-6-29 20:20
This post is very simple to read and appreciate without leaving any details out. Great work!  online dealings
shz Email
2022-6-29 20:32
A debt of gratitude is in order for giving late reports with respect to the worry, I anticipate read more.  online dealings
shz Email
2022-6-29 20:38
All the contents you mentioned in post is too good and can be very useful. I will keep it in mind, thanks for sharing the information keep updating, looking forward for more posts.Thanks  online dealings
shz Email
2022-6-29 20:43
I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business.  online dealings
shz Email
2022-6-29 20:46
Thanks a lot for one’s intriguing write-up. It’s actually exceptional. Searching ahead for this sort of revisions.  online dealings
shz Email
2022-8-4 21:59
It is perfect time to make some plans for the future and it is time to be happy. I've read this post and if I could I desire to suggest you some interesting things or suggestions. Perhaps you could write next articles referring to this article. I want to read more things about it!  Scam Risk
shz Email
2022-8-4 22:06
I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post. Hats off to you! The information that you have provided is very helpful.  Scam Risk
分页: 4/6 第一页 上页 1 2 3 4 5 6 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]