解决安装 redis 时报错 unrecoverable fatal error
后知后觉 暂无评论

服务器之前安装过 redis-server,因已经将服务迁移至 Kubernetes,因此只需要安装 redis-cli 客户端即可。

执行包管理命令进行安装,结果执行安装报错:

sudo apt install redis-tools
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libjemalloc2 liblzf1
Suggested packages:
  ruby-redis
The following NEW packages will be installed:
  libjemalloc2 liblzf1 redis-tools
0 upgraded, 3 newly installed, 0 to remove and 4 not upgraded.
Need to get 1,379 kB of archives.
After this operation, 7,423 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://ftp.lanet.kr/ubuntu-ports noble/universe arm64 libjemalloc2 arm64 5.3.0-2build1 [204 kB]
Get:2 https://ftp.lanet.kr/ubuntu-ports noble/universe arm64 liblzf1 arm64 3.6-4 [7,426 B]
Get:3 https://ftp.lanet.kr/ubuntu-ports noble-updates/universe arm64 redis-tools arm64 5:7.0.15-1ubuntu0.24.04.1 [1,167 kB]
Fetched 1,379 kB in 1s (2,413 kB/s)
dpkg: unrecoverable fatal error, aborting:
 unknown system user 'redis' in statoverride file; the system user got removed
before the override, which is most probably a packaging bug, to recover you
can remove the override manually with dpkg-statoverride
E: Sub-process /usr/bin/dpkg returned an error code (2)

异常

可以看到报错信息如下:

dpkg: unrecoverable fatal error, aborting:
 unknown system user 'redis' in statoverride file; the system user got removed
before the override, which is most probably a packaging bug, to recover you
can remove the override manually with dpkg-statoverride

dpkg-statoverrideDebian/Ubuntu 系统中用于管理文件权限覆盖的工具,它允许用户手动修改文件或目录的权限和所有者,并且这些更改在系统更新时会被保留,因为用户操作的原因导致部分权限改动残留,和需要安装的包内容存在冲突,需要先处理这部分异常。

解决

使用命令查询所有存在的权限改动记录:

## 此命令查询的文件为 '/var/lib/dpkg/statoverride'
## 不过还是推荐使用命令执行标准操作,而不是直接编辑文件内容
sudo dpkg-statoverride --list

输出结果为:

redis redis 640 /etc/redis/redis.conf

找到其中涉及 redis 的行和其涉及的文件,执行命令:

sudo dpkg-statoverride --remove /etc/redis/redis.conf

附录

参考链接

如果遇到问题或者对文章内容存疑,请在下方留言,博主看到后将及时回复,谢谢!
回复 / 查看「历史评论
回答17+34=