Ubuntu 22.04安裝MongoDB 7.0

小編今天要來介紹如何在Ubuntu 22.04.3安裝MongoDB 7.0資料庫,廢話不多說~馬上安排!

Set1、安裝Ubuntu 22.04
參考:
https://ailog.tw/lifelog/2021/05/15/ubuntu-20-install/

Set2、更新Ubuntu
參考:
https://ailog.tw/lifelog/2019/08/18/ubuntu-update/

Set3、安裝libssl1.1
語法:

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


Set4、安裝相依套件

語法:

curl -fsSL https://pgp.mongodb.com/server-7.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor


Set5、安裝APT 套件庫

語法:

echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list

 

Set6、更新APT 套件庫
語法:

sudo apt update

Set7、安裝mongodb資料庫
語法:

sudo apt install mongodb-org -y

 

Set8、檢查mongodb版本
語法:

mongod --version

 

Set9、啟動mongodb服務
語法:

sudo systemctl start mongod

Set10、檢查mongodb服務
語法:

sudo systemctl status mongod

 

Set11、檢查mongodb服務Port
語法:

sudo ss -pnltu | grep 27017

 

Set12、設定開機啟動mongodb服務
語法:

sudo systemctl enable mongod