1、安裝gcc
# yum -y install gcc
2、安裝libevent
# wget http://www.monkey.org/~provos/libevent-2.0.12-stable.tar.gz
# tar zxf libevent-2.0.12-stable.tar.gz
# cd libevent-2.0.12-stable
#./configure --prefix=/usr/local/lib
# make && make install
3、下載安裝最新版本:http://memcached.org/downloads
# wget http://memcached.org/files/memcached-1.4.20.tar.gzphp
#tar zxvf memcached-1.4.20.tar.gzhtml
# cd memcached-1.4.20memcached
#./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/lib && make && make installpost
4、配置啓動測試
# vi /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
/usr/sbin/ntpdate ntpupdate.tencentyun.com >/dev/null 2>&1 &
/usr/local/agenttools/agent/startagent.sh /usr/local/agenttools/agent /dev/null
#secu-tcs-agent bootstart, install at Tue Apr 29 17:21:38 CST 2014.
/usr/local/sa/agent/secu-tcs-agent-mon-safe.sh > /dev/null 2>&1
/usr/local/memcached/bin/memcached -p 12677 -U 0 -d -r -u root -m 2040 -c 1024 -t 4ui
保存後退出,手動啓動服務url
# /usr/local/memcached/bin/memcached -p 12677 -U 0 -d -r -u root -m 2040 -c 1024 -t 4
注:若是出現/usr/local/memcached/bin/memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory異常在/etc/ld.so.conf中加入/usr/local/lib這一行,保存以後,再運行:/sbin/ldconfig –v更新一下配置便可。htm
# vi /etc/ld.so.confblog
# /sbin/ldconfig -Vip
5、測試memcached
# telnet 127.0.0.1 12677
出現如下信息表示啓動成功Trying 127.0.0.1...Connected to 127.0.0.1.Escape character is '^]'.(退出telnet的方法是:quit+回車)