Memcached安装使用

1 Memcached安装演示

Memcached是基于libevent的事件处理,libevent是一个事件触发的网络库,适用于windows、linux、bsd等多种平台,内部使用select、epoll、kqueue等系统调用管理事件机制。而且libevent在使用上可以做到跨平台,而且根据libevent官方网站上公布的数据统计,似乎也有着非凡的性能

1.安装libevent

1) 先查看libevent是否已经安装:

[root@nn~]# rpm-qa|grep libevent

[root@nn~]# ls /usr/lib|grep libevent
2) 下载libevent

如果没有安装,并且服务器已经有YUM源,则可以直接yum下载安装:

[root@nn~]#yum–y install libevent*
没有YUM源的情况,则可以到网址:http://libevent.org/进行libevent-2.0.21-stable.tar.gz下载,也可以通过以下的方式下载到服务器:

[root@nn~]# wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
或者(本案例通过下面的方式进行下载):

[root@nn~]# curl-O-L http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz

3) 解压缩libevent

[root@nn~]# tar-zxvf libevent-2.0.21-stable.tar.gz
[root@nn~]# cd/root/libevent-2.0.21-stable


4) 配置libevent

[root@nn libevent-2.0.21-stable]# ./configure--prefix=/usr

1) 安装libevent

[root@nn libevent-2.0.21-stable]#make&make install

5) 查看libevent安装情况

[root@nn libevent-2.0.21-stable]# ll/usr/lib/libevent*
或者
[root@nn libevent-2.0.21-stable]# ls-al/usr/lib|grep libevent

如果查询到如下的结果,则表明libevent安装成功。

2.Memcached安装

1) Memcached安装包下载

如果系统已配有YUM安装源,则可以直接执行如下的命令完成安装:

[root@nn~]# yum-y install memcached

如果没有YUM源,则需要自行下载Memcached的最新安装包再进行安装,安装包可在:http://www.memcached.org/上进行下载,本案例下载的是memcached-1.4.21.tar.gz

[root@nn~]# wget www.memcached.org/files/memcached-1.4.21.tar.gz


2) Memcached安装包解压

[root@nn~]# tar-zxvf memcached-1.4.21.tar.gz

[root@nn~]# cd/root/memcached-1.4.21

3) Memcached配置

[root@nn memcached-1.4.21]# ./configure --with-libevent=/usr


或者:

<pre name="code" class="sql">[root@nn memcached-1.4.21]# ./configure --prefix=/usr/local --with-libevent=/usr
 

4) Memcached安装

[root@nn memcached-1.4.21]# make&&make install


5)查看Memcached安装情况

[root@nn memcached-1.4.21]# ll /usr/local/bin/memcached
[root@nn memcached-1.4.21]# ls -al /usr/local/bin/memcached
[root@nn memcached-1.4.21]# ll /usr/local/bin|grep memcached

3.Memcached测试

1) Memcached启动

[root@nn~]# memcached -d -m 512 -c 512 -p 11211 -u root -t 10


单台服务器上可以开启多个Memcached,只要端口号不一就行:

[root@zengxiangtao ~]# memcached -d -m 512 -c 512 -p 11211 -u root -t 10
[root@zengxiangtao ~]# memcached -d -m 512 -c 512 -p 11212 -u root -t 10
[root@zengxiangtao ~]# memcached -d -m 512 -c 512 -p 11213 -u root -t 10</span>

2) 查看是否启动成功

[root@nn~]# netstat -ntlp | grep memcached


3) telnet测试Memcached

[root@nn~]# telnet localhost 11211

注:其中11211Memcached运行的默认端口,当然你也可以用其它端口来运行,退出telnet输入quit即可。

4) 停止Memcatched(找到进程,杀掉进程)

[root@nn~]# pgrep -l memcached
[root@nn~]# netstat-ntlp | grep memcached
[root@nn~]# kill -9 7249




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值