Redis服务停止报错解决方案[NOAUTH Authentication required]
Redis服务器设置密码后,使用service redis stop 会出现以下信息:# serviceredis stop
Stopping ...
(error) NOAUTH Authentication required.
Waiting for Redis to shutdown ...
Waiting for Redis to shutdown ...
Waiting for Redis to shutdown ...
Waiting for Redis to shutdown ...
Waiting for Redis to shutdown ...
Waiting for Redis to shutdown ...
出现这样的错误信息,redis 这时是没有停止服务的。
可以使用ps -ef | grep redis查进程号 然后kill 掉,如果在deamon下还需要去删除pid文件,有点繁琐。
解决办法:
修改redis服务脚本,加入如下所示的红色授权信息即可:
vi /etc/init.d/redis
$CLIEXEC -a "youpassword" -p $REDISPORT shutdown
或是自己添加个密码变量,直接引用如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
vi /etc/init.d/redis
#!/bin/sh
# chkconfig: 2345 80 90
#
# Simple Redis init.d script conceived towork on Linux systems
# as it does use of the /proc filesystem.
REDISPORT=6389
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
RESDISPASSWORD=red29
PIDFILE=/var/run/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 Redisserver..."
$EXEC $CONF &
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does notexist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -a $RESDISPASSWORD -p$REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting forRedis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac
页:
[1]