[文章作者:张宴 本文版本:v1.0 最后修改:2009.01.19 转载请注明原文链接:http://blog.zyan.cc/post/393/]
magent是一款开源的Memcached代理服务器软件,其项目网址为:
http://code.google.com/p/memagent/
一、安装步骤:
1、编译安装libevent:
2、编译安装Memcached:
3、编译安装magent:
二、使用实例:
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还有数据(此问题尚待改进)。
三、整个测试流程:
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 ../
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 ../
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 ../
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
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.
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.
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.
点击在新窗口中浏览此图片
http://www.oschina.net/question/858822_77253
错误地址贴在:
http://www.oschina.net/question/858822_77253
希望帮忙分析下,谢谢
内容:哪里可以买驾驶证http://www.jiashi008.com买驾驶证多少钱,买驾照,办驾照http://www.jiashi008.com
鹏诚通讯科技有限公司
24小时客服QQ:13417527
24小时免费咨询电话:18268787444
朋友,想不想让你的手机很有个性? 明明你在深圳,而你跟朋友聊天的时候,你朋友的电话上显示你在广州(上 海/天津/武汉/兰州等)以至香港. 明明你在跟朋友玩,而你打电话给你家人,让家人以为你在外地出差. 明天你不是刘德华,而你总是你用刘德华的电话号在打电话 明明你现在在内地,而你非要在你朋友面前说你在香港. 想不想拥有了?
本业务不会影响你本手机的使用,想使用改号业务时就拨一下我们系统的预约号码,不想使用时就直接用你手机打出还是原来的号,不会改变你手机原来的实际号码,互不干扰.
交易方式:支持各大银行和淘宝交易.
内容:我的淘宝客网站开好了大家看看把http://t.cn/zjXt1oK
内容:海阔天空娱乐会所15026982229全国本地上门兼职按摩
欢迎光临海海阔天空俏佳人时尚娱乐会所
我们是全国连锁,为您就近提供上门兼职按摩服务
第一步:服务预约电话:15026982229【杨姐】
第二步:按照客人提出的要求安排技师;请说出您的详细地址
第三步: 技师半小时左右到达您的住所,请耐心等待
第四步:技师到达与客人当面沟通,如客人不满意,支付技师往返车费,请求更换技师或服务结束
第五步:客人对技师满意后,技师开始服务
第六步:服务结束,客人结帐
技师图片请进网站查看: Http://WWW.LVCAI.ORG
内容:海阔天空娱乐会所15026982229全国本地上门兼职按摩
欢迎光临海海阔天空俏佳人时尚娱乐会所
我们是全国连锁,为您就近提供上门兼职按摩服务
第一步:服务预约电话:15026982229【杨姐】
第二步:按照客人提出的要求安排技师;请说出您的详细地址
第三步: 技师半小时左右到达您的住所,请耐心等待
第四步:技师到达与客人当面沟通,如客人不满意,支付技师往返车费,请求更换技师或服务结束
第五步:客人对技师满意后,技师开始服务
第六步:服务结束,客人结帐
技师图片请进网站查看: Http://WWW.LVCAI.ORG
内容:杭州最好的夜场是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 杭州东方魅力官方博客http://donfangmeili.qzone.qq.com杭州东方魅力博客