《MongoDB管理与开发精要》这一书实战性极强
以下在Mac系统中运行
1、启动mongoDB命令:/software/mongodb/bin/mongod --dbpath=/software/mongodb/data/db --logpath=/software/mongodb/logs/mongodb.log
2、停止mongoDB可以直接按ctrl+c,可也以通过/software/mongodb/bin/mongo --port 27017 然后输入use admin 然后再执行db.shutdownServer()
/software/mongodb/bin/mongo --port 27017 客户端连接到数据库
3、数据增删查发操作
//连接test数据库
bteki-MacBook-Pro:mongodb b$ bin/mongo
MongoDB shell version: 2.2.2
connecting to: test
> j={name:"mongo"};
{ "name" : "mongo" }
> t={x:3};
{ "x" : 3 }
> db.things.save(j);
> db.things.save(t);
> db.things.find();
{ "_id" : ObjectId("513e9023e1cf5189d96d383b"), "name" : "mongo" }
{ "_id" : ObjectId("513e9032e1cf5189d96d383c"), "x" : 3 }
> for (var i=1;i<10;i++) db.things.save({x:4,j:i});
> db.things.find();
{ "_id" : ObjectId("513e9023e1cf5189d96d383b"), "name" : "mongo" }
{ "_id" : ObjectId("513e9032e1cf5189d96d383c"), "x" : 3 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383d"), "x" : 4, "j" : 1 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383e"), "x" : 4, "j" : 2 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383f"), "x" : 4, "j" : 3 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3840"), "x" : 4, "j" : 4 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3841"), "x" : 4, "j" : 5 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3842"), "x" : 4, "j" : 6 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3843"), "x" : 4, "j" : 7 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3844"), "x" : 4, "j" : 8 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3845"), "x" : 4, "j" : 9 }
> db.c1.find();
> var cursor=db.things.find();
> while (cursor.hasNext()) printjson(cursor.next());
{ "_id" : ObjectId("513e9023e1cf5189d96d383b"), "name" : "mongo" }
{ "_id" : ObjectId("513e9032e1cf5189d96d383c"), "x" : 3 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383d"), "x" : 4, "j" : 1 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383e"), "x" : 4, "j" : 2 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383f"), "x" : 4, "j" : 3 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3840"), "x" : 4, "j" : 4 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3841"), "x" : 4, "j" : 5 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3842"), "x" : 4, "j" : 6 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3843"), "x" : 4, "j" : 7 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3844"), "x" : 4, "j" : 8 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3845"), "x" : 4, "j" : 9 }
> printjson(cursor[4]);
undefined
> var cursor=db.things.find();
> printjson(cursor[4]);
{ "_id" : ObjectId("513e90d7e1cf5189d96d383f"), "x" : 4, "j" : 3 }
> var arr = db.things.find().toArray();
> arr[5];
{ "_id" : ObjectId("513e90d7e1cf5189d96d3840"), "x" : 4, "j" : 4 }
> db.things.find({x:4}).forEach(printjson);
{ "_id" : ObjectId("513e90d7e1cf5189d96d383d"), "x" : 4, "j" : 1 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383e"), "x" : 4, "j" : 2 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383f"), "x" : 4, "j" : 3 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3840"), "x" : 4, "j" : 4 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3841"), "x" : 4, "j" : 5 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3842"), "x" : 4, "j" : 6 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3843"), "x" : 4, "j" : 7 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3844"), "x" : 4, "j" : 8 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3845"), "x" : 4, "j" : 9 }
> db.things.find({x:4}).forEach(printjson);
{ "_id" : ObjectId("513e90d7e1cf5189d96d383d"), "x" : 4, "j" : 1 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383e"), "x" : 4, "j" : 2 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383f"), "x" : 4, "j" : 3 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3840"), "x" : 4, "j" : 4 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3841"), "x" : 4, "j" : 5 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3842"), "x" : 4, "j" : 6 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3843"), "x" : 4, "j" : 7 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3844"), "x" : 4, "j" : 8 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3845"), "x" : 4, "j" : 9 }
> db.things.find(x:4).forEach(pringjson);
Tue Mar 12 10:26:13 SyntaxError: missing ) after argument list (shell):1
> db.things.find({x:4}).forEach(pringjson);
Tue Mar 12 10:26:26 ReferenceError: pringjson is not defined (shell):1
> db.things.find({x:4}).forEach(printjson);
{ "_id" : ObjectId("513e90d7e1cf5189d96d383d"), "x" : 4, "j" : 1 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383e"), "x" : 4, "j" : 2 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383f"), "x" : 4, "j" : 3 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3840"), "x" : 4, "j" : 4 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3841"), "x" : 4, "j" : 5 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3842"), "x" : 4, "j" : 6 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3843"), "x" : 4, "j" : 7 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3844"), "x" : 4, "j" : 8 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3845"), "x" : 4, "j" : 9 }
> printjosn(db.things.findOne({name:"mongo"}));
Tue Mar 12 10:27:10 ReferenceError: printjosn is not defined (shell):1
> printjson(db.things.findOne({name:"mongo"}));
{ "_id" : ObjectId("513e9023e1cf5189d96d383b"), "name" : "mongo" }
> db.things.find().limit(3);
{ "_id" : ObjectId("513e9023e1cf5189d96d383b"), "name" : "mongo" }
{ "_id" : ObjectId("513e9032e1cf5189d96d383c"), "x" : 3 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383d"), "x" : 4, "j" : 1 }
> history
Tue Mar 12 10:29:33 ReferenceError: history is not defined (shell):1
> db.things.update({name:"mongo"},{$set:{name:"mongo_new"}});
> db.things.find();
{ "_id" : ObjectId("513e9032e1cf5189d96d383c"), "x" : 3 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383d"), "x" : 4, "j" : 1 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383e"), "x" : 4, "j" : 2 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383f"), "x" : 4, "j" : 3 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3840"), "x" : 4, "j" : 4 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3841"), "x" : 4, "j" : 5 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3842"), "x" : 4, "j" : 6 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3843"), "x" : 4, "j" : 7 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3844"), "x" : 4, "j" : 8 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3845"), "x" : 4, "j" : 9 }
{ "_id" : ObjectId("513e9023e1cf5189d96d383b"), "name" : "mongo_new" }
> db.things.remove({name:"mongo_new"});
> db.things.find();
{ "_id" : ObjectId("513e9032e1cf5189d96d383c"), "x" : 3 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383d"), "x" : 4, "j" : 1 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383e"), "x" : 4, "j" : 2 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d383f"), "x" : 4, "j" : 3 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3840"), "x" : 4, "j" : 4 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3841"), "x" : 4, "j" : 5 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3842"), "x" : 4, "j" : 6 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3843"), "x" : 4, "j" : 7 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3844"), "x" : 4, "j" : 8 }
{ "_id" : ObjectId("513e90d7e1cf5189d96d3845"), "x" : 4, "j" : 9 }
->use Admin (切换到创建用户)
->db.TestDb (创建数据库)
->db.addUser(“userName”,”Pwd”) 创建用户
->db.auth(“userName”,”Pwd”) 设置用户为允许连接的用户
->db.createCollection(“TableName”) 创建表
->show collections 查看表是否创建成功
->db.TableName.Save({age:1}) 添加数据
->db.TableName.find() 查看添加的数据是否成功
//创建表时可设表大小
> db.createCollection("mycoll",{capped:true,size:100000});
{ "ok" : 1 }
> db.mycoll.isCapped();
true
> db.students.isCapped();
false
//把表转换成上限形式
> db.runCommand({"convertToCapped":"students",size:100000});
{ "ok" : 1 }
> db.students.isCapped();
true
4、存储过程
//名称为addNumbers存储过程
> db.system.js.save({_id:"addNumbers",value:function(x,y){return x+y;}});
> db.eval('addNumbers(3,4.2)');
7.2
5、索引
//创建索引
> db.students.ensureIndex({age:1});
//查询索引
> db.students.getIndexes()
//删除索引
> db.students.dropIndex({age:1})
//重建索引(在collection大量删除的时候,磁盘空间并不会自动回收,长期这样会产生大量的磁盘碎片,影响磁盘读取性能,所以数据索引需要周期性地重建)
> db.students.reIndex()
//对数据库中所有需要回收空间的表重建索引
> db.repairDatabase()
//explain查看执行计划
> db.students.find({age:{$lt:30}}).explain()
6、优化器Profiler(0:不开启,1:记录慢命令,2:记录所有命令)
//获取当前Profiler级别
> db.getProfilingLevel()
0
//设置Profiler级别
> db.setProfilingLevel(1,20)
{ "was" : 0, "slowms" : 100, "ok" : 1 }
//查找执行时间大于5ms的日志
> db.system.profile.find({millis:{$gt:5}})
//使用hint强制要求查询操作使用某个索引
> db.students.find({name:"Tom",age:23}).hint({age:1})
7、性能
//检查服务器运行状态
> db.serverStatus()
//查看特定数据库的详细运行状态,更细粒度地分析故障
> db.stats()
http://127.0.0.1:28017/ ---------可通过Web页面来查看MongoDB运行状态
8、架构
1>主从集群分布布署,复制集
2>读写分离:机制是将那些使cpu及内存消耗严重的操作分离到一台或几台性能很高的机器上,而频繁读取的操作放到几台配置较低的机器上;然后,能过数据同步机制,实现多个数据库之间快速高效地同步数据,从而实现将“读写请求”按实际负载情况进行均衡分布的效果。
3>高性能集群,支持故障转移。
Replica Sets复制集,集群命令步骤:
bteki-MacBook-Pro:mongodbSets b$ mkdir -p data/data/r0 bteki-MacBook-Pro:mongodbSets b$ ls GNU-AGPL-3.0 THIRD-PARTY-NOTICES data README bin bteki-MacBook-Pro:mongodbSets b$ mkdir -p data/data/r1 bteki-MacBook-Pro:mongodbSets b$ mkdir -p data/data/r2 bteki-MacBook-Pro:mongodbSets b$ mkdir -p data/log bteki-MacBook-Pro:mongodbSets b$ mkdir -p data/key bteki-MacBook-Pro:mongodbSets b$ echo "this is rs1 super secret key" > data/key/r0 bteki-MacBook-Pro:mongodbSets b$ echo "this is rs1 super secret key" > data/key/r1 bteki-MacBook-Pro:mongodbSets b$ echo "this is rs1 super secret key" > data/key/r2 bteki-MacBook-Pro:mongodbSets b$ chmod 600 data/key/r* bteki-MacBook-Pro:mongodbSets b$ /software/mongodbSets/bin/mongod --replSet rs1 --keyFile /software/mongodbSets/data/key/r0 --fork --port 28010 --dbpath /software/mongodbSets/data/data/r0 --logpath=/software/mongodbSets/data/log/r0.log --logappend forked process: 8138 all output going to: /software/mongodbSets/data/log/r0.log child process started successfully, parent exiting bteki-MacBook-Pro:mongodbSets b$ /software/mongodbSets/bin/mongod --replSet rs1 --keyFile /software/mongodbSets/data/key/r1 --fork --port 28011 --dbpath /software/mongodbSets/data/data/r1 --logpath=/software/mongodbSets/data/log/r1.log --logappend forked process: 8147 all output going to: /software/mongodbSets/data/log/r1.log child process started successfully, parent exiting bteki-MacBook-Pro:mongodbSets b$ /software/mongodbSets/bin/mongod --replSet rs1 --keyFile /software/mongodbSets/data/key/r2 --fork --port 28012 --dbpath /software/mongodbSets/data/data/r2 --logpath=/software/mongodbSets/data/log/r2.log --logappend forked process: 8150 all output going to: /software/mongodbSets/data/log/r2.log child process started successfully, parent exiting bteki-MacBook-Pro:mongodbSets b$ bin/mongo -port 28010 MongoDB shell version: 2.2.2 connecting to: 127.0.0.1:28010/test > config_rs1={_id:'rs1',members:[ ... {_id:0,host:'localhost:28010'}, ... {_id:1,host:'localhost:28011'}, ... {_id:2,host:'localhost:28012'}]} { "_id" : "rs1", "members" : [ { "_id" : 0, "host" : "localhost:28010" }, { "_id" : 1, "host" : "localhost:28011" }, { "_id" : 2, "host" : "localhost:28012" } ] } > rs.initiate(config_rs1); { "info" : "Config now saved locally. Should come online in about a minute.", "ok" : 1 } > rs.status() { "set" : "rs1", "date" : ISODate("2013-03-13T05:54:33Z"), "myState" : 1, "members" : [ { "_id" : 0, "name" : "localhost:28010", "health" : 1, "state" : 1, "stateStr" : "PRIMARY", "uptime" : 497, "optime" : Timestamp(1363154023000, 1), "optimeDate" : ISODate("2013-03-13T05:53:43Z"), "self" : true }, { "_id" : 1, "name" : "localhost:28011", "health" : 1, "state" : 2, "stateStr" : "SECONDARY", "uptime" : 47, "optime" : Timestamp(1363154023000, 1), "optimeDate" : ISODate("2013-03-13T05:53:43Z"), "lastHeartbeat" : ISODate("2013-03-13T05:54:31Z"), "pingMs" : 509 }, { "_id" : 2, "name" : "localhost:28012", "health" : 1, "state" : 2, "stateStr" : "SECONDARY", "uptime" : 47, "optime" : Timestamp(1363154023000, 1), "optimeDate" : ISODate("2013-03-13T05:53:43Z"), "lastHeartbeat" : ISODate("2013-03-13T05:54:31Z"), "pingMs" : 504 } ], "ok" : 1 } rs1:PRIMARY> //-------------主从操作日志 rs1:PRIMARY> use local switched to db local rs1:PRIMARY> show collections oplog.rs system.replset rs1:PRIMARY> db.oplog.rs.find() { "ts" : Timestamp(1363154023000, 1), "h" : NumberLong(0), "v" : 2, "op" : "n", "ns" : "", "o" : { "msg" : "initiating set" } } rs1:PRIMARY> db.printReplicationInfo() configured oplog size: 183.10546875MB log length start to end: 0secs (0hrs) oplog first event time: Wed Mar 13 2013 13:53:43 GMT+0800 (CST) oplog last event time: Wed Mar 13 2013 13:53:43 GMT+0800 (CST) now: Wed Mar 13 2013 14:01:30 GMT+0800 (CST) rs1:PRIMARY> db.printSlaveReplicationInfo() source: localhost:28011 syncedTo: Wed Mar 13 2013 13:53:43 GMT+0800 (CST) = 535 secs ago (0.15hrs) source: localhost:28012 syncedTo: Wed Mar 13 2013 13:53:43 GMT+0800 (CST) = 535 secs ago (0.15hrs) //----------------主从配置信息 rs1:PRIMARY> db.system.replset.find() { "_id" : "rs1", "version" : 1, "members" : [ { "_id" : 0, "host" : "localhost:28010" }, { "_id" : 1, "host" : "localhost:28011" }, { "_id" : 2, "host" : "localhost:28012" } ] } //----------------管理Replica Sets---主从切换 //28011端口服务 bteki-MacBook-Pro:mongodbSets b$ bin/mongo --port 28011 MongoDB shell version: 2.2.2 connecting to: 127.0.0.1:28011/test rs1:SECONDARY> rs.freeze(30) { "ok" : 1 } rs1:SECONDARY> rs.status() { "set" : "rs1", "date" : ISODate("2013-03-13T06:08:09Z"), "myState" : 2, "syncingTo" : "localhost:28012", "members" : [ { "_id" : 0, "name" : "localhost:28010", "health" : 1, "state" : 2, "stateStr" : "SECONDARY", "uptime" : 854, "optime" : Timestamp(1363154023000, 1), "optimeDate" : ISODate("2013-03-13T05:53:43Z"), "lastHeartbeat" : ISODate("2013-03-13T06:08:08Z"), "pingMs" : 0, "errmsg" : "syncing to: localhost:28012" }, { "_id" : 1, "name" : "localhost:28011", "health" : 1, "state" : 2, "stateStr" : "SECONDARY", "uptime" : 1198, "optime" : Timestamp(1363154023000, 1), "optimeDate" : ISODate("2013-03-13T05:53:43Z"), "errmsg" : "syncing to: localhost:28012", "self" : true }, { "_id" : 2, "name" : "localhost:28012", "health" : 1, "state" : 1, "stateStr" : "PRIMARY", "uptime" : 838, "optime" : Timestamp(1363154023000, 1), "optimeDate" : ISODate("2013-03-13T05:53:43Z"), "lastHeartbeat" : ISODate("2013-03-13T06:08:08Z"), "pingMs" : 0 } ], "ok" : 1 } rs1:SECONDARY> //28010端口服务 rs1:PRIMARY> rs.stepDown(30) Wed Mar 13 14:07:46 DBClientCursor::init call() failed Wed Mar 13 14:07:46 query failed : admin.$cmd { replSetStepDown: 30.0 } to: 127.0.0.1:28010 Wed Mar 13 14:07:46 Error: error doing query: failed src/mongo/shell/collection.js:155 Wed Mar 13 14:07:46 trying reconnect to 127.0.0.1:28010 Wed Mar 13 14:07:46 reconnect 127.0.0.1:28010 ok //---------------读写分离 //主 bteki-MacBook-Pro:mongodbSets b$ bin/mongo -port 28012 MongoDB shell version: 2.2.2 connecting to: 127.0.0.1:28012/test rs1:PRIMARY> db.createCollection("Users") { "ok" : 1 } rs1:PRIMARY> db.Users.insert({"name":"test1",age:20}) rs1:PRIMARY> show collections Users system.indexes rs1:PRIMARY> db.Users.find() { "_id" : ObjectId("51401a2b5b02c26e64cba918"), "name" : "test1", "age" : 20 } rs1:PRIMARY> //从 bteki-MacBook-Pro:mongodbSets b$ bin/mongo -port 28010 MongoDB shell version: 2.2.2 connecting to: 127.0.0.1:28010/test rs1:SECONDARY> show collections Wed Mar 13 14:22:45 uncaught exception: error: { "$err" : "not master and slaveOk=false", "code" : 13435 } rs1:SECONDARY> db.getMongo().setSlaveOk() rs1:SECONDARY> show collections Users system.indexes rs1:SECONDARY> db.Users.find(); { "_id" : ObjectId("51401a2b5b02c26e64cba918"), "name" : "test1", "age" : 20 } //-----------增减节点 //先添加一个28013节点,然后再执行下面语句添加到集群中 rs1:PRIMARY> rs.add("localhost:28013") { "ok" : 1 } //减少、删除节点 rs1:PRIMARY> rs.remove("localhost:28013") //判断是否是主节点(只有主节点才能插入数据操作) rs1:PRIMARY>db.isMaster()4>分片Sharding
相关推荐
mongodb学习笔记资料,从安装到操作库collection 对document的crud 索引 replicaSet sharding 备份与恢复
MongoDB 学习笔记 本文档是 MongoDB 学习笔记,涵盖了 NoSQL、Cache、运行平台等多个方面的知识点。 一、NoSQL 数据库 MongoDB MongoDB 是一个强大、灵活、可扩展性好的文档数据存储器,可以完成大部分关系数据库...
mongodb学习笔记 MongoDB 是一个基于分布式文件存储的开源数据库系统,主要用于处理大量数据的存储和查询。以下是 MongoDB 的一些基本操作和技巧: 插入文档 MongoDB 中可以使用 `insert` 方法来插入文档,例如 ...
本压缩包“mongoDB学习笔记及工具.zip”包含了一些资源,帮助你深入理解和掌握MongoDB的相关知识。 1. **笔记(note.txt)**: 这个文件可能是对MongoDB的基础概念、安装过程、基本操作和进阶特性的详细记录。笔记...
本篇学习笔记将从基础操作到高级功能,详细阐述MongoDB的关键知识点。 首先,MongoDB的基本单元是集合(collection),类似于关系型数据库中的表,而集合中的元素称为文档(document),文档是键值对的集合,类似于...
首先,`mongodb_and_python`学习笔记可能涵盖了如何使用Python编程语言与MongoDB进行交互。Python是常见的MongoDB驱动程序之一,通过PyMongo库,开发者可以方便地执行CRUD(创建、读取、更新、删除)操作,构建复杂...
总结的MongoDB的学习笔记,基本上包括了MongoDB的方方面面,每个知识点,都有示例代码,有需要的朋友,可以下载下来进一步补充完善。
MongoDB 是一种流行的开源、非关系型数据库系统,以其灵活性、高性能和易用性而备受开发者青睐。在本文中,我们将深入探讨 ...在实际项目中,学习和掌握 MongoDB 及其驱动程序能够帮助你更好地应对现代数据存储需求。
MongoDB是一种流行的NoSQL数据库,它的索引机制与传统的关系型数据库类似,旨在提升查询和排序的速度。在MongoDB中,索引对于优化查询性能至关重要,尤其在处理大量数据时。下面将详细介绍MongoDB中不同类型的索引...
MongoDB的GridFS是一个强大的文件存储系统,专为在数据库中存储和检索大量小文件而设计。GridFS将文件拆分为多个数据块(chunk),每个块都有自己的文档存储在`fs.chunks`集合中,而文件元信息则保存在`fs.files`集合...
本文介绍了 MongoDB 的基础使用、技术架构、应用场景、主要特点以及安装步骤。内容涵盖了 MongoDB 的基本操作和配置,深入探讨了其内部技术架构,讨论了适合的应用场景和实际案例,并详细说明了安装过程以帮助读者...
### MongoDB 学习笔记知识点详解 #### 一、MongoDB 命令行基础操作 **1.1 帮助命令** - **help**:显示 MongoDB shell 的基本帮助信息。 - **db.help()**:提供当前数据库的帮助信息。 - **db.mycoll.help()**:...