重启宝塔redis启动失败,pid file is exits

重启宝塔redis启动失败

查看状态:


[root@localhost ~]# service redis status
Redis is not running, buy pid file is exits /www/server/redis/redis.pid
[root@localhost ~]# 

原因:

我的宝塔是装在vmware里,win10重启,vm里的虚拟机直接关机,redis 没有正常关闭,redis.pid文件残留。

解决办法:

[root@localhost redis]# vi /etc/init.d/redis 

搜索【Redis is not running, buy pid file is exits】
大概在38行


     34 redis_start(){
     35         if [ -f "/www/server/redis/redis.pid" ]; then
     36                 ps -p $(cat ${PIDFILE}) > /dev/null 2>&1
     37                 if [ $? -ne "0" ]; then
     38                         echo Redis is not running, buy pid file is exits ${PIDFILE}
     39   
     40                         exit 1
     41                 else
     42                         echo "redis is running! ($(cat ${PIDFILE}))"
     43                         exit 0
     44                 fi
     45         fi
     46         echo "Starting redis server..."
     47         sudo -u redis $EXEC $CONF
     48         echo ${REDIS_PORT} > /www/server/redis/start.pl
     49         echo "Starting redis success!"
     50 }

在39行加入(exit 1之前 )


   rm -rf /www/server/redis/redis.pid &&  service  redis restart &&   service redis status

然后reboot查看效果

你可能感兴趣的:(linux,linux)