mongodb之linux通用二进制包安装

MonfoDB是开源文档数据库,,提供共性能、高可用、自动扩展等

MongoDB中记录是文档,其是字段和值组成的对结构。mongodb文档类似JSON对象,字段的值可以包含其它文档、数组、文档的数组。记录组织成collection,相当于表。参考下图:

使用文档的优点是:文档对应很多编程语言的内生数据对象内嵌文档和数组减少了join的开销动态schema支持顺畅多态关键功能:高性能:mongodb提供高性能数据持久。特别是: 支持内嵌数据模型减少了数据库系统的I/O 索引支持快速查询且内嵌文档和数组可以包含键高可用:mongodb提供高可用的是replica sets 自动失败切换 数据冗余replica set是一组mongodb服务器,它们维护这同一个数据集,提供冗余,增加数据可用性。自动水平扩展:水平扩展是mongodb的内核功能。 在集群上自动共享分布式数据 replica sets能为低延迟,高吞吐量的应用提供最终一致性读。安装:0环境[root@host2 ~]# uname -aLinux host2 2.6.32-504.3.3.el6.x86_64 #1 SMP Wed Dec 17 01:55:02 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux[root@host2 ~]# cat /etc/issueCentOS release 6.5 (Final)Kernel \r on an \m1下载:curl -O 2[root@mgdbsvr mongodb]# tar -zxvf mongodb-linux-x86_64-2.6.7.tgz mongodb-linux-x86_64-2.6.7/READMEmongodb-linux-x86_64-2.6.7/THIRD-PARTY-NOTICESmongodb-linux-x86_64-2.6.7/GNU-AGPL-3.0mongodb-linux-x86_64-2.6.7/bin/mongodumpmongodb-linux-x86_64-2.6.7/bin/mongorestoremongodb-linux-x86_64-2.6.7/bin/mongoexportmongodb-linux-x86_64-2.6.7/bin/mongoimportmongodb-linux-x86_64-2.6.7/bin/mongostatmongodb-linux-x86_64-2.6.7/bin/mongotopmongodb-linux-x86_64-2.6.7/bin/mongooplogmongodb-linux-x86_64-2.6.7/bin/mongofilesmongodb-linux-x86_64-2.6.7/bin/bsondumpmongodb-linux-x86_64-2.6.7/bin/mongoperfmongodb-linux-x86_64-2.6.7/bin/mongodmongodb-linux-x86_64-2.6.7/bin/mongosmongodb-linux-x86_64-2.6.7/bin/mongo[root@mgdbsvr mongodb]# 3拷贝的规划的文件夹[root@mgdbsvr mongodb]# mv mongodb-linux-x86_64-2.6.7 /opt/mongodb4配置环境变量[root@mgdbsvr ~]# vi .bash_profilePATH=$PATH:/opt/mongodb/bin5数据所在文件夹[root@mgdbsvr mongodb]# mkdir dbdata6使用户 mongod可以读写数据所在文件夹[root@mgdbsvr mongodb]# useradd -r mongod[root@mgdbsvr mongodb]# chown mongod:mongod dbdata/7启动[root@mgdbsvr mongodb]# mongod –dbpath dbdata2015-02-13T17:56:23.704+0800 [initandlisten] MongoDB starting : pid=2035 port=27017 dbpath=dbdata 64-bit host=mgdbsvr2015-02-13T17:56:23.708+0800 [initandlisten] db version v2.6.72015-02-13T17:56:23.708+0800 [initandlisten] git version: a7d57ad27c382de82e9cb93bf983a80fd9ac98992015-02-13T17:56:23.708+0800 [initandlisten] build info: Linux build7.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_492015-02-13T17:56:23.708+0800 [initandlisten] allocator: tcmalloc2015-02-13T17:56:23.708+0800 [initandlisten] options: { storage: { dbPath: "dbdata" } }2015-02-13T17:56:23.738+0800 [initandlisten] journal dir=dbdata/journal2015-02-13T17:56:23.741+0800 [initandlisten] recover : no journal files present, no recovery needed2015-02-13T17:56:24.520+0800 [initandlisten] preallocateIsFaster=true 13.462015-02-13T17:56:25.273+0800 [initandlisten] preallocateIsFaster=true 12.52015-02-13T17:56:27.166+0800 [initandlisten] preallocateIsFaster=true 8.762015-02-13T17:56:27.166+0800 [initandlisten] preallocateIsFaster check took 3.423 secs2015-02-13T17:56:27.167+0800 [initandlisten] preallocating a journal file dbdata/journal/prealloc.02015-02-13T17:56:30.089+0800 [initandlisten] File Preallocator Progress: 891289600/1073741824 83%2015-02-13T17:56:31.216+0800 [initandlisten] preallocating a journal file dbdata/journal/prealloc.12015-02-13T17:56:34.070+0800 [initandlisten] File Preallocator Progress: 629145600/1073741824 58%2015-02-13T17:56:35.779+0800 [initandlisten] preallocating a journal file dbdata/journal/prealloc.22015-02-13T17:56:38.054+0800 [initandlisten] File Preallocator Progress: 859832320/1073741824 80%2015-02-13T17:56:39.630+0800 [initandlisten] allocating new ns file dbdata/local.ns, filling with zeroes…2015-02-13T17:56:39.762+0800 [FileAllocator] allocating new datafile dbdata/local.0, filling with zeroes…2015-02-13T17:56:39.763+0800 [FileAllocator] creating directory dbdata/_tmp2015-02-13T17:56:39.797+0800 [FileAllocator] done allocating datafile dbdata/local.0, size: 64MB, took 0.002 secs2015-02-13T17:56:39.832+0800 [initandlisten] build index on: local.startup_log properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "local.startup_log" }2015-02-13T17:56:39.855+0800 [initandlisten] added index to empty collection2015-02-13T17:56:39.894+0800 [initandlisten] command local.$cmd command: create { create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0 numYields:0 reslen:37 281ms2015-02-13T17:56:39.897+0800 [initandlisten] waiting for connections on port 270178连接,简单使用[root@mgdbsvr ~]# mongoMongoDB shell version: 2.6.7connecting to: test#查看当前数据库> dbtest#切到数据库 mydb> use mydbswitched to db mydb> dbmydb#用javascript创建两个文档> j = { name : "mongo" }{ "name" : "mongo" }> k = { x : 3 }{ "x" : 3 }#创建mydb数据库和testdata collection> db.testdata.insert(j)WriteResult({ "nInserted" : 1 })> db.testdata.insert(k);WriteResult({ "nInserted" : 1 })> show collectionssystem.indexestestdata> db.testdata.find(){ "_id" : ObjectId("54ddd717d692cfe0bd20d983"), "name" : "mongo" }{ "_id" : ObjectId("54ddd728d692cfe0bd20d984"), "x" : 3 }> > > show dbsadmin (empty)local 0.078GBmydb 0.078GB> > use hahadbswitched to db hahadb> show dbsadmin (empty)local 0.078GBmydb 0.078GB> dbhahadb> j = { name : "mongo" }{ "name" : "mongo" }> show dbsadmin (empty)local 0.078GBmydb 0.078GB> db.testdata.insert(j)WriteResult({ "nInserted" : 1 })> show dbsadmin (empty)hahadb 0.078GBlocal 0.078GBmydb 0.078GB> > use mydbswitched to db mydb> show collectionssystem.indexestestdata> > db.testdata.insert(j)WriteResult({ "nInserted" : 1 })> db.testdata.find(){ "_id" : ObjectId("54ddd717d692cfe0bd20d983"), "name" : "mongo" }{ "_id" : ObjectId("54ddd728d692cfe0bd20d984"), "x" : 3 }{ "_id" : ObjectId("54ddda64d692cfe0bd20d986"), "name" : "mongo" }> db.testdata.insert(k)WriteResult({ "nInserted" : 1 })> > > db.testdata.find(){ "_id" : ObjectId("54ddd717d692cfe0bd20d983"), "name" : "mongo" }{ "_id" : ObjectId("54ddd728d692cfe0bd20d984"), "x" : 3 }{ "_id" : ObjectId("54ddda64d692cfe0bd20d986"), "name" : "mongo" }{ "_id" : ObjectId("54ddda7dd692cfe0bd20d987"), "x" : 3 }> > db.testdata.find({x:3}){ "_id" : ObjectId("54ddd728d692cfe0bd20d984"), "x" : 3 }{ "_id" : ObjectId("54ddda7dd692cfe0bd20d987"), "x" : 3 }> > > exit;[root@mgdbsvr ~]# 参考:

docs.mongodb.org/manual/tutorial/install-mongodb-on-linux/

—————–

转载请著明出处:blog.csdn.net/beiigang

因为有梦,所以勇敢出发,选择出发,便只顾风雨兼程。

mongodb之linux通用二进制包安装

相关文章:

你感兴趣的文章:

标签云: