python_note
  • Introduction
  • My Python
    • Anaconda
    • argparse
    • datetime
    • json
    • logging
    • numpy
    • open
    • openCC
    • pandas & csv
    • Socket & SocketServer
    • re
    • yaml
    • smtp
    • 物件操作
    • unittest
    • 線程
    • prettytable
    • IO
    • pycurl
    • sys
    • pickle
    • auto-python-to-exe
    • cython
    • nuitka
  • Crawler
    • Urllib & Requests
      • User-agent
      • Percent-Encoding
      • mail code
    • Selenium
    • TCP & UDP
    • 控制字符(control character)
  • Web Development
    • Flask
      • RESTful api
      • Template
      • blueprint
    • Django
      • 環境佈署(windows)
    • 檢查Port
    • Apache
    • 使用者行為
    • jQuery
    • 壓力測試
    • DataTable
    • Bootstrap
    • CSS
    • JavaScript
    • Chart.js
  • Deep Learning
    • Keras 設定
    • RNN
    • LSTM
  • Test
    • T-Test
  • 資料結構
    • Hash
    • 時間複雜度
  • NLP
    • N-gram
    • CKIP
    • 中文轉數字
    • CRF
    • Mutual Information
    • 模糊比對
  • Linebot
    • Heroku
    • 圖文選單
    • channel
  • Linux
    • 常用指令
    • shell script
    • sshfs
    • ssh
    • nodejs & npm
    • debug
  • GCP
    • app engine
    • ssh(gcp)
    • gsutil
    • brabrabra
    • Load Balancer
    • k8s
  • Database
    • mysql
    • elasticsearch
      • Query
      • Backup and Restore
      • elasticdump
      • es2csv
      • ELK
    • mongodb
      • install
      • authentication
      • pymongo
    • sql server
  • go
    • Swarm
  • Docker
    • Kitematic
    • Dockerfile
    • Swarm
  • Git
  • 其他
    • USB軟體保護
    • Windows效能監視器
  • Blockchain
Powered by GitBook
On this page
  • 環境
  • 安裝流程
  • 1. 在ubuntu新增public key
  • 2. 創建list file
  • 3. 重新載入上述設定
  • 4. 開始安裝
  • 5. 檢查安裝結果

Was this helpful?

  1. Database
  2. mongodb

install

環境

安裝環境:ubuntu 18.04

windows沒裝過

安裝流程

1. 在ubuntu新增public key

先直接使用官網語法取得key

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

如果有gnupg相關錯誤:

 sudo apt-get install gnupg

如果出現錯誤訊息no valid openpgp data found,可以嘗試將語法拆開來輸入

先輸入

wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc

再輸入

sudo apt-key add server-4.2.asc

[暴力解]如果還是不行,直接手動產生一個.asc檔,再將url中的key貼上儲存

2. 創建list file

要在/etc/apt/sources.list.d/建立檔案,內容包含server到件網址,語法:

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

若執行時遇到certificate is not trusted驗證問題,可嘗試將上述檔案中的連結的HTTPS的S拿掉試試看,

變成:

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

3. 重新載入上述設定

sudo apt-get install -y mongodb-org

4. 開始安裝

預設安裝目前最新版本

sudo apt-get install -y mongodb-org

5. 檢查安裝結果

重啓、啓動、停止、查看mongoDB的狀態

sudo systemctl status mongodb
sudo systemctl stop mongodb
sudo systemctl start mongodb
sudo systemctl restart mongodb

或者

sudo service mongod start
sudo service mongod status
sudo service mongod stop
sudo service mongod restart

確認開啟後(running)

打開新的vmd輸入,看看能否正常連線:

mongo

或者

mongo --eval 'db.runCommand({ connectionStatus: 1 })'

若回傳資訊也包含1則表示成功

PreviousmongodbNextauthentication

Last updated 5 years ago

Was this helpful?

參考文章:

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
https://www.howtoing.com/how-to-install-mongodb-on-ubuntu-18-04
https://www.twblogs.net/a/5c8e694cbd9eee35fc1528a2
https://medium.com/feveral%E7%9A%84%E7%A8%8B%E5%BC%8F%E7%AD%86%E8%A8%98/%E5%9C%A8-ubuntu-%E4%B8%8A%E5%AE%89%E8%A3%9D-mongodb-df3ef7f4279f