- MongoDB官方文档中文版
 - MongoDB用户手册
 - MongoDB简介
 -  安装 MongoDB   
- 安装MongoDB社区版
 - 安装MongoDB企业版
 - 将社区版MongoDB升级到企业版MongoDB
 - 验证MongoDB软件包的完整性
 
 - Mongo Shell
 - 增删改查操作
 - 聚合
 -  数据模式   
- 数据建模介绍
 - 模式验证
 - Data Modeling Concepts
 -  Data Model Examples and Patterns   
- Model Relationships Between Documents
 - Model One-to-One Relationships with Embedded Documents
 - Model One-to-Many Relationships with Embedded Documents
 - Model One-to-Many Relationships with Document References
 - Model Tree Structures
 - Model Tree Structures with Parent References
 - Model Tree Structures with Child References
 - Model Tree Structures with an Array of Ancestors
 - Model Tree Structures with Materialized Paths
 - Model Tree Structures with Nested Sets
 - Model Specific Application Contexts
 - Model Data for Atomic Operations
 - Model Data to Support Keyword Search
 - Model Data for Schema Versioning
 - Model Monetary Data
 - Model Time Data
 - Model Computed Data
 
 - Data Model Reference
 
 - 事务
 -  索引   
- Single Field Indexes
 - Compound Indexes
 - Multikey Indexes
 - Text Indexes
 - Wildcard Indexes
 - 2dsphere Indexes
 - 2d Indexes
 - geoHaystack Indexes
 - Hashed Indexes
 - 索引特性
 - Index Builds on Populated Collections
 - 索引交集
 - Manage Indexes
 - 衡量索引使用
 - Indexing Strategies
 - Indexing Reference
 - 2d索引
 - 2dsphere索引
 - 复合索引
 - geoHaystack索引
 - Hashed 索引
 - 在填充的集合上建立索引
 - 索引参考
 - 索引策略
 - 管理索引
 - 多键索引
 - 单字段索引
 - 文本索引
 - 通配符索引
 
 -  安全   
- 安全检查列表
 - Enable Access Control
 -  身份验证   
- Users
 - Add Users
 - Authentication Mechanisms
 - SCRAM
 - x.509
 - Enterprise Authentication Mechanisms
 - Kerberos Authentication
 - LDAP Proxy Authentication
 - LDAP Authorization
 - Internal/Membership Authentication
 - Deploy Replica Set With Keyfile Authentication
 - Update Replica Set to Keyfile Authentication
 - Update Replica Set to Keyfile Authentication (No Downtime)
 - Rotate Keys for Replica Sets
 - Deploy Sharded Cluster with Keyfile Authentication
 - Update Sharded Cluster to Keyfile Authentication
 - Update Sharded Cluster to Keyfile Authentication (No Downtime)
 - Rotate Keys for Sharded Clusters
 - Use x.509 Certificate for Membership Authentication
 - Upgrade from Keyfile Authentication to x.509 Authentication
 - Rolling Update of x.509 Cluster Certificates that Contain New DN
 
 - Role-Based Access Control
 - TLS/SSL (Transport Encryption)
 - Encryption at Rest
 - Client-Side Field Level Encryption
 - 审计
 - Network and Configuration Hardening
 - Implement Field Level Redaction
 - Security Reference
 - Create a Vulnerability Report
 - Appendix
 - 附录
 - 启用访问控制
 - 网络和配置强化
 - 安全参考
 
 - 改变流
 -  复制集   
- 复制集成员
 - 副本集日志
 - Replica Set Data Synchronization
 - 副本集部署架构
 - Replica Set High Availability
 - Replica Set Read and Write Semantics
 - Replica Set Deployment Tutorials
 - Member Configuration Tutorials
 -  Replica Set Maintenance Tutorials   
- Change the Size of the Oplog
 - Perform Maintenance on Replica Set Members
 - Force a Member to Become Primary
 - Resync a Member of a Replica Set
 - Configure Replica Set Tag Sets
 - Reconfigure a Replica Set with Unavailable Members
 - Manage Chained Replication
 - Change Hostnames in a Replica Set
 - Configure a Secondary’s Sync Target
 
 - Replication Reference
 - 副本集数据同步
 
 -  分片   
- 分片集群组成]
 - 片键
 - 哈希分片
 - 范围分片
 - 部署分片集群
 - 区域
 - Data Partitioning with Chunks
 - Balancer
 -  Administration   
