按照网上教程些了启动脚本了,service redis start | stop 都没问题,
加了脚本权限
chmod +x /etc/init.d/redis
设置开机启动
sudo chkconfig redis on
这些步骤都做了还是不行
redis是4.x版本,求大神解救,谢过
开机启动日志:
Dec 26 20:05:02 localhost systemd: Failed at step EXEC spawning /etc/rc.d/init.d/redis: Exec format error
Dec 26 20:05:02 localhost systemd: redis.service: control process exited, code=exited status=203
Dec 26 20:05:02 localhost systemd: Failed to start SYSV: Redis is a persistent key-value database.
Dec 26 20:05:02 localhost systemd: Unit redis.service entered failed state.
Dec 26 20:05:02 localhost systemd: redis.service failed.
脚本:
# chkconfig: 2345 90 10
# description: Redis is a persistent key-value database
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
REDISPORT=6379
EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/usr/local/redis/bin/redis-cli
PIDFILE=/usr/local/redis/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -a 9999 shutdown
while [ -x ${PIDFILE} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
restart|force-reload)
${0} stop
${0} start
;;
*)
echo "Please use {start|stop|restart|force-reload} as first argument"
;;
esac