Ubuntu 22.04.1 LTS安装MongoDB报错:损坏软件包无法修复
Ubuntu 22.04.1 LTS安装MongoDB依赖报错求助
在Ubuntu 22.04.1 LTS系统中安装MongoDB时遇到下载错误,已尝试Stack Overflow上的3种解决方案,但仍出现报错:
E: Unable to correct problems, you have held broken packages.
执行sudo apt-get install -y mongodb-org时的具体错误信息如下:
(base) joy@joy-System-Product-Name:~$ sudo apt-get install -y mongodb-org Reading package lists... Done Building dependency tree... Done Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: mongodb-org-mongos : Depends: libssl1.1 (>= 1.1.1) but it is not installable mongodb-org-server : Depends: libssl1.1 (>= 1.1.1) but it is not installable E: Unable to correct problems, you have held broken packages.
核心原因
Ubuntu 22.04.1 LTS默认使用libssl3,而MongoDB的mongodb-org-mongos和mongodb-org-server依赖的libssl1.1不在22.04的官方源中,导致依赖无法满足,同时触发损坏包报错。
解决方案
方案一:手动安装libssl1.1
- 从Ubuntu 20.04官方源下载对应架构的libssl1.1 deb包(以amd64为例):
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.20_amd64.deb
- 安装下载的deb包:
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2.20_amd64.deb
- 再次执行MongoDB安装命令:
sudo apt-get install -y mongodb-org
方案二:修复系统损坏包后重新安装
如果仍存在损坏包问题,先修复系统依赖:
- 清理本地缓存:
sudo apt clean && sudo apt autoclean
- 自动修复损坏的依赖关系:
sudo apt --fix-broken install
- 更新系统源并升级已安装包:
sudo apt update && sudo apt upgrade -y
- 重新安装MongoDB:
sudo apt-get install -y mongodb-org
内容的提问来源于stack exchange,提问作者j ton
相关产品推荐
相关产品推荐