- Config Server Administration
 - Replace a Config Server
 - View Cluster Configuration
 - Restart a Sharded Cluster
 - Migrate a Sharded Cluster to Different Hardware
 - Add Shards to a Cluster
 - Remove Shards from an Existing Sharded Cluster
 - Clear jumbo Flag
 - Back Up Cluster Metadata
 - Convert Sharded Cluster to Replica Set
 - Convert a Replica Set to a Sharded Cluster
 - Convert a Shard Standalone to a Shard Replica Set
 
 - Sharding Reference
 - 分片键
 - Zone
 
 -  管理权限   
- 产品说明
 - Operations Checklist
 - Development Checklist
 - Performance
 - 配置和维护
 - Data Center Awareness
 -  MongoDB Backup Methods   
- Back Up and Restore with Filesystem Snapshots
 - Back Up and Restore with MongoDB Tools
 - Restore a Replica Set from MongoDB Backups
 - Backup and Restore Sharded Clusters
 - Back Up a Sharded Cluster with File System Snapshots
 - Back Up a Sharded Cluster with Database Dumps
 - Schedule Backup Window for Sharded Clusters
 - Restore a Sharded Cluster
 - Recover a Standalone after an Unexpected Shutdown
 
 - Monitoring for MongoDB
 - 开发检查表
 - MogoDB 备份方法
 - 操作检查表
 - MongoDB性能
 
 - 存储
 - 常见问题
 -  参考   
