问题描述
我的/etc/init.d/redis 脚本可以正常启动或者停止redis服务
service redis startservice redis stopservice redis restart
我也设置了/etc/init.d/redis权限为755也设置了开机启动chkconfig redis on
chkconfig --list如下:
redis 0:关 1:关 2:开 3:开 4:开 5:开 6:关
请问为什么不能开机启动呢?求解决办法
附:/etc/init.d/redis代码如下:
# chkconfig: 2345 10 90#!/bin/sh## Simple Redis init.d script conceived to work on Linux systems# as it does use of the /proc filesystem.REDISPORT=6379EXEC=/usr/local/bin/redis-serverCLIEXEC=/usr/local/bin/redis-cliPIDFILE=/var/run/redis_${REDISPORT}.pidCONF='/usr/local/redis/redis.conf'AUTH='111111'# CONF='/etc/redis/${REDISPORT}.conf'case '$1' in start)if [ -f $PIDFILE ]thenecho '$PIDFILE exists, process is already running or crashed'elseecho 'Starting Redis server...'$EXEC $CONFfi;; stop)if [ ! -f $PIDFILE ]thenecho '$PIDFILE does not exist, process is not running'elsePID=$(cat $PIDFILE)echo 'Stopping ...'$CLIEXEC -p $REDISPORT -a $AUTH shutdownwhile [ -x /proc/${PID} ]do echo 'Waiting for Redis to shutdown ...' sleep 1doneecho 'Redis stopped'fi;; restart|force-reload)${0} stop${0} start;; *)echo 'Please use start or stop as first argument';;esac
问题解答
回答1:自己参考php-fpm提供的启动文件,加了这么句话搞定了,什么原理不知道
### BEGIN INIT INFO# Provides: redis# Required-Start: $remote_fs $network# Required-Stop: $remote_fs $network# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Short-Description: starts redis# Description: starts the redis FastCGI Process Manager daemon### END INIT INFO回答2:
看看日志,有可能是报错了
回答3:要是不行,你就在/etc/rc.local里面的exit之前加一句:sudo service redis-server start。