You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 22.04系统中MongoDB服务无法启动问题求助

问题:MongoDB服务无法启动,提示单元文件不存在

The unit file for mongoDB doesn't exist

  • 已按照MongoDB社区论坛的安装指南在Ubuntu 22.04上安装了最新版本MongoDB
  • 已安装Ubuntu 22.04缺失的依赖项libssl1.1
  • 添加正确的文件和配置文件后,执行以下命令无法启动服务:
    sudo systemctl enable mongodb
    sudo service mongodb start
    

解决步骤

  1. 确认systemd单元文件名
    新版MongoDB包通常使用mongod而非mongodb作为systemd单元名称,先检查系统中存在的相关服务单元:

    sudo systemctl list-units --type=service | grep mongo
    

    若输出显示mongod.service,则使用该名称进行后续操作。

  2. 重新加载systemd配置
    若手动添加过配置文件,先让systemd重新识别配置:

    sudo systemctl daemon-reload
    
  3. 使用正确命令启动服务
    确认单元名为mongod后,执行以下命令:

    sudo systemctl enable mongod
    sudo systemctl start mongod
    
  4. 修复不完整的安装
    如果仍找不到单元文件,彻底重装MongoDB包:

    sudo apt-get purge mongodb*
    sudo apt-get autoremove
    sudo apt-get install mongodb-org
    

    重装完成后再次尝试启动服务。

  5. 排查启动失败原因
    若服务启动失败,查看状态和日志定位问题:

    sudo systemctl status mongod
    sudo journalctl -u mongod -f
    

内容的提问来源于stack exchange,提问作者ICE

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 05:40:24