ERR Can't save in background: fork failed: Background save failed: fork failed(后台保存失败:fork 失败)
Redis含义
Redis 无法为后台 RDB 快照或 AOF 重写创建子进程(fork)。由于持久化无法运行,数据无法写入磁盘。
原因
操作系统无法为 fork 分配足够的内存;通常是禁用了 overcommit_memory,当 Redis 试图预留大约一份其所用内存的副本时,系统拒绝。物理/虚拟内存不足或进程数限制也可能导致此问题。
解决方法
在 Linux 上启用内存超额分配:sysctl vm.overcommit_memory=1(添加到 /etc/sysctl.conf 中使其永久生效)。为服务器增加内存或降低 Redis 内存使用量(maxmemory)。提供足够的交换空间。检查进程/文件描述符限制(ulimit)。如果持久化至关重要,在没有这些设置的情况下不要上线生产。
同一数据库的其他条目
- ERR unknown subcommandERR unknown subcommand or wrong number of arguments(未知子命令或参数数量错误)
- ERR Client sent AUTH, but no password is setERR AUTH <password> called without any password configured for the default user (Redis 6+) / ERR Client sent AUTH, but no password is set (Redis <6)(调用了 AUTH,但服务器未配置密码)
- ERR DEBUG command not allowedDEBUG command not allowed(不允许使用 DEBUG 命令)
- NOPROTO unsupported protocol versionUnsupported RESP protocol version(不支持的 RESP 协议版本)
- ERR Unknown option or number of arguments for CONFIG SETUnknown option or number of arguments for CONFIG SET (older versions: Unsupported CONFIG parameter)(CONFIG SET 的选项未知或参数数量错误)
- ERR MULTI calls can not be nestedMULTI calls can not be nested(MULTI 调用不能嵌套)
- ERR Lua script attempted to access nonexistent global variableLua script attempted to access a nonexistent global variable(Lua 脚本试图访问不存在的全局变量)