Installing mongodb over Ubuntu 22.04

Hello,

These days Ubuntu published their new long term supported version, 22.04, and it is not possible to install mongodb because they don’t support libssl1.1 anymore:

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
 mongodb-org-shell : Depends: libssl1.1 (>= 1.1.1) but it is not installable

I googled it, but I did not find anywhere nobody who could solve this problem. Any ideas?
Thank you!

6 Likes

Are you following these directions?

Yes, but it’s a dependency problem. I tried mongo 4.4 and 5.0, to no avail: same error on both.

1 Like

Aha. I’m on 20.0x and haven’t upgraded to 22 yet. I’m sure @Stennie will have the answer!

1 Like

This worked for me

echo "deb http://security.ubuntu.com/ubuntu impish-security main" | sudo tee /etc/apt/sources.list.d/impish-security.list
sudo apt-get update
sudo apt-get install libssl1.1
7 Likes

Just apt installing openssl 1.1 sounds like a recipe for disaster.
Ubuntu 22.04 already has openssl 3 installed.
I think a MongoDB team member had best respond to this issue with a recommended path
@Stennie ?

2 Likes

Hi folks,

Ubuntu 22.04 was released less than a week ago so doesn’t have official MongoDB packages available yet. The build team is aware and will set up appropriate packaging & testing infrastructure to validate new packages.

Relevant Jira issues to watch are:

I don’t have a specific ETA to share at the moment, but I’d generally recommend waiting for essential software packages to be available before committing to major O/S upgrades.

If you are an early adopter of a new O/S release, suggested interim workarounds would be:

  • Run your MongoDB deployment on separate hosts with supported O/S versions (eg 20.04 LTS)

  • Run MongoDB in a container/VM with a supported O/S version

  • Use a hosted version of MongoDB (eg MongoDB Atlas) so you have fewer direct dependencies on O/S updates

All of these approaches use official binaries, so you are less likely to run into novel issues.

For a development environment you could also consider:

However, I would be very wary of mixing & matching packages intended for different O/S versions (especially for a production environment) as those combinations have not been thoroughly tested.

Regards,
Stennie

8 Likes

Ok, thank you! Will wait for the support then. Out of ignorance, may I ask if generating a snap instead of a deb could solve the dependency problem and other possible library conflicts?

Thanks, It worked for me as well!!

Hi there, hope you’re doing well. I’m currently using MongoDB in Docker and it is good enough while waiting for new update from the MongoDB team.

to start MongoDB (automatically restart):
sudo docker run -dp 27017:27017 -v local-mongo:/data/db --name local-mongo --restart=always mongo

To access into running local-mongo container:
sudo docker exec -it local-mongo sh

Then type mongo and you’re good to go!

4 Likes

This worked for me as well. Still waiting for offcial release.

1 Like

Can you drop the process of installing mongodb on docker ??

Hi Alexander, I’ve already posted the process above. I’ll re-post it in case you didn’t see it:
sudo docker run -dp 27017:27017 -v local-mongo:/data/db --name local-mongo --restart=always mongo

Thank you. Will try it now

As a sidenote, you can still download some of the mongodb binaries from the official ubuntu repo (not recommended by mongodb though), if you just playing around it is fine imho. Example:

sudo apt-get install mongo<tab>
mongocli                          mongodb-mongosh  ...
sudo apt-get install mongodb-mongosh 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Recommended packages:
  libssl1.1

You can see it skips libssl1.1

Is there any ETA on 22.04 packages? Or even RHEL 9?

Any rough estimate? It’s the only blocker we have now for both distros.

6 Likes

Hey fellas.
Is there already any “official” solution to that problem?
I also struggle with Ubuntu 22.04 LTS, cannot install MongoDB on it.

4 Likes

Hi folks! Ubuntu 22.04 has been out for almost 3 months now, when will we be able to install the official version of mongo without all sorts of hacks and tweaks?

5 Likes

