Memcached(Linux)安装及启动
下载好libevent 和 Memcached
http://libevent.org/
http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz
http://memcached.org/
http://memcached.googlecode.com/files/memcached-1.4.13.tar.gz
安装 libevent
# tar zxvf libevent-2.0.19-stable.tar.gz
# cd libevent-2.0.19-stable
# ./configure --prefix=/usr
# make
# make install
# tar zxvf memcached-1.4.13.tar.gz
# cd memcached-1.4.13
# ./configure --prefix=/usr/local
# make
# make install
Memcached运行
[root@localhost /]# /usr/local/bin/memcached -u root & (后台运行)
查看帮助信息
# /usr/local/bin/memcached -h
关注基本选项
-p <num> 监听的TCP端口 (缺省: 11211)
-d 以守护进程方式运行Memcached
-u <username> 运行Memcached的账户,非root用户
-m <num> 最大的内存使用, 单位是MB,缺省是 64 MB
-c <num> 软连接数量, 缺省是 1024
-v 输出警告和错误信息
-vv 打印客户端的请求和返回信息
-h 打印帮助信息
-i 打印memcached和libevent的版权信息
运行 Memcached
目标:使用11211端口、hualiangxie用户、最大占用512M内存、1024个软连接,输
出客户端请求,以守护进程方式运行
# /usr/local/bin/memcached -p 11211 -d -u root -m 512 -c 1024 -vvv
检查是否正常启动
[root@localhost bin]# ps auxxww | grep memcached
root 23698 0.0 0.1 54472 1040 ? Ssl 18:26 0:00 memcached -p 11211 -d -u root -m 512 -c1024 -vvv
root 23780 0.0 0.0 5120 664 pts/2 R+ 18:28 0:00 grep memcached
# telnet localhost 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
stats
STAT pid 4402
STAT uptime 1032
STAT time 1231155683
STAT version 1.2.6
STAT pointer_size 32
...
END
启动Memcached服务时,遇到的问题:
error while loading shared libraries: libevent-2.0.so.5: cannotopen shared object file: No such file or directory
输入下面命令
> whereis libevent-2.0.so.5
> ldd /usr/local/bin/memcached
如图:
> LD_DEBUG=libs ./memcached -v (这个没用到)
找到默认路径 /usr/lib/
>sudo ln -s /usr/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
>sudo ldd /usr/local/bin/memcached
如图:
再次启动Memcached服务即可。