centos7上redis不能开机启动

白小衣 发布于 2017/12/26 20:09
阅读 3K+
收藏 0

按照网上教程些了启动脚本了,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
                                                        

 

加载中
1
l
lccsirrah

会不会是你脚本问题? #!/bin/sh 要放第一行吧。

大中华网吧首席管理员
大中华网吧首席管理员
估计就是这个
0
红薯
红薯
出什么错了,你好歹得说出来
白小衣
白小衣
回复 @红薯 : 错误贴出来了,再麻烦帮忙看下
红薯
红薯
你怎么设置开机启动的? 看看 /var/log/messages
白小衣
白小衣
帅大哥,开机启动服务的错哪里看哦
0
红薯
红薯

Exec format error  ,好像文件损坏?

0
binges
binges
centos7好像不是这么玩的
binges
binges
回复 @白小衣 : 1. 给开机启动文件添加执行权限 chmod +x /etc/rc.d/rc.local 2.把开机启动脚本添加到此文件中,比如 /etc/init.d/redis start
白小衣
白小衣
求详解
0
战场原礼亚
战场原礼亚

centos7用的是systemd吧

0
白小衣
白小衣

已放弃,systemctl 也不行

0
g
gdsq

这个问题解决了吗

返回顶部
顶部