下载预备软件:
mcached 下载地址: http://memcached.org/
bevent 下载地址: http://www.monkey.org/~provos/libevent/
操作系统:SUSE Linux 9 64位
memcached需要libevent的支持,我们需要先安装libevent
先安装 libevent
再安装 Memcached 主程序
源码下载:(最新版)
libevent官网:http://monkey.org/~provos/libevent/
Memcached官网:http://www.danga.com/memcached
# wget http://monkey.org/~provos/libevent-x.x.x-stable.tar.gz
# wget http://memcached.googlecode.com/files/memcached-x.x.x.tar.gz
安装libevent
shell>tar –zxvf libevent-x.x.x-stable.tar.gz //解压源文件包
shell>cd libevent-x.x.x-stable //进入解压后的目录
shell>./configure --prefix=/usr/local/libevent //译后生成的目标文件夹
shell>make
shell>make install
安装memcached
shell>tar –zxvf memcached-x.x.x.tar.gz //解压源文件包
shell>cd memcached-x.x.x //进入解压后的目录
shell>./configure --with-libevent=/usr/local/libevent --prefix=/usr/local/memcached //设置libevent的位置和编译后生成的目标文件夹
shell>make
shell>make install
启动memcached
shell>cd /usr/local/memcached/bin
shell>./memcached –d –p 9999 –m 128 (-p 9999是指定监听端口为9999)
运行memcached时报错
“/memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory” (根据libevent的版本,公共库名可能不同)
通过使用export将libevent的路径加入 LD_LIBRARY_PATH,命令如下:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/libevent/lib
关注基本选项
-p <num> 监听的TCP端口 (缺省: 11211)
-d 以守护进程方式运行Memcached
-u <username> 运行Memcached的账户,非root用户
-m <num> 最大的内存使用, 单位是MB,缺省是 64 MB
-c <num> 软连接数量, 缺省是 1024
-v 输出警告和错误信息
-vv 打印客户端的请求和返回信息
-h 打印帮助信息
-i 打印memcached和libevent的版权信息
测试:
Ps aux | grep memcached
Telnet 127.0.0.1 11211 (如果是根据上面-p 9999参数的话,就应该是Telnet 127.0.0.1 9999)