标签:
以下这段脚本:
#! /bin/sh # # chkconfig: - 55 45 # description: The memcached daemon is a network memory cache service. # processname: memcached # config: /etc/sysconfig/memcached # Source function library - for other linux #. /etc/rc.d/init.d/functions # Source function library - for suse linux . /lib/lsb/init-functions PORT=11211 USER=root #最大连接数,根据实际需求修改 MAXCONN=1024 #最大内存量,单位M CACHESIZE=128 OPTIONS=""
if [ -f /etc/sysconfig/memcached ];then . /etc/sysconfig/memcached fi # Check that networking is up. if [ "$NETWORKING" = "no" ] then exit 0 fi
RETVAL=0 prog="memcached" start () { echo -n $"Starting $prog: " # insure that /usr/local/memcached has proper permissions chown $USER /usr/local/memcached /usr/local/memcached/bin/memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P /usr/local/memcached/memcached.pid $OPTIONS RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached } stop () { echo -n $"Stopping $prog: " killproc memcached RETVAL=$? echo if [ $RETVAL -eq 0 ] ; then rm -f /var/lock/subsys/memcached rm -f /usr/local/memcached/memcached.pid fi } restart () { stop start } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status memcached ;; restart|reload) restart ;; condrestart) [ -f /var/lock/subsys/memcached ] && restart || : ;; *) echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}" exit 1 esac exit $?
将以上这段中的内容的中文部分去掉即可,只是用来在代码中做注释。memcached的位置改成您自己的对应位置
将这段代码编辑在 /etc/init.d/memcached文件里面
然后执行脚本:
# chmod 755 /etc/init.d/memcached # chkconfig --add memcached # chkconfig memcached on # service memcached start
以上如成功则重启下系统后查看下memcached是否已随系统启动
标签:
原文地址:http://www.cnblogs.com/bafeiyu/p/4499882.html