天天看點

MongoDB 3.0(1):CentOS7 安裝MongoDB 3.0服務

mongodb 3.0 正式版本釋出!這标志着 mongodb 資料庫進入了一個全新的發展階段,提供強大、靈活而且易于管理的資料庫管理系統。mongodb宣稱,3.0新版本不隻提升7到10倍的寫入效率以及增加80%的資料壓縮率,還能減少95%的運維成本。

  mongodb 3.0主要新特性包括:

  ·可插入式的存儲引擎 api

  ·支援 wiredtiger 存儲引擎

  ·mmapv1 提升

  ·複制集全面提升

  ·叢集方面的改進

  ·提升了安全性

  ·工具的提升

wiredtiger 存儲引擎是一項難以置信的技術實作,提供無門闩、非堵塞算法來利用先進的硬體平台(如大容量晶片緩存和線程化架構)來提升性能。通過 wiredtiger,mongodb 3.0 實作了文檔級别的并發控制,是以大幅提升了大并發下的寫負載。

mongodb 提供了centos yum安裝方式。

pdf 手冊:

<a href="http://docs.mongodb.org/manual/mongodb-manual.pdf">http://docs.mongodb.org/manual/mongodb-manual.pdf</a>

vi /etc/yum.repos.d/mongodb-org-3.0.repo

安裝mongodb

安裝了所有相關服務。

配置檔案在:/etc/mongod.conf

資料檔案在:/var/lib/mongo

日志檔案在:/var/log/mongodb

mongodb服務使用

參考:

<a href="http://docs.mongodb.org/manual/core/crud-introduction/">http://docs.mongodb.org/manual/core/crud-introduction/</a>

連接配接到mongodb,很簡單,執行mongo就可以了。

<a href="http://docs.mongodb.org/manual/tutorial/insert-documents/">http://docs.mongodb.org/manual/tutorial/insert-documents/</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.insert/">http://docs.mongodb.org/manual/reference/method/db.collection.insert/</a>

資料可以沒有主鍵_id,如果沒有,會自動生成一個。如果設定了_id主鍵,就必須不重複。

否則報主鍵沖突:“e11000 duplicate key error index: test.users.$_id_ dup key: { : 1.0 }”

<a href="http://docs.mongodb.org/manual/tutorial/modify-documents/">http://docs.mongodb.org/manual/tutorial/modify-documents/</a>

更新使用update,如果增加{ upsert: true },則表示沒有查詢到資料直接插入。

<a href="http://docs.mongodb.org/manual/tutorial/remove-documents/">http://docs.mongodb.org/manual/tutorial/remove-documents/</a>

查詢到資料才進行删除,并且傳回删除數量。

<a href="http://docs.mongodb.org/manual/tutorial/query-documents/">http://docs.mongodb.org/manual/tutorial/query-documents/</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.aggregate">db.collection.aggregate()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.count">db.collection.count()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.copyto">db.collection.copyto()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.createindex">db.collection.createindex()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.getindexstats">db.collection.getindexstats()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.indexstats">db.collection.indexstats()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.datasize">db.collection.datasize()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.distinct">db.collection.distinct()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.drop">db.collection.drop()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.dropindex">db.collection.dropindex()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.dropindexes">db.collection.dropindexes()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.ensureindex">db.collection.ensureindex()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.explain">db.collection.explain()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.find">db.collection.find()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.findandmodify">db.collection.findandmodify()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.findone">db.collection.findone()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.getindexes">db.collection.getindexes()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.getsharddistribution">db.collection.getsharddistribution()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.getshardversion">db.collection.getshardversion()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.group">db.collection.group()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.insert">db.collection.insert()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.iscapped">db.collection.iscapped()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.mapreduce">db.collection.mapreduce()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.reindex">db.collection.reindex()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.remove">db.collection.remove()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.renamecollection">db.collection.renamecollection()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.save">db.collection.save()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.stats">db.collection.stats()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.storagesize">db.collection.storagesize()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.totalsize">db.collection.totalsize()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.totalindexsize">db.collection.totalindexsize()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.update">db.collection.update()</a>

<a href="http://docs.mongodb.org/manual/reference/method/db.collection.storagesize/#db.collection.update">db.collection.validate()</a>

<a href="http://www.robomongo.org/">http://www.robomongo.org/</a>

MongoDB 3.0(1):CentOS7 安裝MongoDB 3.0服務

使用可視化工具,友善使用mongodb管理。

首先要修改下端口和ip

vi /etc/mongod.conf

然後重新開機mongodb

接下來就可以建立一個mongodb連接配接:

MongoDB 3.0(1):CentOS7 安裝MongoDB 3.0服務

連接配接成功之後效果:

MongoDB 3.0(1):CentOS7 安裝MongoDB 3.0服務

mongodb 3.0操作起來還是很友善的。能高效的使用。

同時mongodb擴充也很友善。接下來研究。

對應網際網路業務來說沒有複雜的join查詢。隻追求高效,快速通路。

繼續閱讀