Linux下使用Magent+Memcached缓存服务器集群部署
1.编译安装libevent
cd /root/soft_hhf/
wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar -xvf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-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 –C /usr/local
tar -zxvf memcached-1.2.6.tar.gz –C /usr/local
cd /usr/local
mv memcached-1.2.6 memcached
cd memcached
./configure --with-libevent=/usr/local
make
cd memcached
./configure --with-libevent=/usr/local
make
make install
exportPKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
exportPKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
3.编译安装Magent
cd /usr/local
mkdir magent
tar -zxf magent-0.5.tar.gz –C /usr/local/ magent
tar -zxf magent-0.5.tar.gz –C /usr/local/ magent
cd /usr/local/ magent
/sbin/ldconfig
sed -i "s#LIBS = -levent#LIBS = -levent-lm#g" Makefile
vi magetn.c
/sbin/ldconfig
sed -i "s#LIBS = -levent#LIBS = -levent-lm#g" Makefile
vi magetn.c
添加:
#ifndef SSIZE_MAX
# define SSIZE_MAX 32767
#endif
make
cp magent /usr/bin/magent
. /etc/init.d/iptables stop
cp magent /usr/bin/magent
. /etc/init.d/iptables stop
安装完成,其中memched是缓存服务器,给予libevent进行IO操作所以需要安装libevent,Magent是代理服务器,客户端连入Magnet它实现了服务器的负载均衡和服务器备份以至于当服务器出现done机时可以启用备份服务器,以及通过hash算法进行路由寻址将数据set到服务器上.
4.搭建测试.
这里提供三台memcached服务器来存储数据,两台memcached服务器来备份数据.
首先启用这5台memcached服务器,端口分别是:s1:3333,s2:4444,s3:5555,b1:6666,b6:7777
启动命令: memcached -m 1 -u root -d -l127.0.0.1 -p 3333
![](https://images2015.cnblogs.com/blog/730484/201602/730484-20160206232903929-263628815.png)
说明启动成功以此启动剩余的4台服务器
![](https://images2015.cnblogs.com/blog/730484/201602/730484-20160206233135444-1034727336.png)
启动Magent代理服务器
magent -u root -n 51200 -l 127.0.0.1 -p 2222 -s 127.0.0.1:3333 -s127.0.0.1:4444 -s127.0.0.1:5555 -b 127.0.0.1:6666 -b 127.0.0.1:7777
![](https://images2015.cnblogs.com/blog/730484/201602/730484-20160206233522179-214234236.png)
至此服务器集群搭建成功
5.进行测试
通过telent连接magent
telnet 127.0.0.1 2222
stats 查看状态
![](https://images2015.cnblogs.com/blog/730484/201602/730484-20160206233840757-183740975.png)
简单的set,get测试
![](https://images2015.cnblogs.com/blog/730484/201602/730484-20160206234152725-731554742.png)
posted on 2016-02-06 23:43 LittlePony 阅读(2191) 评论(0) 编辑 收藏 举报