memcache安装

一.  Linux下memcached安装说明
 1.安装libevent-1.1a.tar

  # tar zxvf libevent-1.1a
  # cd libevent-1.1a
  #./configure --prefix=/usr/ali/libevent/ 
  # make
  # make install
  # make clean

 2. 安装memcached-1.2.4.tar.gz

  # tar zxvf memcached-1.2.4.tar.gz
  # cd memcached-1.2.4
  #./configure --prefix=/usr/ali/memcached/ --with-libevent=/usr/ali/libevent/ 
  # make
  # make install
  # make clean

  注意:若 libevent 不是安装在默认位置必须在 /usr/lib 下建立一个软连接,否则 memcached 会无法运行

  #ln -s /usr/ali/libevent/lib/libevent-1.1a.so.1 /usr/lib
  #ln -s /usr/ali/libevent/lib/libevent.so  /usr/lib

 3.启动memcached

  # memcached -d -p port -u admin
  比如:
  # memcached -d -p 11211 -u admin

 4.关闭memcached

二.  Window下安装安装说明
  下载memcache的windows稳定版,解压缩放某个盘下面,比如在c:memcached
  在终端(也即cmd命令界面)下输入  c:memcachedmemcached.exe -d install  安装
  再输入: c:memcachedmemcached.exe -d start 启动。NOTE: 以后memcached将作为windows的一个服务每次开机时自动启动。这样服务器端已经安装完毕了。
  Memcached 默认监听端口: 11211

三.  对应命令参数说明

 memcached的基本设置:

 -p 监听的端口
 -l 连接的IP地址, 默认是本机
 -d start 启动memcached服务
 -d restart 重起memcached服务
 -d stop|shutdown 关闭正在运行的memcached服务
 -d install 安装memcached服务
 -d uninstall 卸载memcached服务
 -u 以的身份运行 (仅在以root运行的时候有效)
 -m 最大内存使用,单位MB。默认64MB
 -M 内存耗尽时返回错误,而不是删除项
 -c 最大同时连接数,默认是1024
 -f 块大小增长因子,默认是1.25
 -n 最小分配空间,key+value+flags默认是48
 -h 显示帮助

四.  控制脚本

Java代码  收藏代码
  1. #!/bin/bash  
  2.   
  3. MYDATE=`date +%Y-%m-%d`  
  4. MEM_PORT_LIST='11211 11212 11213 11214 11215 11216'  
  5.   
  6. clear  
  7. echo -e "   33[40;33m"  
  8. cat <<eof  
  9.                           memcached控制脚本,请谨慎操作  
  10.            ----------------------------------------------------------------------------------------------------------  
  11.                     User:$USER     Select the choice you want to synchronize      Date:$MYDATE  
  12.            ----------------------------------------------------------------------------------------------------------  
  13.                       1) start memcached [$MEM_PORT_LIST]    
  14.                       2) shutdown memcached [$MEM_PORT_LIST]    
  15.            ----------------------------------------------------------------------------------------------------------  
  16. eof  
  17. echo -e "   33[40;33m"  
  18. echo -n "Selection:"  
  19. read letter  
  20.  #echo "Rsync data to ....."  
  21. case $letter  in  
  22.   1)  
  23.     clear  
  24.     echo -e "   33[40;32m  ------------------------ 33[40;37m"  
  25.     echo "start memcached [$MEM_PORT_LIST] "  
  26.     for DEST_PORT  in $MEM_PORT_LIST  
  27.       do  
  28.       echo -e "   33[40;32m  $DEST_PORT is begin startup ------------------------- 33[40;37m"  
  29.       /usr/ali/memcached/bin/memcached -d -p $DEST_PORT -u admin  
  30.       echo -e "   33[40;32m  $DEST_PORT is end   shutup -------------------------  33[40;37m"     
  31.       done  
  32.     exit 0  
  33.     ;;  
  34.   2)  
  35.     clear  
  36.     echo -e "   33[40;32m  ------------------------ 33[40;37m"  
  37.     echo "shutdown memcached [$MEM_PORT_LIST] "  
  38.     killall -9 memcached ;    
  39.     exit 0  
  40.     ;;  
  41.    *)  
  42.     echo "Bad select,exit" >&2  
  43.     exit 1  
  44.     ;;  
  45. esac  
原文地址:https://www.cnblogs.com/lijc1990/p/3547926.html