DevOpsDockerDockersHow to

Apt-get fails on 16.04 or 18.04 installing mongodb

Err:8 https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 Release.gpg
The following signatures were invalid: EXPKEYSIG 58712A2291FA4AD5 MongoDB 3.6 Release Signing Key packaging@mongodb.com
Diaba@poseidon:~$ sudo apt-get install mongodb-org
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package mongodb-org is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'mongodb-org' has no installation candidate

Or when you try to run sudo apt update commands you get the following results:

diaba@MongoDB:~$ sudo apt-get update              
Hit:1 http://archive.canonical.com/ubuntu xenial InRelease
Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease
Hit:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu xenial-backports InRelease
Hit:5 http://archive.ubuntu.com/ubuntu xenial-security InRelease
Ign:6 https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 InRelease
Get:7 https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 Release [3,457 B] Get:8 https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 Release.gpg [801 B] Err:8 https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 Release.gpg
The following signatures were invalid: EXPKEYSIG 58712A2291FA4AD5 MongoDB 3.6 Release Signing Key packaging@mongodb.com
Fetched 4,258 B in 0s (7,747 B/s)
Reading package lists… Done
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 Release: The following signatures were invalid: EXPKEYSIG 58712A2291FA4AD5 MongoDB 3.6 Release Signing Key packaging@mongodb.com
W: Failed to fetch https://repo.mongodb.org/apt/ubuntu/dists/xenial/mongodb-org/3.6/Release.gpg The following signatures were invalid: EXPKEYSIG 58712A2291FA4AD5 MongoDB 3.6 Release Signing Key packaging@mongodb.com
W: Some index files failed to download. They have been ignored, or old ones used instead.

To resolve the issue you need to do the following steps:

Ubuntu 16.x and Ubuntu 18.04 & MongoDB 4.x

  1. First, remove MongoDB from previous if installed:
sudo apt remove --autoremove mongodb-o

2. Remove any mongodb repo list files:

sudo rm /etc/apt/sources.list.d/mongodb*.list
sudo apt update

3. add the new key or Import the public key used by the package management system.:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4

4. Create a list file for MongoDB:

Ubuntu 16.x “Ubuntu 16.04 (Xenial)”:

The following instruction is for Ubuntu 16.04 (Xenial). For Ubuntu 14.04 (Trusty) or Ubuntu 18.04 (Bionic), click on the appropriate tab.

Create the /etc/apt/sources.list.d/mongodb-org-4.0.list file for Ubuntu 16.04 (Xenial):

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.lis

5. Reload local package database:

sudo apt-get update         

6. Install the MongoDB packages:

To install the latest stable version, issue the following:

sudo apt-get install -y mongodb-org

Ubuntu 18.04 (Bionic):

The following instruction is for Ubuntu 18.04 (Bionic). For Ubuntu 14.04 (Trusty) or Ubuntu 16.04 (Xenial), click on the appropriate tab.

  1. Create the /etc/apt/sources.list.d/mongodb-org-4.0.list file for Ubuntu 18.04 (Bionic):
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.lis

2. Reload local package database:

Issue the following command to reload the local package database:

sudo apt-get update

3. Install the MongoDB packages:

To install the latest stable version, issue the following:

sudo apt-get install -y mongodb-or

Install a specific release of MongoDB:

To install a specific release, you must specify each component package individually along with the version number, as in the following example:

sudo apt-get install -y mongodb-org=4.0.6 mongodb-org-server=4.0.6 mongodb-org-shell=4.0.6 mongodb-org-mongos=4.0.6 mongodb-org-tools=4.0.6

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

bMLwwo

Please type the text above:

Check Also

Close
Close
Close