频道栏目
IT货架 > > 正文
memcached安装
网友分享于:Jun 12, 2018 11:49:22 PM    来源: IT货架   
源:http://www.iteye.com/topic/110112
评:
memcached安装

1. 下载, memcached需要先安装libevent

memcached的下载地址:http://danga.com/memcached/download.bml

libevent的下载地址 :http://www.monkey.org/~provos/libevent/

2. 安装libevent
java 代码

    #  tar xzvf libevent-1.3c.tar.gz   
    # cd libevent-1.3c  
    # ./configure --prefix=/home/mahaibo/install  
    # make  
    # make install 

检查是否安装成功:

#cd /home/mahaibo/install/lib

如果有libevent-1.3c.so.1  libevent-1.3c.so.1.0.3  libevent.a  libevent.la  libevent.so

这几个文件存在,说明安装成功

3.安装memcached
java 代码

    #  tar xzvf memcached-1.2.2.tar.gz   
    # cd memcached-1.2.2 
    # ./configure --with-libevent=/home/mahaibo/install --prefix=/home/mahaibo/installmemcache  
    # make  
    # make install 

检查是否安装成功:

#cd /home/mahaibo/installmemcache/bin

如果memcached  memcached-debug这2个文件存在,说明安装成功

4.执行


java 代码

    #cd /home/mahaibo/installmemcache/bin  
     
    # ./memcached -h  

如果出现:
java 代码

    memcached 1.2.2 
    -p <num></num>      TCP port number to listen on (default: 11211)  
    -U <num></num>      UDP port number to listen on (default: 0, off)  
    -s <file></file>     unix socket path to listen on (disables network support)  
    -l <ip_addr></ip_addr>  interface to listen on, default is INDRR_ANY  
    -d            run as a daemon  
    -r            maximize core file limit  
    -u <username></username> assume identity of <username></username> (only when run as root)  
    -m <num></num>      max memory to use for items in megabytes, default is 64 MB  
    -M            return error on memory exhausted (rather than removing items)  
    -c <num></num>      max simultaneous connections, default is 1024 
    -k            lock down all paged memory  
    -v            verbose (print errors/warnings while in event loop)  
    -vv           very verbose (also print client commands/reponses)  
    -h            print this help and exit  
    -i            print memcached and libevent license  
    -b            run a managed instanced (mnemonic: buckets)  
    -P <file></file>     save PID in <file></file>, only used with -d option  
    -f <factor></factor>   chunk size growth factor, default 1.25 
    -n <bytes></bytes>    minimum space allocated for key+value+flags, default 48 



说明安装成功,并且路径配置正确。

有可能会出现:
java 代码

    memcached: error while loading shared libraries: libevent-1.3c.so.1: cannot open shared object file: No such file or directory 

说明 没有找到文件:libevent-1.3c.so.1

解决办法:

第一步. 查看下lib路径:
java 代码

    LD_DEBUG=libs /home/mahaibo/installmemcache/bin/memcached -v 

