The local Databaselocal数据库
local DatabaseOn this page本页内容
Overview概述
Every 每个mongod instance has its own local database, which stores data used in the replication process, and other instance-specific data. mongod实例都有自己的local数据库,该数据库存储复制过程中使用的数据以及其他特定于实例的数据。The local database is invisible to replication: collections in the local database are not replicated.local数据库对复制不可见:local数据库中的集合不会被复制。
Collections on all mongod Instances所有mongod实例上的集合
mongod Instances- local.startup_log
- 
On startup, each启动时,每个mongodinstance inserts a document intostartup_logwith diagnostic information about themongodinstance itself and host information.mongod实例都会在startup_log中插入一个文档,其中包含有关mongod示例本身的诊断信息和主机信息。startup_logis a capped collection.是一个有上限的集合。This information is primarily useful for diagnostic purposes.这些信息主要用于诊断目的。For example, the following is a prototype of a document from the例如,以下是startup_logcollection:startup_log集合中文档的原型:{
 "_id" : "<string>",
 "hostname" : "<string>",
 "startTime" : ISODate("<date>"),
 "startTimeLocal" : "<string>",
 "cmdLine" : {
 "dbpath" : "<path>",
 "<option>" : <value>
 },
 "pid" : <number>,
 "buildinfo" : {
 "version" : "<string>",
 "gitVersion" : "<string>",
 "sysInfo" : "<string>",
 "loaderFlags" : "<string>",
 "compilerFlags" : "<string>",
 "allocator" : "<string>",
 "versionArray" : [ <num>, <num>, <...> ],
 "javascriptEngine" : "<string>",
 "bits" : <number>,
 "debug" : <boolean>,
 "maxBsonObjectSize" : <number>
 }
 }Documents in thestartup_logcollection contain the following fields:startup_log集合中的文档包含以下字段:- local.startup_log.startTime
- 
A UTC ISODate value that reflects when the server started.反映服务器启动时间的UTC ISODate值。
 - local.startup_log.startTimeLocal
- 
A string that reports the一个字符串,用于报告系统本地时区中的startTimein the system's local time zone.startTime。
 - local.startup_log.cmdLine
- 
An embedded document that reports the一个嵌入式文档,用于报告mongodruntime options and their values.mongod运行时选项及其值。
 - local.startup_log.buildinfo
- 
An embedded document that reports information about the build environment and settings used to compile this一个嵌入式文档,报告有关编译此mongod.mongod所用的构建环境和设置的信息。This is the same output as这与buildInfo.buildInfo的输出相同。See请参见buildInfo.buildInfo。
 
Collections on Replica Set Members副本集成员上的集合
- local.system.replset
- 
local.system.replsetholds the replica set's configuration object as its single document. To view the object's configuration information, issue将副本集的配置对象作为其单个文档。要查看对象的配置信息,请从rs.conf()frommongosh.mongosh发出rs.conf()。You can also query this collection directly.您也可以直接查询此集合。
- local.oplog.rs
- 
local.oplog.rsis the capped collection that holds the oplog. You set its size at creation using the是包含oplog的封顶集合。您可以在创建时使用oplogSizeMBsetting.oplogSizeMB设置来设置其大小。To resize the oplog after replica set initiation, use the Change the Size of the Oplog procedure.要在复制集启动后调整操作日志的大小,请使用更改操作日志大小过程。For additional information, see the Oplog Size section.有关其他信息,请参阅操作日志大小部分。The oplog can grow past its configured size limit to avoid deleting theoplog可以超过其配置的大小限制,以避免删除多数提交点。majority commit point.Starting in MongoDB 5.0, it is no longer possible to perform manual write operations to the oplog on a cluster running as a replica set.从MongoDB 5.0开始,在作为副本集运行的集群上,不再可能对oplog执行手动写入操作。Performing write operations to the oplog when running as a standalone instance should only be done with guidance from MongoDB Support.当作为独立实例运行时,对oplog执行写操作只能在MongoDB支持的指导下完成。
Restrictions限制
- Multi-Document Transactions on- local- local上的多文档事务处理
- You cannot perform read/write operations to the collections in the不能在多文档事务中对- localdatabase inside a multi-document transaction.- local数据库中的集合执行读/写操作。
- Retryable Writes against针对- local- local的可重试写入
- 
You cannot perform write operations to collections in the在启用可重试写入的情况下,无法对localdatabase with retryable writes enabled.local数据库中的集合执行写入操作。ImportantThe official MongoDB 4.2-series drivers enable retryable writes by default.MongoDB 4.2系列的官方驱动程序默认启用可重试写入。Applications which write to the写入localdatabase will encounter write errors upon upgrading to 4.2-series drivers unless retryable writes are explicitly disabled.local数据库的应用程序在升级到4.2系列驱动程序时将遇到写入错误,除非明确禁用了可重试写入。To disable retryable writes, specify要禁用可重试写入,请在MongoDB集群的连接字符串中指定retryWrites=falsein the connection string for the MongoDB cluster.retryWrites=false。