Docs HomeMongoDB Manual

The local Databaselocal数据库

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实例上的集合

local.startup_log

On startup, each mongod instance inserts a document into startup_log with diagnostic information about the mongod 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 the startup_log collection contain the following fields:startup_log集合中的文档包含以下字段:

local.startup_log._id

Includes the system hostname and a millisecond epoch value.包括系统主机名和毫秒epoch值。

local.startup_log.hostname

The system's hostname.系统的主机名。

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.pid

The process identifier for this process.此进程的进程标识符。

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() from mongosh. 将副本集的配置对象作为其单个文档。要查看对象的配置信息,请从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 oplogSizeMB setting. 是包含oplog的封顶集合。您可以在创建时使用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 the majority commit point.oplog可以超过其配置的大小限制,以避免删除多数提交点

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支持的指导下完成。

local.replset.minvalid

This contains an object used internally by replica sets to track replication status.其中包含一个由复制副本集内部用于跟踪复制状态的对象。

Restrictions限制

Multi-Document Transactions on locallocal上的多文档事务处理
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数据库中的集合执行写入操作。

Important

The 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 retryWrites=false in the connection string for the MongoDB cluster.要禁用可重试写入,请在MongoDB集群的连接字符串中指定retryWrites=false