memcached自启动

#
# 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

MEMCACHED="/usr/local/memcached/bin/memcached"
SERVER_IP="172.16.26.4"
SERVER_PORT="11211"

[ -f $MEMCACHED ] || exit 1

start()
{
echo -n $"Starting memcached: "
daemon $MEMCACHED -u root -d -m 1024 -l $SERVER_IP -p $SERVER_PORT -P /tmp/memcached.pid
echo
}
stop()
{
echo -n $"Shutting down memcached: "
killproc memcached
echo
}

# 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

#设置启动服务
1、chmod 755 /etc/init.d/memcached #增加执行权限
2、chkconfig --add memcached #添加memcached到服务项
3、chkconfig --level 2345 memcached on #设置开机启动
4、chkconfig --list memcached #查看是否设置成功
#服务管理命令
1、service memcached start # 启动memcached
2、service memcached stop # 关闭memcached
3、service memcached restart # 重启memcached

posted @ 2017-01-22 13:43  humor1314  阅读(125)  评论(0编辑  收藏