MongoDB 3.4安裝

?window 安裝

不做過多贅述,還是比較簡單的 http://www.runoob.com/mongodb/mongodb-window-install.html

linux 下安裝??

參照MongoDB英文版文檔編寫

Install MongoDB Community Edition on Ubuntu 18.04

Overview

使用本教程使用.deb軟件包在LTS Ubuntu Linux系統(tǒng)上安裝MongoDB Community Edition。

重要

由Ubuntu提供的非官方mongodb包不是由MongoDB維護的。您應該始終使用官方的MongoDB mongodb-org軟件包,它們與最新的主要和次要MongoDB版本保持同步。

平臺支持

MongoDB僅提供64位LTS(長期支持)Ubuntu版本的軟件包。例如,14.04 LTS(可信),16.04 LTS(xenial),依此類推。這些包可能與其他Ubuntu版本一起使用,但是,它們不受支持。

Ubuntu 12.04 LTS(精確)不再支持MongoDB 3.4.15。

適用于IBM POWER SYSTEMS的UBUNTU 16.04所需的包更新

由于Ubuntu 16.04 for POWER上舊版glibc軟件包中存在鎖定缺陷錯誤,因此在運行MongoDB之前,必須將glibc軟件包升級到至少glibc 2.23-0ubuntu5。具有較舊版本的glibc軟件包的系統(tǒng)將因隨機內(nèi)存損壞而遇到數(shù)據(jù)庫服務器崩潰和不當行為,并且不適合MongoDB的生產(chǎn)部署

Packages

MongoDB在自己的存儲庫中提供官方支持的包。 此存儲庫包含以下包:



? ? mongodb-org-server軟件包提供了一個初始化腳本,該腳本使用/etc/mongod.conf配置文件啟動mongod。

有關使用此初始化腳本的詳細信息,請參閱運行MongoDB Community Edition。

這些程序包與Ubuntu提供的mongodb,mongodb-server和mongodb-clients程序包沖突。

默認情況下,軟件包提供的默認/etc/mongod.conf配置文件的bind_ip設置為127.0.0.1。 在初始化副本集之前,根據(jù)您的環(huán)境需要修改此設置。

Install MongoDB Community Edition

MongoDB僅提供64位LTS(長期支持)Ubuntu版本的軟件包。 例如,14.04 LTS(可信),16.04 LTS(xenial),依此類推。 這些包可能與其他Ubuntu版本一起使用,但是,它們不受支持。

Ubuntu 12.04 LTS(精確)不再支持MongoDB 3.4.15。

Import the public key used by the package management system.

Import the public key used by the package management system.

The Ubuntu package management tools (i.e. dpkg and apt) ensure package consistency and authenticity by requiring that distributors sign packages with GPG keys. Issue the following command to import the MongoDB public GPG Key:

? ? sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6

創(chuàng)建 MongoDB list 文件

Create the /etc/apt/sources.list.d/mongodb-org-3.4.list list file using the command appropriate for your version of Ubuntu:

Ubuntu 14.04

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

Ubuntu 16.04

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

重載package

Issue the following command to reload the local package database:

? ? sudo apt-get update

安裝 MongoDB packages

Install the latest stable version of MongoDB.

Issue the following command:

? ? sudo apt-get install -y mongodb-org

運行n MongoDB社區(qū)版本

MongoDB的默認數(shù)據(jù)存放在?/var/lib/mongodb

MongoDB日志默認存放在/var/log/mongodb

你也可以通過/etc/mongod.conf自行定義路徑和各種信息

打開 MongoDB

? ? ? ? sudo service mongod start

驗證MongoDB 是否開啟成功

查看日志文件信息?/var/log/mongodb/mongod.log有下列信息則為成功

? ? ? ?waiting for connections on port 27017

提示:端口號可以在 /etc/mongod.conf 中設置, 27017 是默認的.

停止MongoDB.

sudo service mongod stop


重啟 MongoDB.

? ? sudo service mongod restart

卸載 MongoDB Community Edition

停止 MongoDB.

? ? sudo service mongod stop

移除Packages.

? ? sudo apt-get purge mongodb-org*

刪除數(shù)據(jù)

? ? sudo rm -r /var/log/mongodb

? ? sudo rm -r /var/lib/mongodb

配置文件mongod.conf示例

mongod.conf 具體示例 參見文檔

? ? # for documentation of all options, see:

? ? #? http://docs.mongodb.org/manual/reference/configuration-options/

? ? # Where and how to store data.

? ? storage:

? ? ? dbPath: /var/lib/mongodb? ? #數(shù)據(jù)庫路徑

? ? ? journal:

? ? ? ? enabled: true

? ? #? engine:

? ? #? mmapv1:

? ? #? wiredTiger:

? ? # where to write logging data.

? ? systemLog:

? ? ? destination: file

? ? ? logAppend: true

? ? ? path: /var/log/mongodb/mongod.log? #日志路徑

? ? # network interfaces

? ? net:

? ? ? port: 27017

? ? ? bindIp: 0.0.0.0 #允許訪問的ip 地址? 0.0.0.0代表都可以 指定ip示例 192.168.10.11,192.168.10.13

? ? #processManagement:

? ? #security:

? ? #operationProfiling:

? ? #replication:

? ? #sharding:

? ? ## Enterprise-Only Options:

? ? #auditLog:

? ? #snmp:

MongoDB的在服務自啟動

將mongodb啟動項目追加入/etc/rc.local保證mongodb在服務器開機時啟動

? ? #!/bin/sh -e

? ? #

? ? # rc.local

? ? #

? ? # This script is executed at the end of each multiuser runlevel.

? ? # Make sure that the script will "exit 0" on success or any other

? ? # value on error.

? ? #

? ? # In order to enable or disable this script just change the execution

? ? # bits.

? ? #

? ? # By default this script does nothing.

? ? touch /var/lock/subsys/local

? ? sudo service mongod start

? ? exit 0


本文參見英文文檔編寫!英文文檔連接地址:https://docs.mongodb.com/v3.4/

?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容