memcached for linux安装

               

author:skate

time:2010-12-18


 

 

linux下 memcached-1.4.5  安装

 

os版本:CentOS release 4.7

 

 

一. 安装:libevent

 

下载地址:http://www.monkey.org/~provos/libevent/
./configure --prefix=/usr/local/libevent
make && make install

 


二. 安装:memcached

 

下载地址:http://code.google.com/p/memcached/downloads/list

 

wget http://memcached.org/latest
tar -zxvf memcached-1.4.5.tar.gz
cd memcached-1.4.5
./configure --prefix=/usr/local/memcache --with-libevent=/usr/local/libevent/
make &&  make install

 


错误1:
安装包的时候运行./configure --prefix=/usr/local/memcache --with-libevent=/usr/local/libevent/ 时出现下面的提示:
checking build system type... Invalid configuration `i686-pc-linux-': machine `i686-pc-linux' not recognized
configure: error: /bin/sh config/config.sub i686-pc-linux- failed

 

解决方法:
./configure --prefix=/usr/local/memcache --with-libevent=/usr/local/libevent/ --build=i686-pc-linux-gnu

 

 

错误2:
configure: error: no acceptable C compiler found in $PATH

 

解决方法:
yum install gcc

./configure --prefix=/usr/local/memcache --with-libevent=/usr/local/libevent/
make && make install

 


三. 启动服务 :
memcached -d -m 10    -u root -l 192.168.40.4 -p 12000 -c 256 -P /tmp/memcached.pid  (完整启动)
memcached -d -m 1024    -u root  -p 55001 -c 2048   (默认启动)

 


参数说明:
-d选项是启动一个守护进程
-m是分配给Memcache使用的内存数量,单位是MB,我这里是10MB
-u是运行Memcache的用户,我这里是root
-l是监听的服务器IP地址
-p是设置Memcache监听的端口,最好是1024以上的端口
-c选项是最大运行的并发连接数,默认是1024,按照你服务器的负载量来设定
-P是设置保存Memcache的pid文件
-vv 调试模式

 


在启动memcache时会遇到如下的错误
[root@crs2 memcached-1.4.5]# ./memcached -d -m 64    -u root  -p 55001 -c 2048
./memcached: error while loading shared libraries: libevent-2.0.so.2: cannot open shared object file: No such file or directory

 

解决方法:

[root@crs2 memcached-1.4.5]# LD_DEBUG=libs /usr/local/memcache/bin/memcached -v
      9957:     find library=libevent-2.0.so.2 [0]; searching
      9957:      search cache=/etc/ld.so.cache
      9957:      search path=/lib/tls/i686/sse2:/lib/tls/i686:/lib/tls/sse2:/lib/tls:/lib/i686/sse2:/lib/i686:/lib/sse2:/lib:/usr/lib/tls/i686/sse2:/usr/lib/tls/i686:/usr/lib/tls/sse2:/usr/lib/tls:/usr/lib/i686/sse2:/usr/lib/i686:/usr/lib/sse2:/usr/lib              (system search path)
      9957:       trying file=/lib/tls/i686/sse2/libevent-2.0.so.2
      9957:       trying file=/lib/tls/i686/libevent-2.0.so.2
      9957:       trying file=/lib/tls/sse2/libevent-2.0.so.2
      9957:       trying file=/lib/tls/libevent-2.0.so.2
      9957:       trying file=/lib/i686/sse2/libevent-2.0.so.2
      9957:       trying file=/lib/i686/libevent-2.0.so.2
      9957:       trying file=/lib/sse2/libevent-2.0.so.2
      9957:       trying file=/lib/libevent-2.0.so.2
      9957:       trying file=/usr/lib/tls/i686/sse2/libevent-2.0.so.2
      9957:       trying file=/usr/lib/tls/i686/libevent-2.0.so.2
      9957:       trying file=/usr/lib/tls/sse2/libevent-2.0.so.2
      9957:       trying file=/usr/lib/tls/libevent-2.0.so.2
      9957:       trying file=/usr/lib/i686/sse2/libevent-2.0.so.2
      9957:       trying file=/usr/lib/i686/libevent-2.0.so.2
      9957:       trying file=/usr/lib/sse2/libevent-2.0.so.2
      9957:       trying file=/usr/lib/libevent-2.0.so.2
      9957:
/usr/local/memcache/bin/memcached: error while loading shared libraries: libevent-2.0.so.2: cannot open shared object file: No such file or directory

 

创建了软连接就可以解决
[root@crs2 memcached-1.4.5]# ln -s /usr/local/libevent/lib/libevent-2.0.so.2 /lib/libevent-2.0.so.2

 

这时,再启动memcached 就可以了
[root@crs2 memcached-1.4.5]# ./memcached -d -m 64    -u root  -p 55001 -c 2048

 

 

登录memcache
[root@crs2 memcached-1.4.5]# telnet 127.0.0.1 55001
Trying 127.0.0.1...
Connected to localhost (127.0.0.1).
Escape character is '^]'.
stats
STAT pid 9963
STAT uptime 307
STAT time 1292559170
STAT version 1.4.5
STAT pointer_size 32
STAT rusage_user 0.000000
STAT rusage_system 0.043993
STAT curr_connections 10
STAT total_connections 11
STAT connection_structures 11
STAT cmd_get 0
STAT cmd_set 0
STAT cmd_flush 0
STAT get_hits 0
STAT get_misses 0
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 7
STAT bytes_written 0
STAT limit_maxbytes 67108864
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT bytes 0
STAT curr_items 0
STAT total_items 0
STAT evictions 0
STAT reclaimed 0
END
quit
Connection closed by foreign host.

 

 

 

参考官方文档:
http://code.google.com/p/memcached/wiki/NewInstallFromSource

 

 

 

 

 

 

------end------

 

 

 

 

 

           
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值