-  Operators   
- Query and Projection Operators
 - Comparison Query Operators
 - Logical Query Operators
 - Element Query Operators
 - Evaluation Query Operators
 - Geospatial Query Operators
 - Array Query Operators
 - Bitwise Query Operators
 - $comment
 - 查询与映射运算符
 - 更新运算符
 - Field Update Operators
 - Array Update Operators
 - Bitwise Update Operator
 - Aggregation Pipeline Stages
 - $addFields (aggregation)
 - $bucket (aggregation)
 - $bucketAuto (aggregation)
 - $collStats (aggregation)
 - $count (aggregation)
 - $currentOp (aggregation)
 - $facet (aggregation)
 - $geoNear (aggregation)
 - $graphLookup (aggregation)
 - $group (aggregation)
 - $indexStats (aggregation)
 - $limit (aggregation)
 - $listLocalSessions
 - $listSessions
 - $lookup (aggregation)
 - $match (aggregation)
 - $merge (aggregation)
 - $out (aggregation)
 - $planCacheStats
 - $project (aggregation)
 - $redact (aggregation)
 - $replaceRoot (aggregation)
 - $replaceWith (aggregation)
 - $sample (aggregation)
 - $set (aggregation)
 - $skip (aggregation)
 - $sort (aggregation)
 - $sortByCount (aggregation)
 - $unionWith (aggregation)
 - $unset (aggregation)
 - $unwind (aggregation)
 - Aggregation Pipeline Operators
 - $sin (aggregation)
 - $abs (aggregation)
 - $slice (aggregation)
 - $accumulator (aggregation)
 - $split (aggregation)
 - $acos (aggregation)
 - $sqrt (aggregation)
 - $acosh (aggregation)
 - $add (aggregation)
 - $addToSet (aggregation)
 - $allElementsTrue (aggregation)
 - $and (aggregation)
 - $anyElementTrue (aggregation)
 - $arrayElemAt (aggregation)
 - $arrayToObject (aggregation)
 - $asin (aggregation)
 - $asinh (aggregation)
 - $sum (aggregation)
 - $atan (aggregation)
 - $atan2 (aggregation)
 - $tan (aggregation)
 - $atanh (aggregation)
 - $avg (aggregation)
 - $binarySize (aggregation)
 - $bsonSize (aggregation)
 - $ceil (aggregation)
 - $toInt (aggregation)
 - $cmp (aggregation)
 - $concat (aggregation)
 - $concatArrays (aggregation)
 - $cond (aggregation)
 - $convert (aggregation)
 - $cos (aggregation)
 - $dateFromParts (aggregation)
 - $dateToParts (aggregation)
 - $type (aggregation)
 - $dateFromString (aggregation)
 - $week (aggregation)
 - $dateToString (aggregation)
 - $year (aggregation)
 - $dayOfMonth (aggregation)
 - $zip (aggregation)
 - $dayOfWeek (aggregation)
 - $dayOfYear (aggregation)
 - $degreesToRadians (aggregation)
 - $divide (aggregation)
 - $eq (aggregation)
 - $exp (aggregation)
 - $filter (aggregation)
 - $first (aggregation accumulator)
 - $first (aggregation)
 - $floor (aggregation)
 - $function (aggregation)
 - $gt (aggregation)
 - $gte (aggregation)
 - $hour (aggregation)
 - $ifNull (aggregation)
 - $in (aggregation)
 - $indexOfArray (aggregation)
 - $indexOfBytes (aggregation)
 - $indexOfCP (aggregation)
 - $isArray (aggregation)
 - $isNumber (aggregation)
 - $isoDayOfWeek (aggregation)
 - $isoWeek (aggregation)
 - $isoWeekYear (aggregation)
 - $last (aggregation accumulator)
 - $last (aggregation)
 - $let (aggregation)
 - $literal (aggregation)
 - $ln (aggregation)
 - $log (aggregation)
 - $log10 (aggregation)
 - $lt (aggregation)
 - $lte (aggregation)
 - $trim (aggregation)
 - $map (aggregation)
 - $max (aggregation)
 - $mergeObjects (aggregation)
 - $meta
 - $min (aggregation)
 - $millisecond (aggregation)
 - $minute (aggregation)
 - $mod (aggregation)
 - $month (aggregation)
 - $multiply (aggregation)
 - $ne (aggregation)
 - $not (aggregation)
 - $objectToArray (aggregation)
 - $or (aggregation)
 - $pow (aggregation)
 - $push (aggregation)
 - $radiansToDegrees (aggregation)
 - $range (aggregation)
 - $reduce (aggregation)
 - $regexFind (aggregation)
 - $regexFindAll (aggregation)
 - $regexMatch (aggregation)
 - $replaceOne (aggregation)
 - $replaceAll (aggregation)
 - $reverseArray (aggregation)
 - $round (aggregation)
 - $rtrim (aggregation)
 - $second (aggregation)
 - $setDifference (aggregation)
 - $setEquals (aggregation)
 - $setIntersection (aggregation)
 - $setIsSubset (aggregation)
 - $setUnion (aggregation)
 - $size (aggregation)
 - $slice (aggregation)
 - $split (aggregation)
 - $sqrt (aggregation)
 - $stdDevPop (aggregation)
 - $stdDevSamp (aggregation)
 - $strcasecmp (aggregation)
 - $strLenBytes (aggregation)
 - $strLenCP (aggregation)
 - $substr (aggregation)
 - $substrBytes (aggregation)
 - $substrCP (aggregation)
 - $subtract (aggregation)
 - $sum (aggregation)
 - $switch (aggregation)
 - $tan (aggregation)
 - $toBool (aggregation)
 - $toDate (aggregation)
 - $toDecimal (aggregation)
 - $toDouble(aggregation)
 - $toInt (aggregation)
 - $toLong (aggregation)
 - $toObjectId (aggregation)
 - $toString (aggregation)
 - $toLower (aggregation)
 - $toUpper (aggregation)
 - $trim (aggregation)
 - $trunc (aggregation)
 - $type (aggregation)
 - $week (aggregation)
 - $year (aggregation)
 - $zip (aggregation)
 - 查询修饰符
 - $comment
 - $explain
 - $hint
 - $max
 - $maxTimeMS
 - $min
 - $orderby
 - $query
 - $returnKey
 - $showDiskLoc
 - $natural
 - 聚合管道操作符
 - $abs (aggregation)
 - $acos (aggregation)
 - $acosh (aggregation)
 - $add (aggregation)
 - $addToSet (aggregation)
 - $and (aggregation)
 - $anyElementTrue (aggregation)
 - $arrayElemAt (aggregation)
 - $arrayToObject (aggregation)
 - $asin (aggregation)
 - $asinh (aggregation)
 - $atan (aggregation)
 - $atan2 (aggregation)
 - $atanh (aggregation)
 - $avg (aggregation)
 - $ceil (aggregation)
 - $cmp (aggregation)
 - $concat (aggregation)
 - $concatArrays (aggregation)
 - $cond (aggregation)
 - $convert (aggregation)
 - $cos (aggregation)
 - $dateFromParts (aggregation)
 - $dateFromString (aggregation)
 - $dateToParts (aggregation)
 - $dateToString (aggregation)
 - $literal (aggregation)
 - 聚合管道阶段
 
 -  数据库命令   
