安装MongoDB [4.0.2版本]
MongoDB簡介
MongoDB 是一個(gè)基于分布式文件存儲(chǔ)的數(shù)據(jù)庫。由C++語言編寫。旨在為WEB應(yīng)用提供可擴(kuò)展的高性能數(shù)據(jù)存儲(chǔ)解決方案。
??
MongoDB 是一個(gè)介于關(guān)系數(shù)據(jù)庫和非關(guān)系數(shù)據(jù)庫之間的產(chǎn)品,是非關(guān)系數(shù)據(jù)庫當(dāng)中功能最豐富,最像關(guān)系數(shù)據(jù)庫的。它支持的數(shù)據(jù)結(jié)構(gòu)非常松散,是類似json的bson格式,因此可以存儲(chǔ)比較復(fù)雜的數(shù)據(jù)類型。Mongo最大的特點(diǎn)是它支持的查詢語言非常強(qiáng)大,其語法有點(diǎn)類似于面向?qū)ο蟮牟樵冋Z言,幾乎可以實(shí)現(xiàn)類似關(guān)系數(shù)據(jù)庫單表查詢的絕大部分功能,而且還支持對數(shù)據(jù)建立索引。
它的特點(diǎn)是高性能、易部署、易使用,存儲(chǔ)數(shù)據(jù)非常方便。主要功能特性有:
- 面向集合存儲(chǔ),易存儲(chǔ)對象類型的數(shù)據(jù)。
- 模式自由、支持查詢、支持動(dòng)態(tài)查詢。
- 支持完全索引,包含內(nèi)部對象。
- 支持復(fù)制和故障恢復(fù)。
- 使用高效的二進(jìn)制數(shù)據(jù)存儲(chǔ),包括大型對象(如視頻等)。
- 自動(dòng)處理碎片,以支持云計(jì)算層次的擴(kuò)展性。
- 支持RUBY,PYTHON,JAVA,C++,PHP,C#等多種語言。
- 文件存儲(chǔ)格式為BSON(一種JSON的擴(kuò)展)。
- 可通過網(wǎng)絡(luò)訪問。
安裝配置
如果shell啟動(dòng)進(jìn)程所占的資源設(shè)置過低,將會(huì)產(chǎn)生錯(cuò)誤導(dǎo)致無法連接,需要設(shè)置ulimit -n 和ulimit -u 的值大于20000.
# ulimit -n 25000 # ulimit -u 25000 [root@test4-8g ~]# systemctl stop firewalld && systemctl disable firewalld [root@test4-8g ~]# setenforce 0 [root@test4-8g ~]# cat /etc/selinux/config SELINUX=disabled [root@test4-8g ~]# getenforce 0 Permissive1.YUM安裝
[root@test4-8g ~]# vim /etc/yum.repos.d/mongodb-org-4.0.repo[mongodb-org-4.0] name = MongoDB Repository baseurl = https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/ gpgcheck = 1 enabled = 1 gpgkey = https://www.mongodb.org/static/pgp/server-4.0.asc [root@test4-8g ~]# yum install -y mongodb-org啟動(dòng):
[root@test4-8g ~]# service mongod start [root@test4-8g ~]# mongo ····· To permanently disable this reminder, run the following command: db.disableFreeMonitoring() --- >2.下載Tar包,解壓安裝
安裝包地址:https://www.mongodb.com/downloads
Tar包安裝解決依賴:
創(chuàng)建數(shù)據(jù)存儲(chǔ)目錄和日志文件目錄
[root@test4-8g ~]# mkdir -p /usr/local/mongodb/data/db [root@test4-8g ~]# mkdir -p /usr/local/mongodb/logs編輯MongoDB啟動(dòng)配置文件
[root@test4-8g ~]# cd /usr/local/mongodb/bin [root@test4-8g bin]# vim mongodb.confdbpath = /usr/local/mongodb/data/db //數(shù)據(jù)存儲(chǔ)目錄 logpath = /usr/local/mongodb/logs/mongodb.log //日志文件目錄 fork = true //后臺(tái)運(yùn)行 #auth=true bind_ip=0.0.0.0MongoDB 的可執(zhí)行文件位于 bin 目錄下,需要將其添加到 PATH 路徑中
[root@test4-8g bin]# vim /etc/profile export MONGODB_HOME=/usr/local/mongodb export PATH=$PATH:$MONGODB_HOME/bin //末尾處添加 [root@test4-8g bin]# source /etc/profile //重新加載環(huán)境變量啟動(dòng)MongoDB
[root@test4-8g bin]# mongod -f mongodb.conf 2018-09-27×××5:50:18.042+0800 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none' about to fork child process, waiting until server is ready for connections. forked process: 19149 child process started successfully, parent exiting [root@test4-8g bin]# lsof -i:27017 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME mongod 19149 root 11u IPv4 49167 0t0 TCP *:27017 (LISTEN)連接MongoDB并訪問
[root@test4-8g bin]# /usr/local/mongodb/bin/mongo ······ For interactive help, type "help". For more comprehensive documentation, seehttp://docs.mongodb.org/ Questions? Try the support grouphttp://groups.google.com/group/mongodb-user > [root@test4-8g bin]# mongo MongoDB shell version v4.0.2 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 4.0.2 >轉(zhuǎn)載于:https://blog.51cto.com/13767724/2286689
總結(jié)
以上是生活随笔為你收集整理的安装MongoDB [4.0.2版本]的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 摩托车二手车交易
- 下一篇: 中国机器人市场前景开阔 本土企业如何突围