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"memcached

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

#設置啓動服務
一、chmod 755 /etc/init.d/memcached #增長執行權限
二、chkconfig --add memcached #添加memcached到服務項
三、chkconfig --level 2345 memcached on #設置開機啓動
四、chkconfig --list memcached #查看是否設置成功
#服務管理命令
一、service memcached start # 啓動memcached
二、service memcached stop # 關閉memcached
三、service memcached restart # 重啓memcachedrest

相關文章
相關標籤/搜索