You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Ubuntu 15.10安装MongoDB 4.0失败求助:mongod.service未找到

Hey there, let's break down why you're hitting this issue and how to fix it—this is a common problem when mixing newer MongoDB versions with end-of-life Ubuntu releases.

Root Cause

MongoDB 4.0 does not support Ubuntu 15.10 (code name wily). Ubuntu 15.10 was a short-term release that reached end-of-life back in July 2016, and MongoDB dropped support for non-LTS Ubuntu versions starting with later 3.x releases. MongoDB 4.0 only supports Ubuntu 16.04 LTS and newer, which is why the official docs don't include steps for 15.10, and the mongod.service unit is missing—there's no valid package build for your system version.

First off, Ubuntu 15.10 has no security updates or official support anymore, which is a major risk for any system. The best long-term fix is to upgrade to an LTS release like Ubuntu 16.04, 20.04, or 22.04. Once you're on a supported LTS version, you can follow standard MongoDB 4.0 installation steps without issues.

Alternative: Install MongoDB 3.2 on Ubuntu 15.10 (If You Must Stay on 15.10)

MongoDB 3.2 is the last version that supports Ubuntu 15.10. Here's how to clean up your failed installs and set it up properly:

Step 1: Fully Remove Previous MongoDB Residues

Wipe all traces of your failed 4.0 installation to avoid conflicts:

# Stop any running mongod processes (ignore if no service found)
sudo systemctl stop mongod
# Purge all MongoDB packages
sudo apt purge -y mongodb-org*
# Delete data, logs, and config files
sudo rm -rf /var/log/mongodb /var/lib/mongodb /etc/systemd/system/mongod.service
# Update apt cache
sudo apt update

Step 2: Add MongoDB 3.2 Repository for Ubuntu 15.10

Add the dedicated repo for MongoDB 3.2 on wily:

# Add the repo entry
echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu wily/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
# Import the repo GPG key to verify packages
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927

Step 3: Install MongoDB 3.2 (Pin the Version)

Install the specific 3.2 version and pin it to prevent accidental upgrades to unsupported versions:

sudo apt update
# Install exact version of MongoDB 3.2 packages
sudo apt install -y mongodb-org=3.2.22 mongodb-org-server=3.2.22 mongodb-org-shell=3.2.22 mongodb-org-mongos=3.2.22 mongodb-org-tools=3.2.22
# Pin the version to avoid auto-updates
echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections

Step 4: Configure and Start the Service

Set up necessary permissions and launch the service:

# Create data directory if it doesn't exist
sudo mkdir -p /var/lib/mongodb
sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chmod 755 /var/lib/mongodb
# Reload systemd to recognize the service
sudo systemctl daemon-reload
# Start mongod
sudo systemctl start mongod
# Enable auto-start on boot
sudo systemctl enable mongod

Step 5: Verify the Installation

Check that everything is working as expected:

# Check service status
sudo systemctl status mongod
# Verify MongoDB version
mongo --version

Final Notes

Again, I can't stress enough that staying on Ubuntu 15.10 is not recommended due to the lack of security updates. If possible, prioritize upgrading to an LTS release to get full support for newer MongoDB versions and critical system security patches.

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

火山引擎 最新活动