我无法通过初始化脚本关闭我的 redis 服务器。当我这样做时,这会产生巨大的副作用,即挂起我的机器sudo reboot
。
我使用规范指南新安装了 redis ,将其配置为接受 unix 套接字上的连接,现在正尝试停止服务器,以便我可以恢复以前保存的 .rdb 转储。
但我不断收到以下信息:
Could not connect to Redis at 127.0.0.1:0: Connection refused
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 ...
Waiting for Redis to shutdown ...
我使用的命令是sudo /etc/init.d/redis-server stop
. 请注意,shutdown
连接到 后我仍然可以发出问题redis-cli -s /var/run/redis.sock
,但我需要初始化脚本才能工作。
为什么redis不会关闭,我该如何解决这种情况?版本是Redis server v=4.0.2 sha=00000000:0 malloc=jemalloc-4.0.3 bits=64 build=8ddba2e6a24ce078
我很自然地port 0
在配置文件中设置了unixsocket /var/run/redis.sock
和unixsocketperm 755
.
此外,脚本文件的内容是:
!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
REDISPORT=0
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis.pid
CONF="/etc/redis/redis.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 -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac
注意REDISPORT=0
,应该如此。目前,这并不真正支持停止和启动 redis 服务器。