CentOs6.x安裝memcached-1.5.x
阿新 • • 發佈:2017-12-04
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 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