您的位置:首页 > 数据库 > Memcache

centos6.4下安装memcached

2014-04-28 15:02 399 查看
首先安装libevent:

wget http://monkey.org/~provos/libevent-1.4.14b-stable.tar.gz tar zxvf libevent-1.4.14b-stable.tar.gz
cd libevent-1.4.14b-stable
./configure --prefix=/usr/local/libevent/
make && make install
ln -s /usr/local/libevent/lib/libevent-1.4.so.2 /lib/libevent-1.4.so.2


然后安装memcached

wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz tar zxvf memcached-1.4.15.tar.gz
cd memcached-1.4.15
./configure --prefix=/usr/local/memcached/ --with-libevent=/usr/local/libevent/
make && make install


启动memcached命令

/usr/local/memcached/bin/memcached -d -m 64 -u root -l 127.0.0.100 -p 11211 -c 128 -P /tmp/memcached.pid


也可使用服务器脚本:vim
/etc/rc.d/init.d/memcached

#!/bin/sh
#
# memcached:    MemCached Daemon
#
# chkconfig:    - 90 25
# description:  MemCached Daemon
#
# Source function library.
. /etc/rc.d/init.d/functions
. /etc/sysconfig/network
#[ ${NETWORKING} = "no" ] && exit 0
#[ -r /etc/sysconfig/dund ] || exit 0
#. /etc/sysconfig/dund
#[ -z "$DUNDARGS" ] && exit 0
start()
{
echo -n $"Starting memcached: "
daemon $MEMCACHED -u daemon -d -m 64 -l 127.0.0.100 -p 11211 -c 128 -P /tmp/memcached.pid
echo
}
stop()
{
echo -n $"Shutting down memcached: "
killproc memcached
echo
}
MEMCACHED="/usr/local/memcached/bin/memcached"
[ -f $MEMCACHED ] || exit 1
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 3
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0


添加开机启动:

cd /etc/rc.d/init.d/
chmod 777 memcached
chkconfig --add memcached
chkconfig --level 235 memcached on
chkconfig --list | grep memcached


[root@blog.phpha.com] service memcached start
[root@blog.phpha.com] service memcached stop
[root@blog.phpha.com] service memcached restart
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: