我在ubuntu中安装了memcached,我想在系统启动时将memcache设置为自动启动,但是我出错了! 我在/etc/init.d/中创建了一个名为memcached的shell脚本,这是我的代码:
#! /bin/sh
#
# processname: memcached
# config: /etc/sysconfig/memcached
# Source function library - for other linux
#. /etc/rc.d/init.d/functions
# Source function library - for suse linux
#load the public function used by all shell scripts
. /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
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 $?
然后我在执行
时向该文件添加执行权限chkconfig --add memcached
问题出现了,它说:
insserv: warning: script 'K20acpi-support' missing LSB tags and overrides
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'plymouth-stop' missing LSB tags and overrides
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'rsyslog' missing LSB tags and overrides
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'network-manager' missing LSB tags and overrides
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
.......
/sbin/insserv failed, exit code 1
memcached 0:off 1:off 2:off 3:off 4:off 5:off 6:off
答案 0 :(得分:0)
问题是chkconfig
更像是一个Redhat-ism,你可以在Ubuntu上安装(看起来像你有)。但是,看起来这里的许多依赖项(即启动脚本)都已从此迁移到Upstart上,因此使用此系统最多也是困难的。
对于Ubuntu,您可能需要create an upstart script。请注意,最近Ubuntu将来会decided移至systemd。
或者,请查看更加友好的Ubuntu sysv-rc-conf
(有关详情,请参阅this Askubuntu post)。