- Aggregation Commands
 - aggregate
 - count
 - distinct
 - mapReduce
 - Geospatial Commands
 - geoSearch
 - Query and Write Operation Commands
 - delete
 - find
 - findAndModify
 - getLastError
 - getMore
 - insert
 - resetError
 - update
 - 查询计划缓存命令
 - planCacheClear
 - planCacheClearFilters
 - planCacheListFilters
 - planCacheSetFilter
 - 认证命令
 - authenticate
 - getnonce
 - logout
 - User Management Commands
 - createUser
 - dropAllUsersFromDatabase
 - dropUser
 - grantRolesToUser
 - revokeRolesFromUser
 - updateUser
 - usersInfo
 - Role Management Commands
 - createRole
 - dropRole
 - dropAllRolesFromDatabase
 - grantPrivilegesToRole
 - grantRolesToRole
 - invalidateUserCache
 - revokePrivilegesFromRole
 - revokeRolesFromRole
 - rolesInfo
 - updateRole
 - Replication Commands
 - applyOps
 - isMaster
 - replSetAbortPrimaryCatchUp
 - replSetFreeze
 - replSetGetConfig
 - replSetGetStatus
 - replSetInitiate
 - replSetMaintenance
 - replSetReconfig
 - replSetResizeOplog
 - replSetStepDown
 - replSetSyncFrom
 - Sharding Commands
 - addShard
 - addShardToZone
 - balancerCollectionStatus
 - balancerStart
 - balancerStatus
 - balancerStop
 - checkShardingIndex
 - clearJumboFlag
 - cleanupOrphaned
 - enableSharding
 - flushRouterConfig
 - getShardMap
 - getShardVersion
 - isdbgrid
 - listShards
 - medianKey
 - moveChunk
 - movePrimary
 - mergeChunks
 - refineCollectionShardKey
 - removeShard
 - removeShardFromZone
 - setShardVersion
 - shardCollection
 - shardingState
 - split
 - splitChunk
 - splitVector
 - unsetSharding
 - updateZoneKeyRange
 - Sessions Commands
 - abortTransaction
 - commitTransaction
 - endSessions
 - killAllSessions
 - killAllSessionsByPattern
 - killSessions
 - refreshSessions
 - startSession
 - Administration Commands
 - cloneCollectionAsCapped
 - collMod
 - compact
 - connPoolSync
 - convertToCapped
 - create
 - createIndexes
 - currentOp
 - drop
 - dropDatabase
 - dropConnections
 - dropIndexes
 - filemd5
 - fsync
 - fsyncUnlock
 - getDefaultRWConcern
 - getParameter
 - killCursors
 - killOp
 - listCollections
 - listDatabases
 - listIndexes
 - logRotate
 - reIndex
 - renameCollection
 - setFeatureCompatibilityVersion
 - setIndexCommitQuorum
 - setParameter
 - setDefaultRWConcern
 - shutdown
 - Diagnostic Commands
 - availableQueryOptions
 - buildInfo
 - collStats
 - connPoolStats
 - connectionStatus
 - cursorInfo
 - dataSize
 - dbHash
 - dbStats
 - diagLogging
 - driverOIDTest
 - explain
 - features
 - getCmdLineOpts
 - getLog
 - hostInfo
 - isSelf
 - listCommands
 - lockInfo
 - netstat
 - ping
 - profile
 - serverStatus
 - shardConnPoolStats
 - top
 - validate
 - whatsmyuri
 - 免费监控命令
 - getFreeMonitoringStatus
 - setFreeMonitoring
 - 数据库命令
 - logApplicationMessage
 - 管理命令
 - 聚合命令
 - 诊断命令
 - 地理空间命令
 - 查询和写操作命令
 - 复制命令
 - 角色管理命令
 - 会话命令
 - 分片命令
 - 用户管理命令
 
 -  mongo Shell 方法   
