When attempting to install MongoDB 3.4 on Debian 9 (Stretch), you'll encounter dependency issues with libssl1.0.0. This occurs because:
mongodb-org-mongos : Depends: libssl1.0.0 (>= 1.0.1) mongodb-org-tools : Depends: libssl1.0.0 (>= 1.0.1) mongodb-org-shell : Depends: libssl1.0.0 (>= 1.0.1) mongodb-org-server : Depends: libssl1.0.0 (>= 1.0.1)
Debian Stretch ships with libssl1.1 by default, which isn't compatible with MongoDB 3.4's requirements.
First, add the Debian Jessie repository temporarily:
echo "deb http://security.debian.org/debian-security jessie/updates main" | sudo tee -a /etc/apt/sources.list
Then install the required SSL library:
sudo apt-get update sudo apt-get install libssl1.0.0
After this, proceed with MongoDB installation:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.4 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list sudo apt-get update sudo apt-get install mongodb-org
For a cleaner solution, consider upgrading to MongoDB 3.6 which supports newer SSL libraries:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/3.6 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list sudo apt-get update sudo apt-get install mongodb-org
After successful installation, check MongoDB version:
mongo --version
And verify the service is running:
sudo systemctl status mongod
For those who prefer official packages:
# For Debian 9 (Stretch) echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
Note that this installs a newer version (4.0) which has better compatibility with modern systems.
Remember to configure authentication and firewall rules after installation:
# Enable MongoDB authentication sudo nano /etc/mongod.conf # Add these lines: security: authorization: enabled
Restart MongoDB to apply changes:
sudo systemctl restart mongod
When attempting to install MongoDB 3.4 on Debian Stretch, you'll encounter SSL dependency issues because MongoDB 3.4 packages were built against libssl1.0.0
, while Debian 9 (Stretch) ships with libssl1.0.2
or libssl1.1
. Here's what typically happens:
# Common error output
mongodb-org-server : Depends: libssl1.0.0 (>= 1.0.1) which is a virtual package
mongodb-org-shell : Depends: libssl1.0.0 (>= 1.0.1)
mongodb-org-mongos : Depends: libssl1.0.0 (>= 1.0.1)
mongodb-org-tools : Depends: libssl1.0.0 (>= 1.0.1)
Here are three approaches to resolve this:
Option 1: Install libssl1.0.0 from Jessie
Manually download and install the older libssl package:
wget http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u12_amd64.deb
sudo dpkg -i libssl1.0.0_1.0.1t-1+deb8u12_amd64.deb
sudo apt-mark hold libssl1.0.0
sudo apt-get install -f
sudo apt-get install mongodb-org
Option 2: Use MongoDB 3.6+ Instead
MongoDB 3.6 and later versions properly support libssl1.1:
echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.4 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
sudo apt-get update
sudo apt-get install mongodb-org
Option 3: Rebuild MongoDB Packages
For advanced users who must use MongoDB 3.4:
# Install build dependencies
sudo apt-get install devscripts build-essential fakeroot debhelper
# Download source
apt-get source mongodb-org=3.4.24
cd mongodb-org-3.4.24
# Modify debian/control to use libssl1.1
sed -i 's/libssl1.0.0/libssl1.1/g' debian/control
# Rebuild package
dpkg-buildpackage -rfakeroot -uc -b
# Install rebuilt packages
cd ..
sudo dpkg -i *.deb
After successful installation, verify MongoDB is running:
sudo systemctl start mongod
sudo systemctl status mongod
mongo --version
- If you get segmentation faults, check for mixed libssl versions with
ldd $(which mongod)
- For authentication issues, ensure you've created admin user:
db.createUser({user: "admin", roles: ["root"]})
- Check logs at
/var/log/mongodb/mongod.log
for detailed errors
For production environments, consider:
# Using Docker
docker run --name mongodb34 -p 27017:27017 -d mongo:3.4
# Using manual tarball installation
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian81-3.4.24.tgz
tar -zxvf mongodb-linux-x86_64-debian81-3.4.24.tgz
mv mongodb-linux-x86_64-debian81-3.4.24 /usr/local/mongodb