昨天下午刚到公司,开发告诉我有个页面打不开。后面经过排查排除代码的问题,开始怀疑是不是redis出问题了,后面尝试着重启了一下redis,结果问题解决了。当时因为redis没有配日志文件,所以。。。
等到今天早上又出现同样的问题了,不过依然没有日志,所以后面我在服务器里配置了日志,然后就不停对坐在我对面的开发说:马丹,服务器怎么还不出问题......
刚刚(2017-01-12 16:42)终于又出现这个问题了,我本着无比鸡冻的眼神看了眼日志
13718:M 12 Jan 14:21:30.150 # Background saving error
13718:M 12 Jan 14:21:36.064 * 1 changes in 900 seconds. Saving...
13718:M 12 Jan 14:21:36.064 * Background saving started by pid 18396
18396:C 12 Jan 14:21:36.065 # Failed opening .rdb for saving: Permission denied
13718:M 12 Jan 14:21:36.165 # Background saving error
13718:M 12 Jan 14:21:42.078 * 1 changes in 900 seconds. Saving...
13718:M 12 Jan 14:21:42.079 * Background saving started by pid 18398
18398:C 12 Jan 14:21:42.079 # Failed opening .rdb for saving: Permission denied
13718:M 12 Jan 14:21:42.179 # Background saving error
13718:M 12 Jan 14:21:48.092 * 1 changes in 900 seconds. Saving...
13718:M 12 Jan 14:21:48.093 * Background saving started by pid 18399
18399:C 12 Jan 14:21:48.093 # Failed opening .rdb for saving: Permission denied
13718:M 12 Jan 14:21:48.194 # Background saving error
13718:M 12 Jan 14:21:54.006 * 1 changes in 900 seconds. Saving...
13718:M 12 Jan 14:21:54.007 * Background saving started by pid 18400
18400:C 12 Jan 14:21:54.007 # Failed opening .rdb for saving: Permission denied
满屏尽是permission denied。
我的猜想:.rdb是数据文件,说明数据文件没有写入权限。但是很奇怪我在redis目录下没有找到.rdb文件。然后我用find在全局查找一次。
[root@iZ2zeib1msf1e5n3hae56mZ ~]# find / -name *.rdb
/tmp/dump.rdb
/root/dump.rdb
/root/.ssh/dump.rdb
这里是不是应该有个疑问?为什么redis的数据目录不在redis目录下面呢?于是上网百度,发现百度上面说的方法都治不了我的痛,着实不靠谱,也就没有测试。
后来发现个问题,配置文件下
[root@iZ2zeib1msf1e5n3hae56mZ redis-3.0.7]# sed -n '192p' redis.conf
dir ./
情况一:
[root@test ~]# redis-server /data/redis-3.0.7/redis.conf &
[root@test ~]# ls
conf.n dump.rdb http:
情况二:
[root@iZ2zeib1msf1e5n3hae56mZ redis-3.0.7]# ./src/redis-server /data/redis-3.0.7/redis.conf &
[root@iZ2zeib1msf1e5n3hae56mZ redis-3.0.7]# ls
00-RELEASENOTES BUGS COPYING dump.rdb Makefile README redis.log runtest-cluster sentinel.conf tests
bin CONTRIBUTING deps INSTALL MANIFESTO redis.conf runtest runtest-sentinel src utils
发现有什么问题了吧?哈哈哈哈