- Collection Methods
 - db.collection.aggregate()
 - db.collection.bulkWrite()
 - db.collection.copyTo()
 - db.collection.count()
 - db.collection.countDocuments()
 - db.collection.estimatedDocumentCount()
 - db.collection.createIndex()
 - db.collection.createIndexes()
 - db.collection.dataSize()
 - db.collection.deleteOne()
 - db.collection.deleteMany()
 - db.collection.distinct()
 - db.collection.drop()
 - db.collection.dropIndex()
 - db.collection.dropIndexes()
 - db.collection.ensureIndex()
 - db.collection.explain()
 - db.collection.find()
 - db.collection.findAndModify()
 - db.collection.findOne()
 - db.collection.findOneAndDelete()
 - db.collection.findOneAndReplace()
 - db.collection.findOneAndUpdate()
 - db.collection.getIndexes()
 - db.collection.getShardDistribution()
 - db.collection.getShardVersion()
 - db.collection.hideIndex()
 - db.collection.insert()
 - db.collection.insertOne()
 - db.collection.insertMany()
 - db.collection.isCapped()
 - db.collection.latencyStats()
 - db.collection.mapReduce()
 - db.collection.reIndex()
 - db.collection.remove()
 - db.collection.renameCollection()
 - db.collection.replaceOne()
 - db.collection.save()
 - db.collection.stats()
 - db.collection.storageSize()
 - db.collection.totalIndexSize()
 - db.collection.totalSize()
 - db.collection.unhideIndex()
 - db.collection.update()
 - db.collection.updateOne()
 - db.collection.updateMany()
 - db.collection.watch()
 - db.collection.validate()
 - Cursor Methods
 - cursor.addOption()
 - cursor.allowDiskUse()
 - cursor.allowPartialResults()
 - cursor.batchSize()
 - cursor.close()
 - cursor.isClosed()
 - cursor.collation()
 - cursor.comment()
 - cursor.count()
 - cursor.explain()
 - cursor.forEach()
 - cursor.hasNext()
 - cursor.hint()
 - cursor.isExhausted()
 - cursor.itcount()
 - cursor.limit()
 - cursor.map()
 - cursor.max()
 - cursor.maxTimeMS()
 - cursor.min()
 - cursor.next()
 - cursor.noCursorTimeout()
 - cursor.objsLeftInBatch()
 - cursor.pretty()
 - cursor.readConcern()
 - cursor.readPref()
 - cursor.returnKey()
 - cursor.showRecordId()
 - cursor.size()
 - cursor.skip()
 - cursor.sort()
 - cursor.tailable()
 - cursor.toArray()
 - Database Methods
 - db.adminCommand()
 - db.aggregate()
 - db.cloneDatabase()
 - db.commandHelp()
 - db.copyDatabase()
 - db.createCollection()
 - db.createView()
 - db.currentOp()
 - db.dropDatabase()
 - db.eval()
 - db.fsyncLock()
 - db.fsyncUnlock()
 - db.getCollection()
 - db.getCollectionInfos()
 - db.getCollectionNames()
 - db.getLastError()
 - db.getLastErrorObj()
 - db.getLogComponents()
 - db.getMongo()
 - db.getName()
 - db.getProfilingLevel()
 - db.getProfilingStatus()
 - db.getReplicationInfo()
 - db.getSiblingDB()
 - db.help()
 - db.hostInfo()
 - db.isMaster()
 - db.killOp()
 - db.listCommands()
 - db.logout()
 - db.printCollectionStats()
 - db.printReplicationInfo()
 - db.printShardingStatus()
 - db.printSlaveReplicationInfo()
 - db.resetError()
 - db.runCommand()
 - db.serverBuildInfo()
 - db.serverCmdLineOpts()
 - db.serverStatus()
 - db.setLogLevel()
 - db.setProfilingLevel()
 - db.shutdownServer()
 - db.stats()
 - db.version()
 - db.watch()
 - Query Plan Cache Methods
 - db.collection.getPlanCache()
 - PlanCache.clear()
 - PlanCache.clearPlansByQuery()
 - PlanCache.help()
 - PlanCache.list()
 - Bulk Operation Methods
 - db.collection.initializeOrderedBulkOp()
 - db.collection.initializeUnorderedBulkOp()
 - Bulk()
 - Bulk.execute()
 - Bulk.find()
 - Bulk.find.arrayFilters()
 - Bulk.find.collation()
 - Bulk.find.hint()
 - Bulk.find.remove()
 - Bulk.find.removeOne()
 - Bulk.find.replaceOne()
 - Bulk.find.updateOne()
 - Bulk.find.update()
 - Bulk.find.upsert()
 - Bulk.getOperations()
 - Bulk.insert()
 - Bulk.tojson()
 - Bulk.toString()
 - User Management Methods
 - db.auth()
 - db.changeUserPassword()
 - db.createUser()
 - db.dropUser()
 - db.dropAllUsers()
 - db.getUser()
 - db.getUsers()
 - db.grantRolesToUser()
 - db.removeUser()
 - db.revokeRolesFromUser()
 - db.updateUser()
 - passwordPrompt()
 - Role Management Methods
 - db.createRole()
 - db.dropRole()
 - db.dropAllRoles()
 - db.getRole()
 - db.getRoles()
 - db.grantPrivilegesToRole()
 - db.revokePrivilegesFromRole()
 - db.grantRolesToRole()
 - db.revokeRolesFromRole()
 - db.updateRole()
 - Replication Methods
 - rs.add()
 - rs.addArb()
 - rs.conf()
 - rs.freeze()
 - rs.help()
 - rs.initiate()
 - rs.printReplicationInfo()
 - rs.printSlaveReplicationInfo()
 - rs.reconfig()
 - rs.remove()
 - rs.status()
 - rs.stepDown()
 - rs.syncFrom()
 - Sharding Methods
 - sh.addShard()
 - sh.addShardTag()
 - sh.addShardToZone()
 - sh.addTagRange()
 - sh.balancerCollectionStatus()
 - sh.disableBalancing()
 - sh.enableBalancing()
 - sh.disableAutoSplit
 - sh.enableAutoSplit
 - sh.enableSharding()
 - sh.getBalancerHost()
 - sh.getBalancerState()
 - sh.removeTagRange()
 - sh.removeRangeFromZone()
 - sh.help()
 - sh.isBalancerRunning()
 - sh.moveChunk()
 - sh.removeShardTag()
 - sh.removeShardFromZone()
 - sh.setBalancerState()
 - sh.shardCollection()
 - sh.splitAt()
 - sh.splitFind()
 - sh.startBalancer()
 - sh.status()
 - sh.stopBalancer()
 - sh.waitForBalancer()
 - sh.waitForBalancerOff()
 - sh.waitForPingChange()
 - sh.updateZoneKeyRange()
 - convertShardKeyToHashed
 - Free Monitoring Methods
 - db.disableFreeMonitoring()
 - db.enableFreeMonitoring()
 - db.getFreeMonitoringStatus
 - Object Constructors and Methods
 - BulkWriteResult()
 - Date()
 - ObjectId
 - ObjectId.getTimestamp()
 - ObjectId.toString()
 - ObjectId.valueOf()
 - UUID()
 - WriteResult()
 - WriteResult.hasWriteError()
 - WriteResult.hasWriteConcernError()
 - Connection Methods
 - connect()
 - Mongo()
 - Mongo.getDB()
 - Mongo.getReadPrefMode()
 - Mongo.getReadPrefTagSet()
 - Mongo.isCausalConsistency()
 - Mongo.setCausalConsistency()
 - Mongo.setReadPref()
 - Mongo.startSession()
 - Mongo.watch()
 - Session
 - SessionOptions
 - Native Methods
 - cat()
 - cd()
 - copyDbpath()
 - getHostName()
 - getMemInfo()
 - hostname()
 - isInteractive()
 - listFiles()
 - load()
 - ls()
 - md5sumFile()
 - mkdir()
 - pwd()
 - quit()
 - removeFile()
 - resetDbpath()
 - sleep()
 - setVerboseShell()
 - version()
 - _isWindows()
 - _rand()
 - Client-Side Field Level Encryption Methods
 - getKeyVault()
 - KeyVault.createKey()
 - KeyVault.deleteKey()
 - KeyVault.getKey()
 - KeyVault.getKeys()
 - KeyVault.addKeyAlternateName()
 - KeyVault.removeKeyAlternateName()
 - KeyVault.getKeyByAltName()
 - getClientEncryption()
 - ClientEncryption.encrypt()
 - ClientEncryption.decrypt()
 - mongo Shell 方法
 
 - MongoDB Package Components
 - Configuration File Options
 - MongoDB Server Parameters
 - MongoDB Limits and Thresholds
 - Explain Results
 - System Collections
 - 连接字符串URI格式
 - 排序
 - MongoDB的Wire协议
 - 日志消息
 - Exit Codes and Statuses
 - 词汇表
 - 默认的MongoDB端口
 - Default MongoDB Read Concerns/Write Concerns
 - 服务器会话
 - Configuration File Options
 - 默认的MongoDB读/写关注
 - 退出代码和状态
 - MongoDB Limits and Thresholds
 
 -  Operators   
 -  更新说明   
