[文章作者:张宴 本文版本: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) | 阅读(105734)
Nike Air Max Email Homepage
2012-5-18 17:42
This nike air max for sale belongs to the sounding just what are termed as nike air vintage best sellers, many other products and services for the reason that range appearing companies the actual nike air Galliera, plus the nike air outlet monogram selection. nike dunks are made of high leather materials which can be durable and fashionable.They will make you become the focus in the streets or audience.
xujie777 Email
2012-5-19 08:49
We aim to make all our customers satisfy with our products. You will find a variety of Men's fashion louis vuitton uk, fashion Women's cheap Louis Vuitton bags in our store at affordable price.Thinking of interesting ways to cost a milestone birthday? louis vuitton online shop had one of the most distinctive distinctive celebrations.bakery along with living room operated by means of about three moment louis vuitton online Most effective Pastry Chef’s of the year Rammy Nominee Chef’s.
xujie777 Email
2012-5-19 08:49
The choices are likely to be basically countless seeing that louis vuitton outlet occurs with the help of completely new and also incredible concepts once in a while.Louis vuitton Wholesale Monogram Canvas HandbagsLouis Vuitton Collection Beach Handbags louis vuitton bags outlet Damier Canvas HandbagsLouis vuitton Mahina HandbagsLouis Vuitton Monogram Mini Lin HandbagsLouis Vuitton Monogram Multicolore HandbagsLouis vuitton Monogram Vernis HandbagsLouis Vuitton Wholesale Epi Leather HandbagsLouis Vuitton For Men HandbagsLouis Vuitton Damier Canvas WalletsLouis Vuitton Epi Leather WalletsLouis Vuitton Monogram Canvas WalletsLouis Vuitton Monogram Vernis WalleLouis Vuitton ShoesLouis Vuitton Men wallets.As the Authentic Louis Vuitton are so high-priced, so came the louis vuitton handbags outlet.
xujie777 Email
2012-5-19 08:50
coach outlet has become a popular shopping experience for consumers around the world, and a desirable distribution channel for manufacturer's and retailers.Getting your hands on coach outlet store online can be a hefty investment of hundreds of dollars.But do not despair,the Coach Outlet store could be the answer to your prayers.coach outlet online is your smart choice when you want to get the discount Coach accessory. You can find the exact Coach Bags and other accessory you want at a low price that's right for you. My dear friends, let the coach outlet online pave your way into the world of high fashion with their ultimate fashion factory.
xujie123
2012-5-21 11:28
Our online store offers you discounted Designer louis vuitton replica wallet at present. You could find them in desirable quality and price. If you don't mind high class louis vuitton uk, have a good time here.louis vuitton Store Online Handbags can also bring great accuracy as well as practical applicability and fashionable.Have you ever dreamed of being as charming as Madonna? Have you ever thought of becoming an envy of all your friends? If so, come to louis vuitton outlet.<br/>
xujie555
2012-5-21 13:55
coach factory outlet uses graceful accessories to match the classical logo of coach, which is the best combination of coach. The handmade coach products?can make you more charming and graceful.coach factory online provides people many coach goods. If you wish to snatch the coach handbag, then this best method is made for that you like for coach discount.coach factory outlet online is a fashion brand to ensure its quality. With designer coach shoulder bags, you will always attract people's attention. The bags will emphasize your personal style and taste.<br/>
xujie333
2012-5-21 15:18
coach outlet online Store guarantee that all the coach handbags offered are own high quality. In addition , all of them are sold at an unexpected low price.If you want to purchase, just visit their website.coach factory outlet is really sizzling kinds of shopping way for you. With the usage of the replica designer coach bags, you can surely be able to change your individual looks in a stunning manner.Coach bags on sale from the coach outlet are cheap or discount prices that you certainly will stand out from the crowd on your next camping trip!<br/>
lirourou77 Email Homepage
2012-9-5 14:12
Lvjing Hai, the flexibility to delay the basic pension policy, if implemented, will do the elderly occupied by young people to work. In this regard, countries <b>discount designer clothes<b>      
should be to stimulate economic growth, new jobs, to alleviate this problem.

His analysis, private enterprises and foreign enterprises, joint ventures, to attract a large number of employment staff in order to enable flexibility to delay in receiving the basic pension policies can be implemented smoothly, it seems, or should the broad-brush approach to enforce appropriate.

Chu Fu-ling: each year involving tens of millions <b>wholesale designer handbags<b>      
of people

Chu Fu Ling told reporters in the country to implement the flexibility to delay the basic pension policies each year may involve tens of millions of people, and thus lead to the problem of young people unable to enter these positions. This massive amount of posts can not be vacated, may be <b>designer handbags for less<b>      
difficult through the newly developed position, such as to resolve all of a sudden.
gw574813284@sina.com
2012-11-1 15:15
我安装magent为什么报错呢?

