•1、安装依赖包libevent yum -y install libevent •2、编译安装 tar xvf memcached-1.2.0.tar.gz cd memcached-1.2.0 ./configure --prefix=/usr/local/memcached make make install 参数 •p 监听的端口 •-c 最大同时连接数,默认是1024 •-m 最大内存使用,单位MB。默认64MB •-P 设置保存Memcache的pid文件 •-d 后台运行 •-u 运行Memcache的用户,仅在以root运行的时候有效 启动脚本: •#!/bin/bash •pid=`ps -ef|grep memcached|grep -v "grep"|awk '{print $2}'` •if [[ $pid ]] •then •echo "memcached is running..." •else •/usr/local/bin/memcached -d -m 10 -p 11211 -u root -c 256 -P /tmp/memcached.pid >> /tmp/memcached.log •echo 'memcached started pidfile path is /tmp/memcached.pid' •fi 停止脚本: •#!/bin/bash •pid=`cat /tmp/memcached.pid` •new_pid=`ps -ef|grep $pid|grep -v "grep"|awk '{print $2}'` •if [[ $new_pid ]] •then •kill -9 `cat /tmp/memcached.pid` •echo "memcached stoped..." •else •echo "memcached is not runing...." •fi