结果为:
java 代码

       27515:     find library=libevent-1.3c.so.1 [0]; searching  
         27515:      search path=tls/i686/sse2:tls/i686:tls/sse2:tls:i686/sse2:i686:sse2::/usr/local/lib/tls/i686/sse2:/usr/local/lib/tls/i686:/usr/local/lib/tls/sse2:/usr/local/lib/tls:/usr/local/lib/i686/sse2:/usr/local/lib/i686:/usr/local/lib/sse2:/usr/local/lib:/usr/local/BerkeleyDB.4.3/lib/tls/i686/sse2:/usr/local/BerkeleyDB.4.3/lib/tls/i686:/usr/local/BerkeleyDB.4.3/lib/tls/sse2:/usr/local/BerkeleyDB.4.3/lib/tls:/usr/local/BerkeleyDB.4.3/lib/i686/sse2:/usr/local/BerkeleyDB.4.3/lib/i686:/usr/local/BerkeleyDB.4.3/lib/sse2:/usr/local/BerkeleyDB.4.3/lib:/opt/Ice-3.1/lib/tls/i686/sse2:/opt/Ice-3.1/lib/tls/i686:/opt/Ice-3.1/lib/tls/sse2:/opt/Ice-3.1/lib/tls:/opt/Ice-3.1/lib/i686/sse2:/opt/Ice-3.1/lib/i686:/opt/Ice-3.1/lib/sse2:/opt/Ice-3.1/lib               (LD_LIBRARY_PATH)  
         27515:       trying file=tls/i686/sse2/libevent-1.3c.so.1 
         27515:       trying file=tls/i686/libevent-1.3c.so.1 
         27515:       trying file=tls/sse2/libevent-1.3c.so.1 
         27515:       trying file=tls/libevent-1.3c.so.1 
         27515:       trying file=i686/sse2/libevent-1.3c.so.1 
         27515:       trying file=i686/libevent-1.3c.so.1 
         27515:       trying file=sse2/libevent-1.3c.so.1 
         27515:       trying file=libevent-1.3c.so.1 
         27515:       trying file=/usr/local/lib/tls/i686/sse2/libevent-1.3c.so.1 
         27515:       trying file=/usr/local/lib/tls/i686/libevent-1.3c.so.1 
         27515:       trying file=/usr/local/lib/tls/sse2/libevent-1.3c.so.1 
         27515:       trying file=/usr/local/lib/tls/libevent-1.3c.so.1 
         27515:       trying file=/usr/local/lib/i686/sse2/libevent-1.3c.so.1 
         27515:       trying file=/usr/local/lib/i686/libevent-1.3c.so.1 
         27515:       trying file=/usr/local/lib/sse2/libevent-1.3c.so.1 
         27515:       trying file=/usr/local/lib/libevent-1.3c.so.1 
         27515:       trying file=/usr/local/BerkeleyDB.4.3/lib/tls/i686/sse2/libevent-1.3c.so.1 
         27515:       trying file=/usr/local/BerkeleyDB.4.3/lib/tls/i686/libevent-1.3c.so.1 
         27515:       trying file=/usr/local/BerkeleyDB.4.3/lib/tls/sse2/libevent-1.3c.so.1 
         27515:       trying file=/usr/local/BerkeleyDB.4.3/lib/tls/libevent-1.3c.so.1 
         27515:       trying file=/usr/local/BerkeleyDB.4.3/lib/i686/sse2/libevent-1.3c.so.1 
         27515:       trying file=/usr/local/BerkeleyDB.4.3/lib/i686/libevent-1.3c.so.1 
         27515:       trying file=/usr/local/BerkeleyDB.4.3/lib/sse2/libevent-1.3c.so.1 
         27515:       trying file=/usr/local/BerkeleyDB.4.3/lib/libevent-1.3c.so.1 
         27515:       trying file=/opt/Ice-3.1/lib/tls/i686/sse2/libevent-1.3c.so.1 
         27515:       trying file=/opt/Ice-3.1/lib/tls/i686/libevent-1.3c.so.1 
         27515:       trying file=/opt/Ice-3.1/lib/tls/sse2/libevent-1.3c.so.1 
         27515:       trying file=/opt/Ice-3.1/lib/tls/libevent-1.3c.so.1 
         27515:       trying file=/opt/Ice-3.1/lib/i686/sse2/libevent-1.3c.so.1 
         27515:       trying file=/opt/Ice-3.1/lib/i686/libevent-1.3c.so.1 
         27515:       trying file=/opt/Ice-3.1/lib/sse2/libevent-1.3c.so.1 
         27515:       trying file=/opt/Ice-3.1/lib/libevent-1.3c.so.1 
         27515:      search path=/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)  
         27515:       trying file=/usr/lib/tls/i686/sse2/libevent-1.3c.so.1 
         27515:       trying file=/usr/lib/tls/i686/libevent-1.3c.so.1 
         27515:       trying file=/usr/lib/tls/sse2/libevent-1.3c.so.1 
         27515:       trying file=/usr/lib/tls/libevent-1.3c.so.1 
         27515:       trying file=/usr/lib/i686/sse2/libevent-1.3c.so.1 
         27515:       trying file=/usr/lib/i686/libevent-1.3c.so.1 
         27515:       trying file=/usr/lib/sse2/libevent-1.3c.so.1 
         27515:       trying file=/usr/lib/libevent-1.3c.so.1 
         27515:      search cache=/etc/ld.so.cache  
         27515:      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:/usr/lib/tls:/usr/lib/sse2:/usr/lib          (system search path)  
         27515:       trying file=/lib/tls/i686/sse2/libevent-1.3c.so.1 
         27515:       trying file=/lib/tls/i686/libevent-1.3c.so.1 
         27515:       trying file=/lib/tls/sse2/libevent-1.3c.so.1 
         27515:       trying file=/lib/tls/libevent-1.3c.so.1 
         27515:       trying file=/lib/i686/sse2/libevent-1.3c.so.1 
         27515:       trying file=/lib/i686/libevent-1.3c.so.1 
         27515:       trying file=/lib/sse2/libevent-1.3c.so.1 
         27515:       trying file=/lib/libevent-1.3c.so.1 
         27515:       trying file=/usr/lib/tls/i686/libevent-1.3c.so.1 
         27515:       trying file=/usr/lib/tls/libevent-1.3c.so.1 
         27515:       trying file=/usr/lib/sse2/libevent-1.3c.so.1 
         27515:       trying file=/usr/lib/libevent-1.3c.so.1 
         27515:  
    /home/mahaibo/installmemcache/bin/memcached: error while loading shared libraries: libevent-1.3c.so.1: cannot open shared object file: No such file or directory 

第二步. 将libevent-1.3c.so.1拷贝到任何一个列出的lib 下就可以了。

或者 软链接
java 代码

    ln -s /Data/libevent/lib/libevent-1.3b.so.1 /usr/lib/libevent-1.3c.so.1 

或者 修改vi  /etc/profile文件。
java 代码

    export LIBRARY_PATH=:/usr/local/lib:"/usr/local/BerkeleyDB.4.3/lib":/usr/local/lib:/opt/Ice-3.1/lib:/usr/lib:/home/mahaibo/install/lib  



启动服务 :
java 代码



    ./memcached -d -m 10    -u root -l 192.168.40.4 -p 12000 -c 256 -P /tmp/memcached.pid 



参数说明:

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

广告服务联系QQ:1134687142 | 网站地图

版权所有: IT货架- 内容来自互联网,仅供用于技术学习,请遵循相关法律法规. 京ICP备11030978号-1