简体   繁体   中英

install MongoDB on ubuntu 22.04

I am follow this step but not working for ubuntu 22.04.

echo "* Installing Mongod..."
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4

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

sudo apt-get update -y
sudo apt-get install -y mongodb-org
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

echo "* Installing Mongod..."
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4

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

sudo apt-get update -y
sudo apt-get install -y mongodb-org
sudo service mongod start
sudo service mongod status

Finally! Below Solutions worked for me

It is because of the missing dependencies mongodb not installing on ubuntu 22.04. The main reason is the missing of libssl1.1 dependency. So we need to install it seperately.

1. sudo apt install dirmngr gnupg apt-transport-https ca-certificates software-properties-common

2. echo "deb http://security.ubuntu.com/ubuntu impish-security main" | sudo tee /etc/apt/sources.list.d/impish-security.list echo "deb http://security.ubuntu.com/ubuntu impish-security main" | sudo tee /etc/apt/sources.list.d/impish-security.list

3.Go to root user sudo -i then paste this wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb

4. apt update

5. apt install libssl1.1

6. wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add - wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -

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

8. apt update

9. apt install -y mongodb-org

The latest version of mongodb will be installed To start it

1. systemctl enable mongod

2. systemctl start mongod

In case MongoDB doesn't start run the command below to reload.

systemctl daemon-reload

I installed it in the following way:

Step 1/2: Installation of libssl1.1

download library
wget http://http.us.debian.org/debian/pool/main/o/openssl/libssl1.1_1.1.1o-1_amd64.deb
install it
sudo dpkg -i libssl1.1_1.1.1o-1_amd64.deb

Step 2/2: Installation of mongodb

Following the official mongodb installion page https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/

wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -

The operation should respond with an OK.

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
sudo apt update
sudo apt-get install -y mongodb-org

Mongodb is now installed.

To start mongodb: sudo systemctl start mongod . To verify that MongoDB has started successfully: sudo systemctl status mongod

Solution: Depends: libssl1.1 (>= 1.1.1) but it is not installable

Steps to install mongodb in ubuntu 22.04

  1. First of all update system packages

sudo apt update

  1. Download libssl1.1_1.1.1f-1ubuntu2_amd64.deb

wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb

  1. Install the above using the dpkg command

sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb

  1. Install required packages

sudo apt install wget curl gnupg2 software-properties-common apt-transport-https ca-certificates lsb-release

  1. Add the MongoDB GPG key to apt

wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -

  1. Create a file called mongodb-org-5.0.list. To download and install the sources of the target packages

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

  1. Update system packages again

sudo apt update

  1. Install MongoDB on your system

sudo apt install mongodb-org -y

  1. Start the MongoDB service

sudo systemctl start mongod

  1. Check MongoDB status

sudo systemctl status mongod

  1. Enable the MongoDB database. This is for running even after rebooting.

sudo systemctl enable mongod

  1. For accessing mongodb shell

mongo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM