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
Instanceslocal.startup_log
-
On startup, each启动时,每个mongod
instance inserts a document intostartup_log
with diagnostic information about themongod
instance itself and host information.mongod
实例都会在startup_log
中插入一个文档,其中包含有关mongod
示例本身的诊断信息和主机信息。startup_log
is a capped collection.是一个有上限的集合。This information is primarily useful for diagnostic purposes.这些信息主要用于诊断目的。For example, the following is a prototype of a document from the例如,以下是startup_log
collection: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_log
collection 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一个字符串,用于报告系统本地时区中的startTime
in the system's local time zone.startTime
。
local.startup_log.cmdLine
-
An embedded document that reports the一个嵌入式文档,用于报告mongod
runtime 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.replset
holds 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.rs
is the capped collection that holds the oplog. You set its size at creation using the是包含oplog的封顶集合。您可以在创建时使用oplogSizeMB
setting.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 onlocal
local
上的多文档事务处理You cannot perform read/write operations to the collections in the不能在多文档事务中对local
database inside a multi-document transaction.local
数据库中的集合执行读/写操作。Retryable Writes against针对local
local
的可重试写入-
You cannot perform write operations to collections in the在启用可重试写入的情况下,无法对local
database 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写入local
database 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=false
in the connection string for the MongoDB cluster.retryWrites=false
。