memcached安装和启动
1
下载libevent-1.4.11-stable.tar.gz//http://www.monkey.org/~provos/libevent/
#cd/tmp
#tarlibevent-1.4.11-stable.tar.gz
#cdlibevent-1.4.11-stable
#./configure--prefix=/usr
#make
#makeinstall
2
下载memcached-1.2.8.tar.gz//http://www.danga.com/memcached/
#cd/tmp
#tarzxvfmemcached-1.2.8.tar.gz
#cdmemcached-1.2.8
#./configure--with-libevent=/usr
#make
#makeinstall
3
测试
/usr/local/bin/memcached-h
正常ok
4
常见错误
/usr/local/bin/memcached:errorwhileloadingsharedlibraries:libevent-1.4.so.2:cannotopensharedobjectfile:Nosuchfileordirectory
解决办法
LD_DEBUG=libsmemcached-v
输出
4962:findlibrary=libevent-1.4.so.2[0];searching
4962:searchcache=/etc/ld.so.cache
4962:searchpath=/lib64/tls/x86_64:/lib64/tls:/lib64/x86_64:/lib64:/usr/lib64/tls/x86_64:/usr/lib64/tls:/usr/lib64/x86_64:/usr/lib64(systemsearchpath)
4962:tryingfile=/lib64/tls/x86_64/libevent-1.4.so.2
4962:tryingfile=/lib64/tls/libevent-1.4.so.2
4962:tryingfile=/lib64/x86_64/libevent-1.4.so.2
4962:tryingfile=/lib64/libevent-1.4.so.2
4962:tryingfile=/usr/lib64/tls/x86_64/libevent-1.4.so.2
4962:tryingfile=/usr/lib64/tls/libevent-1.4.so.2
4962:tryingfile=/usr/lib64/x86_64/libevent-1.4.so.2
4962:tryingfile=/usr/lib64/libevent-1.4.so.2
4962:
memcached:errorwhileloadingsharedlibraries:libevent-1.4.so.2:cannotopensharedobjectfile:Nosuchfileordirectory
然后对应的做link
ln-s/usr/lib/libevent-1.4.so.2/usr/lib64/libevent-1.4.so.2
5启动
#/usr/local/bin/memcached-d-m2048-uroot-l192.168.1.20-p12111-c1024-P/tmp/memcached.pid
参数说明:
-d启动为守护进程
-m<num>分配给Memcached使用的内存数量,单位是MB,默认为64MB
-u<username>运行Memcached的用户,仅当作为root运行时
-l<ip_addr>监听的服务器IP地址,默认为环境变量INDRR_ANY的值
-p<num>设置Memcached监听的端口,最好是1024以上的端口
-c<num>设置最大并发连接数,默认为1024
-P<file>设置保存Memcached的pid文件,与-d选择同时使用