标签:memcached linux安装memcached memcache
一、系统及安装说明系统:CentOS6.x_x64,memcached-1.5.3。memcached官方下载地址 http://www.memcached.org/files/memcached-1.5.3.tar.gz。libevent 库:https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
二、开始安装
1>首先yum安装gcc
yum install -y wget gcc
2>安装源码libevent库
#wget #tar zxvf libevent-2.0.21-stable.tar.gz #./configure --prefix=/usr/local/libevent #make && make install
3>下载安装memcached
#wget #tar -zxvf memcached-1.5.3.tar.gz #./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent #make && make install #ln -s /usr/local/memcached/bin/memcached /usr/local/bin #建立软连接
三、编辑脚本加入启动项
1>脚本
#!/bin/sh
#
# memcached: MemCached Daemon
#
# chkconfig: - 90 25
# description: MemCached Daemon
# Source function library.
# Author: pkey san 2015/12/07
. /etc/rc.d/init.d/functions
. /etc/sysconfig/network
prog=memcached
pidfile=${PIDFILE-/var/run/memcached.pid}
start()
{
echo -n $"Starting memcached: "
daemon --pidfile=${pidfile} /usr/local/bin/memcached -u daemon -d -m 512 -l 127.0.0.1 -c 4096 -p 11211
echo `ps aux |grep memcached |grep 11211 |grep -v grep |awk '{print $2}'` >$pidfile
echo
}
stop()
{
echo -n $"Shutting down memcached: "
killproc $prog
echo
}
rh_status(){
status -p ${pidfile} $prog
}
[ -f /usr/local/bin/memcached ] || exit 0
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
rh_status
;;
restart|reload)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|}"
exit 1
esac
exit 02>解释说明
daemon --pidfile=${pidfile} /usr/local/bin/memcached -u daemon -d -m 512 -l 127.0.0.1 -c 4096 -p 11211
-m:指定memcache缓存内存大小
-l:指定memcache的侦听地址一般内网
-c: 最大并发连接数。
-p:侦听端口
3>添加开机启动
#chmod +x /etc/init.d/memcached #chkconfig --add memcached #chkconfig memcached on #service memcached start|stop|restart|reload|status
标签:memcached linux安装memcached memcache
原文地址:http://blog.51cto.com/shhlamp/2047304