系统环境:

[root@memcached ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)
[root@memcached ~]#  uname -a
Linux memcached 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@memcached ~]# lsb_release -a
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 6.5 (Final)
Release:    6.5
Codename:   Final

开始安装:

[root@memcached ~]# yum -y install libevent-devel
[root@memcached ~]# mkdir soft
[root@memcached ~]# cd soft
[root@memcached soft]# wget http://www.memcached.org/files/memcached-1.4.17.tar.gz
[root@memcached soft]# cd memcached-1.4.17
[root@memcached memcached-1.4.17]# ./configure --prefix=/usr/local/memcached
[root@memcached memcached-1.4.17]# make -j2 && make install
[root@memcached memcached-1.4.17]# cd /usr/local/memcached/bin/
[root@memcached bin]# ./memcached -d -u root -m 1024  -p 11211 -c 500
[root@memcached bin]# netstat -tulnpan|grep memcached
tcp        0      0 0.0.0.0:11211               0.0.0.0:*                   LISTEN      5797/./memcached   
tcp        0      0 :::11211                    :::*                        LISTEN      5797/./memcached   
udp        0      0 0.0.0.0:11211               0.0.0.0:*                               5797/./memcached   
udp        0      0 :::11211                    :::*                                    5797/./memcached 
[root@memcached bin]# vim /etc/init.d/memcached
[root@memcached bin]# chmod +x /etc/init.d/memcached
#!/bin/bash
# chkconfig: 2345 96 14
# description: shell init script for Linux.
# created by nowsafe
. /etc/init.d/functions
source /etc/bashrc
source /etc/profile
start() {
    /usr/local/memcached/bin/memcached -d -u root -m 1024  -p 11211 -c 500 >> /dev/null
    echo "start"
}
stop() {
    killall memcached >> /dev/null
    echo "stop"
}
case "$1" in
  start)
    start
        ;;
  stop)
    stop
        ;;
  restart)
    stop
    start
        ;;
  version)
        exec  $1
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|version}"
        exit 1
esac
[root@memcached bin]# netstat -tulnpan |grep mem
tcp        0      0 0.0.0.0:11211               0.0.0.0:*                   LISTEN      5892/memcached     
tcp        0      0 :::11211                    :::*                        LISTEN      5892/memcached     
udp        0      0 0.0.0.0:11211               0.0.0.0:*                               5892/memcached     
udp        0      0 :::11211                    :::*                                    5892/memcached     
[root@memcached bin]# /etc/init.d/memcached stop
Terminated
[root@memcached bin]# netstat -tulnpan |grep mem
[root@memcached bin]#
[root@memcached bin]# chkconfig memcached on