点击在新窗口中浏览此图片
http://www.oschina.net/question/858822_77253

错误地址贴在:
http://www.oschina.net/question/858822_77253

希望帮忙分析下,谢谢
哪里可以买驾驶证,买驾驶证,买驾驶证多少钱,买驾照,办驾照
[2012-11-15 02:04]
来源:林本忙井
内容:哪里可以买驾驶证http://www.jiashi008.com买驾驶证多少钱,买驾照,办驾照http://www.jiashi008.com
汤汪水的 Email
2012-12-11 03:32
手机号码任意显示 (可以免费测试一次)
鹏诚通讯科技有限公司    
24小时客服QQ:13417527
24小时免费咨询电话:18268787444
朋友,想不想让你的手机很有个性? 明明你在深圳,而你跟朋友聊天的时候,你朋友的电话上显示你在广州(上 海/天津/武汉/兰州等)以至香港. 明明你在跟朋友玩,而你打电话给你家人,让家人以为你在外地出差. 明天你不是刘德华,而你总是你用刘德华的电话号在打电话 明明你现在在内地,而你非要在你朋友面前说你在香港. 想不想拥有了?
本业务不会影响你本手机的使用,想使用改号业务时就拨一下我们系统的预约号码,不想使用时就直接用你手机打出还是原来的号,不会改变你手机原来的实际号码,互不干扰.
交易方式:支持各大银行和淘宝交易.
我的淘宝客网站开好了大家看看把
[2012-12-12 13:55]
来源:梁弦羊妾
内容:我的淘宝客网站开好了大家看看把http://t.cn/zjXt1oK
hello
2013-1-8 14:14
uplook
FWAERTW
2013-1-29 16:43
买轴承就到:www.jkzhoucheng.cn
Daived
2013-3-7 17:42
请教一下  在java代码中如何调用magent 12000端口?  是直接调用11211端口就可以了吗?
华子
2013-4-26 12:37
我在实际中php 要怎么调用呢,我调用magent的ip、port不能写入,但是直接写memcached的就可以,请指教。
海阔天空娱乐会所15026982229全国本地上门兼职按摩
[2013-5-24 15:01]
来源:段突完宅
内容:海阔天空娱乐会所15026982229全国本地上门兼职按摩
欢迎光临海海阔天空俏佳人时尚娱乐会所
我们是全国连锁,为您就近提供上门兼职按摩服务
第一步:服务预约电话:15026982229【杨姐】
第二步:按照客人提出的要求安排技师;请说出您的详细地址
第三步: 技师半小时左右到达您的住所,请耐心等待
第四步:技师到达与客人当面沟通,如客人不满意,支付技师往返车费,请求更换技师或服务结束
第五步:客人对技师满意后,技师开始服务
第六步:服务结束,客人结帐

技师图片请进网站查看: Http://WWW.LVCAI.ORG
海阔天空娱乐会所15026982229全国本地上门兼职按摩
[2013-5-27 13:00]
来源:于贝旺平
内容:海阔天空娱乐会所15026982229全国本地上门兼职按摩
欢迎光临海海阔天空俏佳人时尚娱乐会所
我们是全国连锁,为您就近提供上门兼职按摩服务
第一步:服务预约电话:15026982229【杨姐】
第二步:按照客人提出的要求安排技师;请说出您的详细地址
第三步: 技师半小时左右到达您的住所,请耐心等待
第四步:技师到达与客人当面沟通,如客人不满意,支付技师往返车费,请求更换技师或服务结束
第五步:客人对技师满意后,技师开始服务
第六步:服务结束,客人结帐

技师图片请进网站查看: Http://WWW.LVCAI.ORG
杭州夜场招聘/杭州最好的夜场是哪里www.dongfangmeli.com
[2013-5-29 08:59]
来源:雷丘耳眉
内容:杭州最好的夜场是www.dongfangmeli.com杭州东方魅力
杭州夜场招聘首选www.dongfangmeli.com
杭州最好的夜场是杭州东方魅力www.dongfangmeiliclub.com

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

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

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

杭州东方魅力官方网站欢迎你 联系电话:13666653761 微信:dongfangmeili
http://donfangmeili.qzone.qq.com
[2013-6-27 06:49]
来源:杨双香甚
内容:http://donfangmeili.qzone.qq.com 杭州东方魅力官方博客http://donfangmeili.qzone.qq.com杭州东方魅力博客
分页: 3/6 第一页 上页 1 2 3 4 5 6 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]