I got mongodb 5.0.9 installed on ubuntu 22.05… but boy… it was a hassle.

First you have to remove the libssl1.1 dep from:


mongodb-org-mongos_5.0.9_amd64.deb

mongodb-org-server_5.0.9_amd64.deb

mongodb-org-shell_5.0.9_amd64.deb

My bash script (that’s added below) will open the ‘nano’ editor and offer you to edit the control file specifying the deps. Your are looking for a line like this (starting with “Depends” and containing a reference to “libssl1.1”):


Depends: libc6 (>= 2.29), libcurl4 (>= 7.16.2), libgcc-s1 (>= 4.2), liblzma5 (>= 5.1.1alpha+20110809), libssl1.1 (>= 1.1.1)

Remove the reference to libssl1.1 and save & quit. It should look like this:


Depends: libc6 (>= 2.29), libcurl4 (>= 7.16.2), libgcc-s1 (>= 4.2), liblzma5 (>= 5.1.1alpha+20110809)

The script will automagically repackage the files and generate you a new package with ‘-newpackage.deb’ attached to its name:


mongodb-org-mongos_5.0.9_amd64.deb-newpackage.deb

mongodb-org-server_5.0.9_amd64.deb-newpackage.deb

mongodb-org-shell_5.0.9_amd64.deb-newpackage.deb

Now put them in a folder and install them manually with dpkg:


sudo dpkg -i *.deb

After that run:


sudo apt install --no-install-recommends mongodb-org mongodb-org-database mongodb-org-tools mongodb-mongosh-shared-openssl3

Hint: You don’t need ‘mongodb-mongosh’ from the deps as it’s being replaced by ‘mongodb-mongosh-shared-openssl3’.

Afterwards I couldn’t start the mongod service:


Jun 11 18:14:11 systemd[1]: Started MongoDB Database Server.

Jun 11 18:14:11 systemd[48437]: mongod.service: Failed to determine user credentials: No such process

Jun 11 18:14:11 systemd[48437]: mongod.service: Failed at step USER spawning /usr/bin/mongod: No such process

Jun 11 18:14:11 systemd[1]: mongod.service: Main process exited, code=exited, status=217/USER

Jun 11 18:14:11 systemd[1]: mongod.service: Failed with result 'exit-code'.

Which was because of a missing user (after looking at ‘/etc/systemd/system/mongod.service’), so I added it:


sudo adduser mongodb

Edit, try, fail, repeat:


Jun 11 18:15:53 systemd[1]: Started MongoDB Database Server.

Jun 11 18:15:53 mongod[48504]: /usr/bin/mongod: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory

Jun 11 18:15:53 systemd[1]: mongod.service: Main process exited, code=exited, status=127/n/a

Jun 11 18:15:53 systemd[1]: mongod.service: Failed with result 'exit-code'.

Missing libcrypto from ssl 1.1…

I didn’t have the 3.0 on the system, fix that:


sudo apt-get install libssl-dev

Now search for the file:


sudo find / -type f -name libcrypto.so*

link it:


sudo ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.3 /usr/lib/x86_64-linux-gnu/libcrypto.so.3 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1

And we got the same error for ssl1.1…


Jun 11 18:23:59 mongod[48822]: /usr/bin/mongod: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

Search, link, start…


sudo find / -type f -name libssl.so.*


sudo ln -s /usr/lib/x86_64-linux-gnu/libssl.so.3 /usr/lib/x86_64-linux-gnu/libssl.so.1.1

And error (obviously - it’s 3.0, not 1.1…):


Jun 11 18:26:29 systemd[1]: Started MongoDB Database Server.

Jun 11 18:26:29 mongod[48845]: /usr/bin/mongod: /lib/x86_64-linux-gnu/libcrypto.so.1.1: version `OPENSSL_1_1_0' not found (required by /usr/bin/mongod)

Jun 11 18:26:29 mongod[48845]: /usr/bin/mongod: /lib/x86_64-linux-gnu/libssl.so.1.1: version `OPENSSL_1_1_0' not found (required by /usr/bin/mongod)

Jun 11 18:26:29 mongod[48845]: /usr/bin/mongod: /lib/x86_64-linux-gnu/libssl.so.1.1: version `OPENSSL_1_1_1' not found (required by /usr/bin/mongod)

But didn’t I see a snap with 1.1 libs on the system when running the find commands? - Sure did!


$ sudo find / -type f -name libcrypto.so*

/usr/lib/x86_64-linux-gnu/libcrypto.so.3

/snap/core20/1518/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1


$ sudo find / -type f -name libssl.so.*

/usr/lib/x86_64-linux-gnu/libssl.so.3

/snap/core20/1518/usr/lib/x86_64-linux-gnu/libssl.so.1.1

Let’s remove the previous link and they those…


$ sudo rm /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 /usr/lib/x86_64-linux-gnu/libssl.so.1.1

$ sudo ln -s /snap/core20/1518/usr/lib/x86_64-linux-gnu/libssl.so.1.1 /usr/lib/x86_64-linux-gnu/libssl.so.1.1

$ sudo ln -s /snap/core20/1518/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1

SUCCESS:


$ sudo service mongod start && sudo service mongod status

● mongod.service - MongoDB Database Server

Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)

Active: active (running) since Sat 2022-06-11 18:32:20 CEST; 49ms ago

Docs: https://docs.mongodb.org/manual

Main PID: 48894 (mongod)

Memory: 760.0K

CPU: 16ms

CGroup: /system.slice/mongod.service

└─48894 /usr/bin/mongod --config /etc/mongod.conf

Jun 11 18:32:20 systemd[1]: Started MongoDB Database Server.

Script:

#!/bin/bash
# name: debedit.sh
# author: showp1984
# description: unpacks, edits control file and repacks deb-files with gz or xz compression
# prerequisites: xz-utils && nano
# No guarantees. Use at your own peril.

unset DECOMPXZ
unset DECOMPGZ
FILES="{post,pre}{inst,rm} conffiles md5sums control"

echo "Uncompressing deb..."
ar x $*

FILEXZ="control.tar.xz"
if [ -f "$FILEXZ" ]; then
    DECOMPXZ=1
    echo "Found: $FILEXZ | using XZ decomp..."
    tar --xz -xvf $FILEXZ
fi

FILEGZ="control.tar.gz"
if [ -f "$FILEGZ" ]; then
    DECOMPGZ=1
    echo "$FILEGZ exists."
    tar xzf $FILEGZ
fi

nano control

if [[ "$DECOMPXZ" == 1 ]]; then
    echo "Repacking $FILEXZ..."
    tar --ignore-failed-read -cvJf $FILEXZ $FILES

    echo "Repacking deb with xz files..."
    ar rcs "${*}-newpackage.deb" debian-binary $FILEXZ data.tar.xz
fi

if [[ "$DECOMPGZ" == 1 ]]; then
    echo "Repacking $FILEGZ..."
    tar --ignore-failed-read -cvzf $FILEGZ $FILES

    echo "Repacking deb with gz files..."
    ar rcs "${*}-newpackage.deb" debian-binary $FILEGZ data.tar.gz
fi

echo "Cleanup..."
rm -r control md5sums debian-binary control.tar.xz data.tar.xz control.tar.gz data.tar.gz postrm preinst prerm conffiles postinst

echo "Done!"
4 Likes

I needed two more things mongodb was complaining about in the logs.
YMMV!

Add log dir & file:

$ sudo mkdir /var/log/mongodb/
$ sudo touch /var/log/mongodb/mongod.log
$ sudo chown mongodb:mongodb /var/log/mongodb/mongod.log

Add db dir:

$ sudo mkdir /var/lib/mongodb
$ sudo chown mongodb:mongodb /var/lib/mongodb

Have a nice weekend! :wink:

3 Likes