Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

33.9. FAQ

33.9.1. 清空数据库

FLUSHDB - Removes data from your connection's CURRENT database.
FLUSHALL - Removes data from ALL databases.
			

33.9.2. (error) MISCONF Redis is configured to save RDB snapshots

(error) MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.

临时解决方案

			
# redis-cli

127.0.0.1:6379> config set stop-writes-on-bgsave-error no
OK
127.0.0.1:6379> set name neo
OK
127.0.0.1:6379> get name
"neo"
			
			

原因是数据库持久化写入硬盘出现问题,可能是数据库目录权限不足。

排查方法

			
CONFIG GET dir
CONFIG GET dbfilename

config set stop-writes-on-bgsave-error yes
CONFIG SET dir /tmp
CONFIG SET dbfilename temp.rdb
			
			

尝试解决

			
# redis-cli 
127.0.0.1:6379> CONFIG GET dir
1) "dir"
2) "/"
127.0.0.1:6379> CONFIG GET dbfilename
1) "dbfilename"
2) "dump.rdb"
127.0.0.1:6379> config set stop-writes-on-bgsave-error yes
OK
127.0.0.1:6379> CONFIG SET dir /tmp
OK
127.0.0.1:6379> set test aaaa
OK
127.0.0.1:6379> get test
"aaaa"
			
			

如果确认是 dir 权限问题,我们就通过修改redis.conf 中得dir配置解决。

33.9.3. You can't write against a read only replica.

Redis 写入出错

			
[root@netkiller ~]# docker exec -it redis redis-cli
127.0.0.1:6379> set name neo
(error) READONLY You can't write against a read only replica.
127.0.0.1:6379> config set slave-read-only no
OK
127.0.0.1:6379> config get slave-read-only
1) "slave-read-only"
2) "no"
127.0.0.1:6379> set name neo
OK
127.0.0.1:6379> get name
"neo"
			
			

33.9.4. MISCONF Redis is configured to save RDB snapshots, but it's currently unable to persist to disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.

MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.

磁盘空间满

33.9.5.