- Release Notes for MongoDB 4.4
 - Release Notes for MongoDB 4.2
 - Release Notes for MongoDB 4.0
 - Release Notes for MongoDB 3.6
 - Release Notes for MongoDB 3.4
 - Release Notes for MongoDB 3.2
 - Release Notes for MongoDB 3.0
 - Release Notes for MongoDB 2.6
 - Release Notes for MongoDB 2.4
 - Release Notes for MongoDB 2.2
 - Release Notes for MongoDB 2.0
 - Release Notes for MongoDB 1.8
 - Release Notes for MongoDB 1.6
 - Release Notes for MongoDB 1.4
 - Release Notes for MongoDB 1.2.x
 - MongoDB Versioning
 
 - 技术支持
 - 开始使用MongoDB开发
 - 联系我们
 - 更多资料
 - 本书使用 GitBook 发布
 
分片
分片
分片是一种把数据分散到许多台计算机中的方法,MongoDB 使用分片技术来部署非常大的数据集,同时支持高吞吐量的数据操作。
大数据库系统与高吞吐量系统对于单机服务器提出了严峻的挑战。比如说高频查询会榨干一台服务器上的CPU时间,而大于单机内存容量的数据集将会占满磁盘的读写吞吐量。
一般寻址系统有两种扩展方式,一种是垂直扩展,一种是水平扩展。
垂直扩展指的是增加单台计算机的性能,例如使用更强劲的CPU、插入更多内存条、或者增加本地存储空间。可用技术中的限制可能会限制单台机器运行给定负载的能力。此外,基于云的提供商根据可用的硬件配置有严格的上限。 因此,垂直扩展有一个实际的最大值。
水平扩展指的是切分系统的数据集,把它们分散到多台服务器组成的集群上,根据日益增长的容量需求来增加服务器的数量,虽然集群每台机器的性能可能不会太高,但他们只需要负责处理总负载的一小部分,将其组织起来后便能提供强劲的数据存取能力,并以此胜过单台高性能高容量的服务器。扩展这种集群的存储性能仅仅需要增加更多的服务器。这样的成本远比把单台服务器升级成一台超级计算机。不过代价就是基础设施和部署维护方面的复杂性增加。
MongoDB 通过分片技术来支持水平扩展。
分片集群
一个分片集群,由以下组件组成:
- shard: 分片,每个分片都包含一个切分的数据子集,并且可以作为复制集部署。
 - mongos: 路由,每个路由作为数据分片和应用程序之间的数据接口,对应用程序来说它可被视为一个单机 MongoDB 服务器。从MongoDB 4.4开始,mongos可以支持对冲读取,以最小化延迟。
 - config server: 配置服务器,配置服务器存储集群的元数据和配置设置。
 
