首页 > 系统服务 > 详细

CentOs6.x安装memcached-1.5.x

时间:2017-12-04 18:54:13      阅读:276      评论:0      收藏:0      [点我收藏+]
一、系统及安装说明

      系统: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 0

2>解释说明

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


CentOs6.x安装memcached-1.5.x

原文:http://blog.51cto.com/shhlamp/2047304

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!