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管理。
首先要修改下端口和ip
vi /etc/mongod.conf
然后重启mongodb
接下来就可以创建一个mongodb连接:
连接成功之后效果:
mongodb 3.0操作起来还是很方便的。能高效的使用。
同时mongodb扩展也很方便。接下来研究。
对应互联网业务来说没有复杂的join查询。只追求高效,快速访问。