The local Databaselocal数据库

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

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.包括系统主机名和毫秒时间值。

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. 是包含oplog的封顶集合。You set its size at creation using the oplogSizeMB setting. 您可以使用oplogSizeMB设置在创建时设置其大小。To resize the oplog after replica set initiation, use the Change the Size of the Oplog procedure. 要在复制集启动后调整oplog的大小,请使用更改oplog的大小过程For additional information, see the Oplog Size section.有关更多信息,请参阅Oplog大小部分。

Starting in MongoDB 4.0, the oplog can grow past its configured size limit to avoid deleting the majority commit point.从MongoDB 4.0开始,oplog可以超过其配置的大小限制,以避免删除majority提交点

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.当作为独立实例运行时,只能在MongoDB Support的指导下对oplog执行写操作。

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

←  Troubleshoot Replica SetsReplica Set Member States →