下图描述了分片集群内各组件的交互。 
这是一个用于生产目的分片集群示例图。包含正好3个配置服务器(由复制集组成),1个或多个mongos查询路由,以及至少2个shard。这些shard内部是由复制集组成。
MongoDB在集合层对数据进行分片,将集合数据分布在集群中的各个shard上。
片键(Shard Key)
MongoDB使用片键将集合的文档分布在不同的分片上。片键由文档中的一个字段或多个字段组成。
从 4.4 版本开始,分片集合中的文档可以缺少片键字段。缺少片键字段的文档在跨分片分发时将被视为具有空值,但在路由查询时则不会。有关更多信息,请参阅缺失的片键。
在 4.2 及更早的版本中,片键字段必须存在于分片集合的每个文档中。
在对集合进行分片时,你需要选择一个片键(比如 _id )。
从MongoDB 4.2开始,您可以更新文档的片键值,除非您的片键字段是不可更改的 _id 字段。更多信息请参见更改文档的片键值。
在MongoDB 4.0和更早的版本中,文档的片键字段值是不可改变的。
片键索引
要对一个非空集合分片,该集合必须有一个以片键开始的索引。当对一个空的集合分片时,如果该集合还没有对应指定片键的索引,MongoDB 会自动创建对应的索引。请参阅片键索引。
选择片键
片键的选择会影响分片集群的性能、效率和可扩展性。一个拥有最佳硬件和基础架构的集群可能会因为片键的选择而陷入瓶颈。片键及其支持索引的选择也会影响您的集群可以使用的分片策略。
分块
MongoDB 将分片内的数据分区为chunks。每个分块都有一个基于片键的包含性下限和排他性上限范围(即左闭右开)。
平衡器和均匀分块分布
为了在集群中的所有分片上实现均匀分布的分块,一个平衡器在后台运行,以在分片上迁移分块。
分片的优势
读写速度
MongoDB将读写工作负载分布在分片集群中的各个分片上,允许每个分片处理集群操作的一个子集。读和写工作负载都可以通过添加更多的分片在集群中水平扩展。
对于包含片键或复合片键前缀的查询,mongos可以将查询锁定在特定的分片或分片集合上。这些有针对性的操作通常比向集群中的每个分片广播更有效率。
从 MongoDB 4.4 开始,mongos可以支持对冲读取,以最小化延迟。
存储容量
Sharding将数据分布在集群中的各个分片上,允许每个分片包含集群总数据的一个子集。随着数据集的增长,额外的分片会增加集群的存储容量。
高可用性
将配置服务器和分片部署为副本集,可以提高可用性。
即使一个或多个分片副本集变得完全不可用,分片集群仍可继续执行部分读写。也就是说,虽然无法访问不可用的分片上的数据,但针对可用分片的读或写仍然可以成功。
分片前的考虑因素
分片集群基础架构的要求和复杂性需要仔细规划、执行和维护。
一旦一个集合被分片,MongoDB 不提供任何方法来解除分片的集合。
为了确保集群的性能和效率,在选择片键时必须仔细考虑。请参阅选择片键。
分片有一定的操作要求和限制。请参阅分片集群中的操作限制了解更多信息。
如果查询不包括片键或复合片键的前缀,mongos会执行广播操作,查询分片集群中的所有shard。这些散布/收集查询可能是长期运行的操作。
注意:
如果您与MongoDB签订了有效的支持合同,请考虑联系您的客户代表,以获得分片集群规划和部署方面的帮助。
分片式和非分片式集合
一个数据库可以有混合的分片和未分片集合。分片集合被分割并分布在集群中的各个分片上。未分片的集合存储在一个主片上。每个数据库都有自己的主片。  主片的示意图。主片服务器上包含未分片的集合以及来自分片集合的文档块。图中 Shard A 是主片。
连接到分片 Cluster
您必须连接到 mongos 路由才能与分片集群中的任何集合进行交互。这包括分片和未分片的集合。客户端永远不应该连接到一个单一的分片服务器来执行读或写操作。  应用程序/驱动程序向 mongos 发出对未分片集合以及分片集合的查询的示意图。图中未显示配置服务器。
你可以像连接mongod一样连接到mongos,比如通过mongo shell或MongoDB驱动。
分片策略
MongoDB支持两种分片策略,用于在分片集群之间分发数据。
哈希分片
哈希分片涉及计算片键字段的哈希值。然后,根据散列的片键值为每个分块分配一个范围。
小贴士 MongoDB 在使用哈希索引解析查询时自动计算哈希值。应用程序不需要计算哈希值。
 基于哈希的分割图
