[18862] xx Xxx 11:54:26.096 * 1 changes in 1800 seconds. Saving... [18862] xx Xxx 11:54:26.533 * Background saving started by pid 15785 [18862] xx Xxx 11:57:41.308 # Background saving terminated by signal 9 [18862] xx Xxx 11:57:43.185 * 1 changes in 1800 seconds. Saving... [18862] xx Xxx 11:57:43.621 * Background saving started by pid 16600 [18862] xx Xxx 11:58:56.646 # Background saving terminated by signal 9
可kill之后发现redis变成只读的了,不能写入了:
1 2 3
redis1:6379> set11 (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.
查了代码里在bgsaveerr的时候会出现这个:
1 2 3
shared.bgsaveerr = createObject(REDIS_STRING,sdsnew( "-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.\r\n"));
/* Don't accept write commands if there are problems persisting on disk * and if this is a master instance. */ if (((server.stop_writes_on_bgsave_err && server.saveparamslen > 0 && server.lastbgsave_status == REDIS_ERR) || server.aof_last_write_status == REDIS_ERR) && server.masterhost == NULL && (c->cmd->flags & REDIS_CMD_WRITE || c->cmd->proc == pingCommand)) { flagTransaction(c); if (server.aof_last_write_status == REDIS_OK) addReply(c, shared.bgsaveerr); else addReplySds(c, sdscatprintf(sdsempty(), "-MISCONF Errors writing to the AOF file: %s\r\n", strerror(server.aof_last_write_errno))); return REDIS_OK; }
快速解决的方法就是把状态设置为off,然后把bgsave关闭
1 2
config set stop-writes-on-bgsave-error no config set bgsave 0 0