Linux因Redis服务导致关机慢

Redis服务配置了密码,导致关机慢,出现以下提示:

A stop job is running for ... key-value database

原因是关闭Redis服务时需要密码验证。

解决办法:

修改Redis启动脚本,sudo vim /etc/init.d/redisd

 1 case "$1" in
 2     start)
 3         if [ -f $PIDFILE ]
 4         then
 5                 echo "$PIDFILE exists, process is already running or crashed"
 6         else
 7                 echo "Starting Redis server..."
 8                 $EXEC $CONF
 9         fi
10         ;;
11     stop)
12         if [ ! -f $PIDFILE ]
13         then
14                 echo "$PIDFILE does not exist, process is not running"
15         else
16                 PID=$(cat $PIDFILE)
17                 echo "Stopping ..."
18                 $CLIEXEC -p $REDISPORT -a 123456 shutdown
19                 while [ -x /proc/${PID} ]
20                 do
21                     echo "Waiting for Redis to shutdown ..."
22                     sleep 1
23                 done
24                 echo "Redis stopped"
25         fi
26         ;;
27     *)
28         echo "Please use start or stop as first argument"
29         ;;
30 esac

第18行添加红字的部分,配置上密码即可。

posted @ 2019-03-13 14:56  空の彼方  阅读(1271)  评论(1编辑  收藏  举报