简体   繁体   English

在 ubuntu 22.04 上安装 MongoDB

[英]install MongoDB on ubuntu 22.04

I am follow this step but not working for ubuntu 22.04.我正在按照此步骤操作,但不适用于 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.这是因为缺少依赖项 mongodb 未安装在 ubuntu 22.04 上。 The main reason is the missing of libssl1.1 dependency.主要原因是缺少 libssl1.1 依赖。 So we need to install it seperately.所以我们需要单独安装。

1. sudo apt install dirmngr gnupg apt-transport-https ca-certificates software-properties-common 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 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 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 4. apt update

5. apt install libssl1.1 5. apt install libssl1.1

6. wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add - 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 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 8. apt update

9. apt install -y mongodb-org 9. apt install -y mongodb-org

The latest version of mongodb will be installed To start it将安装最新版mongodb启动它

1. systemctl enable mongod systemctl enable mongod

2. systemctl start mongod systemctl start mongod

In case MongoDB doesn't start run the command below to reload.如果 MongoDB 没有启动,请运行以下命令重新加载。

systemctl daemon-reload

I installed it in the following way:我通过以下方式安装它:

Step 1/2: Installation of libssl1.1步骤 1/2:安装 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步骤 2/2:安装 mongodb

Following the official mongodb installion page https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/按照官方mongodb安装页面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.该操作应以 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. Mongodb 现已安装。

To start mongodb: sudo systemctl start mongod .要启动 mongodb: sudo systemctl start mongod To verify that MongoDB has started successfully: sudo systemctl status mongod要验证 MongoDB 是否已成功启动: sudo systemctl status mongod

Solution: Depends: libssl1.1 (>= 1.1.1) but it is not installable解决方案:取决于:libssl1.1 (>= 1.1.1) 但无法安装

Steps to install mongodb in ubuntu 22.04 ubuntu 22.04安装mongodb的步骤

  1. First of all update system packages首先更新系统包

sudo apt update

  1. Download libssl1.1_1.1.1f-1ubuntu2_amd64.deb下载 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使用 dpkg 命令安装上面的

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将 MongoDB GPG 密钥添加到 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.创建一个名为 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在您的系统上安装 MongoDB

sudo apt install mongodb-org -y

  1. Start the MongoDB service启动MongoDB服务

sudo systemctl start mongod

  1. Check MongoDB status查看MongoDB状态

sudo systemctl status mongod

  1. Enable the MongoDB database.启用 MongoDB 数据库。 This is for running even after rebooting.这是为了即使在重新启动后也能运行。

sudo systemctl enable mongod

  1. For accessing mongodb shell用于访问 mongodb shell

mongo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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