memcached安装

1、下载, memcached需要先安装libevent
   memcached的下载地址:http://danga.com/memcached/download.bml
   libevent的下载地址 :http://www.monkey.org/~provos/libevent/

2、安装libevent
  
Python代码 复制代码
  1. # tar xvf libevent-1.4.4-stable.tar.gz        
  2. # cd libevent-1.4.4-stable       
  3. # ./configure --prefix= /opt/cuix/3rdParty/libevent-1.4.4       
  4. # make       
  5. # make install   
    # tar xvf libevent-1.4.4-stable.tar.gz     
    # cd libevent-1.4.4-stable    
    # ./configure --prefix= /opt/cuix/3rdParty/libevent-1.4.4    
    # make    
    # make install
   


   检查是否安装成功:
  
Python代码 复制代码
  1. #cd /opt/cuix/3rdParty/libevent-1.4.4/lib   
    #cd /opt/cuix/3rdParty/libevent-1.4.4/lib
   


   如果有:
   libevent-1.4.so.2 
   libevent-1.4.so.2.0.0 
   libevent.a 
   libevent.la 
   libevent.so
   这几个文件存在,说明安装成功。

3、安装memcached
  
Python代码 复制代码
  1. #  tar xvf memcached-1.2.5.tar.gz        
  2. # cd memcached-1.2.5      
  3. # ./configure --with-libevent=/opt/cuix/3rdParty/libevent-1.4.4    
  4.              --prefix=/opt/cuix/3rdParty/memcached-1.2.5       
  5. # make       
  6. # make install   
    #  tar xvf memcached-1.2.5.tar.gz     
    # cd memcached-1.2.5   
    # ./configure --with-libevent=/opt/cuix/3rdParty/libevent-1.4.4 
                 --prefix=/opt/cuix/3rdParty/memcached-1.2.5    
    # make    
    # make install
   

  
   检查是否安装成功:
  
Python代码 复制代码
  1. # cd 3rdParty/memcached-1.2.5/bin   
    # cd 3rdParty/memcached-1.2.5/bin
   


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

4、执行
  
Python代码 复制代码
  1. # cd /opt/cuix/3rdParty/memcached-1.2.5/bin       
  2. # ./memcached -h    
    # cd /opt/cuix/3rdParty/memcached-1.2.5/bin    
    # ./memcached -h 
   

  
   如果出现:
  
引用

   memcached 1.2.5
   -p <num>      TCP port number to listen on (default: 11211)
   -U <num>      UDP port number to listen on (default: 0, off)
   -s <file>     unix socket path to listen on (disables network support)
   -a <mask>     access mask for unix socket, in octal (default 0700)
   -l <ip_addr>  interface to listen on, default is INDRR_ANY
   -d            run as a daemon
   -r            maximize core file limit
   -u <username> assume identity of <username> (only when run as root)
   -m <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>      max simultaneous connections, default is 1024
   -k            lock down all paged memory.  Note that there is a
                 limit on how much memory you may lock.  Trying to
                 allocate more than that would fail, so be sure you
                 set the limit correctly for the user you started
                 the daemon with (not for -u <username> user;
                 under sh this is done with 'ulimit -S -l NUM_KB').
   -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>     save PID in <file>, only used with -d option
   -f <factor>   chunk size growth factor, default 1.25
   -n <bytes>    minimum space allocated for key+value+flags, default 48
  

   说明安装成功,并且路径配置正确。
   有可能会出现:
  
引用

    memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory
  

   说明没有找到文件:libevent-1.4.so.2

   解决办法:
   将libevent-1.4.so.2拷贝到任何一个列出的lib下或者软链接就可以了。
   或者 修改.profile文件。加入:
  
Python代码 复制代码
  1. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/opt/cuix/3rdParty/libevent-1.4.4/lib    
     export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/opt/cuix/3rdParty/libevent-1.4.4/lib 
   

  
   启动服务:
  
Python代码 复制代码
  1. ./memcached -d -m 10 -u cuix -l 10.3.2.36 -p 18887 -c 256 -P /tmp/memcached.pid   
    ./memcached -d -m 10 -u cuix -l 10.3.2.36 -p 18887 -c 256 -P /tmp/memcached.pid
   

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

    停止服务:
    用# ps -e 查看进程,# kill pid memcached的进程号。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值