1、错误现象:
在redis客户端中进行保存操作,显示失败:
127.0.0.1:6379> save
(error) ERR
使用kill命令关闭redis服务后,查看进程,redis服务进程仍然存在:
pi@raspberrypi /proc/3176 $ ps aux|grep redis
pi 3176 2.1 0.3 39880 3676 ? Ssl 16:10 0:50 /usr/local/bin/redis-server 0.0.0.0:6379
pi 4586 0.0 0.1 5728 1668 pts/1 S+ 16:49 0:00 grep --color=auto redis
pi@raspberrypi /proc/3176 $ sudo kill 3176
pi@raspberrypi /proc/3176 $ ps aux|grep redis
pi 3176 2.1 0.3 39880 3676 ? Ssl 16:10 0:50 /usr/local/bin/redis-server 0.0.0.0:6379
pi 4592 0.0 0.1 5728 1780 pts/1 S+ 16:49 0:00 grep --color=auto redis
2、日志分析:
在redis客户端中进行保存操作,显示失败:
127.0.0.1:6379> save
(error) ERR
使用kill命令关闭redis服务后,查看进程,redis服务进程仍然存在:
pi@raspberrypi /proc/3176 $ ps aux|grep redis
pi 3176 2.1 0.3 39880 3676 ? Ssl 16:10 0:50 /usr/local/bin/redis-server 0.0.0.0:6379
pi 4586 0.0 0.1 5728 1668 pts/1 S+ 16:49 0:00 grep --color=auto redis
pi@raspberrypi /proc/3176 $ sudo kill 3176
pi@raspberrypi /proc/3176 $ ps aux|grep redis
pi 3176 2.1 0.3 39880 3676 ? Ssl 16:10 0:50 /usr/local/bin/redis-server 0.0.0.0:6379
pi 4592 0.0 0.1 5728 1780 pts/1 S+ 16:49 0:00 grep --color=auto redis
3、解决方法
这里将该目录其他用户权限改为具有读、写、执行的权限:
pi@raspberrypi /var/lib/redis $ sudo chmod 757 6379
终止redis进程,然后重启redis-server,发现save操作和服务关闭,都可以了。
(1)终止redis进程:
pi@raspberrypi /var/lib/redis/6379 $ ps aux|grep redis
pi 12281 1.5 0.4 35788 3988 pts/4 Sl+ 04:59 0:05 redis-server *:6379
pi 12388 0.0 0.1 5728 1668 pts/0 S+ 05:06 0:00 grep --color=auto redis
pi@raspberrypi /var/lib/redis/6379 $ kill -9 12281
(2)redis保存操作:
127.0.0.1:6379> save
OK
(3)redis服务关闭:
12412:signal-handler (1497763338) Received SIGTERM scheduling shutdown...
12412:M 18 Jun 05:22:18.723 # User requested shutdown...
12412:M 18 Jun 05:22:18.723 * Saving the final RDB snapshot before exiting.
12412:M 18 Jun 05:22:18.750 * DB saved on disk
12412:M 18 Jun 05:22:18.751 # Redis is now ready to exit, bye bye...