虽然一系列文档的片键值可能是 "接近" 的,但它们的哈希值不可能在同一个chunk上。基于哈希值的数据分布有利于数据分布更加均匀,尤其是在片键单调变化的数据集中。
然而,散列分布意味着基于范围的对片键的查询不太可能针对单个shard,从而导致更多的集群范围的广播操作。
更多信息请参见左边目录哈希分片。
范围分片
范围分片涉及根据片键值将数据划分为范围。然后根据片键值为每个分块分配一个范围。  片键值空间划分为更小的范围或块的示意图。
在范围分片中,取值"相近" 的一系列片键更有可能驻留在同一个chunk上。这样就可以进行有针对性的操作,因为 mongos 可以只将操作路由到包含所需数据的分片上。
范围分片的效率取决于选择的片键。考虑不周的片键会导致数据分布不均,这会失去分片的一些好处,或者会造成性能瓶颈。请参阅[基于范围分片的片键选择]。
更多信息请参见左边目录 "范围分片"。
分片集群中的区域
对于跨越多个数据中心的分片集群,区域可以帮助提高数据的定位性。
在分片集群中,您可以根据片键创建划分分片数据的区域。您可以将每个区域与集群中的一个或多个分片相关联。一个分片可以关联任意数量的区域。在平衡集群中,MongoDB仅将一个区域所覆盖的块迁移到与该区域相关联的分片上。
每个区域覆盖一个或多个片键值的范围。一个区域所覆盖的每个范围总是包含它的下边界,而不包含它的上边界。  基于分片集群中区域的数据分布图
为要覆盖的区段定义新范围时,必须使用片键中包含的字段。如果使用复合片键,则范围必须包括片键的前缀。更多信息请参见区块中的片键。
在选择片键时,应考虑到将来可能使用的区域。
小贴士 从MongoDB 4.0.3开始,设置区域和区域范围可以更快地铲除一个空的或不存在的集合。
更多信息请参见分片集群中的区域。
分片中的集合
使用 shardCollection 命令和 collation: { locale: "simple"} 选项,可以对一个有默认collation的集合进行分片。成功的分片需要以下条件。
- 这个集合必须有一个前缀是片键的索引。
 - 索引必须有集合 { locale: "simple" }
 
在创建具有整理功能的新集合时,请确保在保护集合之前满足这些条件。
注意事项 对分片集合的查询继续使用为集合配置的默认整理方式。要使用片键索引的简单整理,请在查询的整理文档中指定{locale: "simple"}。
请参阅shardCollection了解更多关于sharding和co的信息。
关于分片和整理的更多信息,请参见shardCollection。
变化流
从MongoDB 3.6开始,变化流可用于复制集和分片集群。变化流允许应用程序访问实时数据变化,而无需引入尾随oplog的复杂性和风险。应用程序可以使用变化流来订阅一个或多个集合上的所有数据变更。
事务
从MongoDB 4.2开始,随着分布式事务的引入,多文档事务在分片集群上可以使用。 在一个事务提交之前,事务中所做的数据变化在事务外部是不可见的。
但是,当一个事务向多个分片写入时,并不是所有的外部读操作都需要等待提交的事务的结果在各分片中可见。例如,如果一个事务已提交,并且写1在A分片上可见,但写2在B分片上还不可见,那么在读关注 "本地 "的外部读可以在不看到写2的情况下读取写1的结果。
参见
- 事务
 - 生产方面的考虑
 - 生产方面的考虑因素(分片集群)。
 
参见
原文 - Sharding
译者:雪星 (snomiao@gmail.com) 于 2020 秋
校对:征集中!
!本页校对征集中!
请点击页面上方 EDIT THIS PAGE 参与校对。 详见: 贡献指南、 原文链接。
Copyright © 上海锦木信息技术有限公司 all right reserved,powered by Gitbook文件修订时间: 2020-12-18 11:34:57
