Replica Set Configuration副本集配置
On this page本页内容
You can access the configuration of a replica set using the 您可以使用rs.conf()
method or the replSetGetConfig
command.rs.conf()
方法或replSetGetConfig
命令访问副本集的配置。
To modify the configuration for a replica set, use the 要修改副本集的配置,请使用rs.reconfig()
method, passing a configuration document to the method. rs.reconfig()
方法,将配置文档传递给该方法。See 有关详细信息,请参阅rs.reconfig()
for more information.rs.reconfig()
。
Avoid reconfiguring replica sets that contain members of different MongoDB versions as validation rules may differ across MongoDB versions.避免重新配置包含不同MongoDB版本成员的副本集,因为验证规则可能因MongoDB版本而异。
Replica Set Configuration Document Example副本集配置文档示例
The following document provides a representation of a replica set configuration document. 以下文档提供了副本集配置文档的表示形式。The configuration of your replica set may include only a subset of these settings:复制副本集的配置可能只包括以下设置的一个子集:
{
_id: <string>,
version: <int>,
term: <int>,
protocolVersion: <number>,
writeConcernMajorityJournalDefault: <boolean>,
configsvr: <boolean>,
members: [
{
_id: <int>,
host: <string>,
arbiterOnly: <boolean>,
buildIndexes: <boolean>,
hidden: <boolean>,
priority: <number>,
tags: <document>,
secondaryDelaySecs: <int>,
votes: <number>
},
...
],
settings: {
chainingAllowed : <boolean>,
heartbeatIntervalMillis : <int>,
heartbeatTimeoutSecs: <int>,
electionTimeoutMillis : <int>,
catchUpTimeoutMillis : <int>,
getLastErrorModes : <document>,
getLastErrorDefaults : <document>,
replicaSetId: <ObjectId>
}
}
Replica Set Configuration Fields副本集配置字段
_id
-
Type: string
The name of the replica set.复制副本集的名称。_id
must be identical to the必须与命令行上为replication.replSetName
or the value of--replSet
specified tomongod
on the command line.mongod
指定的replication.replSetName
或--replSet
的值相同。TipSee:请参阅:replSetName
or--replSet
for information on setting the replica set name.replSetName
或--replSet
获取有关设置副本集名称的信息。
version
-
Type: int
An incrementing number used to distinguish revisions of the replica set configuration document from previous iterations of the configuration.一个递增的数字,用于将副本集配置文档的修订与以前的配置迭代区分开来。Changed in version 4.4在版本4.4中更改: Replica set members use:副本集成员使用term
andversion
to achieve consensus on the "newest" replica configuration.term
和version
来就“最新”的副本配置达成共识。When members compare replica configuration documents, the configuration document with a larger当成员比较副本配置文档时,术语较大的配置文档被视为term
is considered the "newest".term
配置文档。If如果term
is the same or absent, the configuration document with the largerversion
is considered "newest".term
相同或不存在,则较大version
的配置文件被视为“最新”。
term
-
Type: int
New in version 4.4.4.4版新增。Only available with featureCompatibilityVersion (fCV) "4.4" or later.仅适用于featureCompatibilityVersion
(fCV) "4.4"或更高版本。An incrementing number used to distinguish revisions of the replica set configuration document from previous iterations of the configuration.一个递增的数字,用于将副本集配置文档的修订与以前的配置迭代区分开来。The配置文档的term
of a configuration document matches the term of the replica set primary which performed the reconfiguration.term
与执行重新配置的primary副本集的术语相匹配。The primary increments its term each time it steps up after winning an election.primary在赢得选举后每增加一次任期。The primary ignores the如果在term
field if set explicitly in thereplSetReconfig
operation.replSetReconfig
操作中显式设置,则primary将忽略term
字段。Issuing a force reconfiguration removes the发布term
field.force
重新配置将删除term
字段。When the primary next issues当primary下一步在没有强制的情况下发出replSetReconfig
without force, it sets theterm
to its own term.replSetReconfig
时,它会将术语设置为自己的术语。Replica set members use副本集成员使用term
andversion
to achieve consensus on the "newest" replica configuration.term
和version
来就“最新”的副本配置达成共识。When members compare replica configuration documents, the configuration document with a larger当成员比较副本配置文档时,term
is considered the "newest".term
较大的配置文档被视为“最新”配置文档。If如果term
is the same or absent, the configuration document with the largerversion
is considered "newest".term
相同或不存在,则较大version
的配置文件被视为“最新”。
configsvr
-
Type: boolean
Default: false
Indicates whether the replica set is used for a sharded cluster's config servers.指示副本集是否用于分片集群的配置服务器。Set to如果副本集用于分片集群的配置服务器,则设置为true
if the replica set is for a sharded cluster's config servers.true
。TipSee also:另请参阅:
protocolVersion
-
Type: number
Default: 1
Starting in 4.0, MongoDB only supports从4.0开始,MongoDB只支持protocolVersion: 1
and no longer supportsprotocolVersion: 0
.protocolVersion: 1
,不再支持protocolVersion: 0
。TipSee also:另请参阅:
writeConcernMajorityJournalDefault
-
Type: boolean
Default: true
Determines the behavior of如果写入关注没有明确指定日志选项{ w: "majority" }
write concern if the write concern does not explicitly specify the journal option j.j
,则确定{ w: "majority" }
写入关注的行为。The following table lists the下表列出了writeConcernMajorityJournalDefault
values and the associated{ w: "majority" }
behavior:writeConcernMajorityJournalDefault
值和相关的{ w: "majority" }
行为:Value值{ w: "majority" }
Behavior行为true
MongoDB acknowledges the write operation after a majority of the voting members have written to the on-disk journal.MongoDB在大多数投票成员向磁盘日志写入内容后确认写入操作。ImportantAll voting members of the replica set must run with journaling when当writeConcernMajorityJournalDefault
istrue
.writeConcernMajorityJournalDefault
为true
时,副本集的所有投票成员都必须运行日志。
If any voting member of a replica set uses the in-memory storage engine, you must set如果副本集的任何投票成员使用内存存储引擎,则必须将writeConcernMajorityJournalDefault
tofalse
.writeConcernMajorityJournalDefault
设置为false
。
If any voting member of a replica set uses the in-memory storage engine and如果副本集的任何投票成员使用内存存储引擎,并且writeConcernMajorityJournalDefault
istrue
,"majority"
write operations may fail.writeConcernMajorityJournalDefault
为true
,则"majority"
写入操作可能会失败。These include operations that inherently use其中包括固有地使用"majority"
write concern, such as thereplSetStepDown
command, or variousmongosh
methods that by default use"majority"
write concern, such as user management methods and role management methods."majority"
写入关注的操作,replSetStepDown
命令,或默认使用"majority"
写入关注的各种mongosh
方法,如用户管理方法和角色管理方法。
Starting in version 4.2 (and 4.0.13 and 3.6.14 ), if a replica set member uses the in-memory storage engine (voting or non-voting) but the replica set has从版本4.2(以及4.0.13和3.6.14)开始,如果副本集成员使用内存存储引擎(投票或非投票),但副本集的writeConcernMajorityJournalDefault
set to true, the replica set member logs a startup warning.writeConcernMajorityJournalDefault
设置为true
,则副本集成员会记录启动警告。false
MongoDB acknowledges the write operation after a majority of the voting members have applied the operation in memory.在大多数投票成员在内存中应用了写操作后,MongoDB确认写操作。WarningIf any voting member of a replica set uses the in-memory storage engine, you must set如果副本集的任何投票成员使用内存存储引擎,则必须将writeConcernMajorityJournalDefault
tofalse
.writeConcernMajorityJournalDefault
设置为false
。
Starting in version 4.2 (and 4.0.13 and 3.6.14 ), if a replica set member uses the in-memory storage engine (voting or non-voting) but the replica set has从版本4.2(以及4.0.13和3.6.14)开始,如果副本集成员使用内存存储引擎(投票或非投票),但副本集的writeConcernMajorityJournalDefault
set to true, the replica set member logs a startup warning.writeConcernMajorityJournalDefault
设置为true
,则副本集成员会记录启动警告。You cannot run transactions on a sharded cluster that has a shard with您不能在具有writeConcernMajorityJournalDefault
set tofalse
(such as a shard with a voting member that uses the in-memory storage engine).writeConcernMajorityJournalDefault
设置为false
的分片(例如具有使用内存存储引擎的投票成员的分片)的分片集群上运行事务。TipSee also:另请参阅:
members
members
-
Type: array
An array of member configuration documents, one for each member of the replica set.一组成员配置文档,副本集中的每个成员一个。Themembers
array is a zero-indexed array.members
数组是一个零索引数组。Each member-specific configuration document can contain the following fields:每个特定于成员的配置文档都可以包含以下字段:members[n]._id
-
Type: integer
An integer identifier for the member in the replica set, unique among all members.副本集中成员的整数标识符,在所有成员中是唯一的。Starting in MongoDB 5.0, values may be any integer value greater than or equal to从MongoDB 5.0开始,值可以是任何大于或等于0
.0
的整数值。Previously, this value was limited to an integer between以前,此值被限制为介于0
and255
inclusive.0
和255
之间(包括0和255)的整数。Each replica set member must have a unique每个副本集成员都必须有一个唯一的_id
._id
。Avoid re-using避免重复使用_id
values even if nomembers[n]
entry is using that_id
in the current configuration._id
值,即使当前配置中没有members[n]
条目使用该_id
。Once set, you cannot change the一旦设置,就不能更改成员的_id
of a member._id
。NoteWhen updating the replica configuration object, access the replica set members in the更新副本配置对象时,请使用数组索引访问members
array with the array index.members
数组中的副本集成员。The array index begins with数组索引以0
. Do not confuse this index value with the value of themembers[n]._id
field in each document in themembers
array.0
开头。不要将此索引值与members
数组中每个文档中的members[n]._id
字段的值混淆。
members[n].host
-
Type: string
The hostname and, if specified, the port number, of the set member.集合成员的主机名和端口号(如果指定)。The hostname name must be resolvable for every host in the replica set.主机名必须可解析为复制集中的每个主机。Warningmembers[n].host
cannot hold a value that resolves to不能保存解析为localhost
or the local interface unless all members of the set are on hosts that resolve tolocalhost
.localhost
或本地接口的值,除非该集合的所有成员都位于解析为localhost
的主机上。
members[n].arbiterOnly
-
Optional.
Type: boolean
Default: false
A boolean that identifies an arbiter.用于标识仲裁器的布尔值。A value of值为true
indicates that the member is an arbiter.true
表示该成员是仲裁人。When using the当使用rs.addArb()
method to add an arbiter, the method automatically setsmembers[n].arbiterOnly
totrue
for the added member.rs.addArb()
方法添加仲裁器时,该方法会为添加的成员自动将members[n].arbiterOnly
设置为true
。For the following MongoDB versions,对于以下MongoDB版本,与带有仲裁器的副本集的pv1
increases the likelihood ofw:1
rollbacks compared topv0
(no longer supported in MongoDB 4.0+) for replica sets with arbiters:pv0
(在MongoDB 4.0+中不再支持)相比,pv1
增加了w:1
回滚的可能性:- MongoDB 3.4.1
- MongoDB 3.4.0
- MongoDB 3.2.11 or earlier
members[n].buildIndexes
-
Optional.
Type: boolean
Default: true
A boolean that indicates whether the一个布尔值,指示mongod
builds indexes on this member.mongod
是否在此成员上构建索引。You can only set this value when adding a member to a replica set.只有在将成员添加到副本集中时,才能设置此值。You cannot change将成员添加到集合后,不能更改members[n].buildIndexes
field after the member has been added to the set.members[n].buildIndexes
字段。To add a member, see要添加成员,请参阅rs.add()
andrs.reconfig()
.rs.add()
和rs.reconfig()
。Do not set to对于从客户端接收查询的false
formongod
instances that receive queries from clients.mongod
实例,不要设置为false
。Setting如果以下所有条件都为buildIndexes
tofalse
may be useful if all the following conditions are true:true
,则将buildIndexes
设置为false
可能很有用:you are only using this instance to perform backups using您仅使用此实例使用mongodump
, andmongodump
执行备份,并且this member will receive no queries, and该成员将不会收到任何查询,并且index creation and maintenance overburdens the host system.索引的创建和维护使主机系统负担过重。
Even if set to即使设置为false
, secondaries will build indexes on the_id
field in order to facilitate operations required for replication.false
,辅助设备也会在_id
字段上构建索引,以便于进行复制所需的操作。WarningIf you set如果将members[n].buildIndexes
tofalse
, you must also setmembers[n].priority
to0
.members[n].buildIndexes
设置为false
,则还必须将members[n].priority
设置为0
。If如果members[n].priority
is not0
, MongoDB will return an error when attempting to add a member withmembers[n].buildIndexes
equal tofalse
.members[n].priority
不为0
,MongoDB在尝试添加members[n].buildIndexes
等于false
的成员时将返回错误。To ensure the member receives no queries, you should make all instances that do not build indexes hidden.为了确保成员不会收到任何查询,应该隐藏所有未生成索引的实例。Other secondaries cannot replicate from a member where如果members[n].buildIndexes
is false.members[n].buildIndexes
为false
,则其他辅助设备无法从该成员进行复制。
members[n].hidden
-
Optional.
Type: boolean
Default: false
When this value is当该值为true
, the replica set hides this instance and does not include the member in the output ofdb.hello()
orhello
.true
时,副本集将隐藏此实例,并且在db.hello()
或hello
的输出中不包括该成员。This prevents read operations (i.e. queries) from ever reaching this host by way of secondary read preference.这将阻止读取操作(即查询)通过secondary读取首选项到达此主机。Hidden members can acknowledge write operations issued with Write Concern.隐藏成员可以确认使用写入关注发出的写入操作。For write operations issued with对于以"majority"
write concern, the member must also be a voting member (i.e.votes
is greater than0
)."majority"
写入关注发布的写入操作,该成员还必须是有投票权的成员(即,votes
大于0
)。TipSee also:另请参阅:
members[n].priority
-
Optional.
Type
: Number between 0 and 1000 for primary/secondary; 0 or 1 for arbiters.:primary/secondary的数字介于0和1000之间;0或1表示仲裁器。Default
: 1.0 for primary/secondary; 0 for arbiters.:primary/secondary为1
;仲裁器为0
。A number that indicates the relative likelihood of a replica set member to become the primary.一个数字,表示复制集成员成为primary的相对可能性。To increase the likelihood that a member becomes the primary, specify a higher要增加成员成为primary的可能性,请为该成员指定更高的priority
value for that member.priority
值。To decrease the likelihood that a member becomes the primary, specify a lower若要降低某个成员成为primary的可能性,请为该成员指定一个priority
value for that member.priority
较低的值。
Changing a member's priority triggers one or more elections.更改成员的优先级会触发一次或多次选举。The election algorithm makes a best-effort attempt to elect the highest-priority member the primary.选举算法尽最大努力来选举最高优先级的成员作为primary。However, a lower-priority member may become the primary even if a higher-priority secondary is available.然而,即使有较高优先级的secondary成员可用,较低优先级的成员也可能成为primary成员。If a lower-priority member becomes the primary, the server continues to periodically call elections until the highest-priority replica set member is the primary.如果优先级较低的成员成为主成员,服务器将继续定期调用选举,直到优先级最高的副本集成员成为主。The frequency at which the elections occur depends on the difference in priority between the elected member and the highest-priority member.选举的频率取决于当选成员和最高优先级成员之间的优先级差异。A member with a priority of优先级为0
cannot become the primary.0
的成员不能成为primary。Non-voting members (meaning members that have无表决权成员(指votes
set to0
) must have a priority of0
.votes
设置为0
的成员)的优先级必须为0
。TipSee also:另请参阅:
members[n].tags
-
Optional.
Type: document
Default: none
Atags
document contains user-defined tag field and value pairs for the replica set member.tags
文档包含复制集成员的用户定义的标记字段和值对。{ "<tag1>": "<string1>", "<tag2>": "<string2>",... }
For read operations, you can specify a tag set in the read preference to direct the operations to replica set member(s) with the specified tag(s).对于读取操作,可以在读取首选项中指定一个标记集,以将操作定向到具有指定标记的副本集成员。For write operations, you can create a customize write concern using对于写入操作,可以使用settings.getLastErrorModes
andsettings.getLastErrorDefaults
.settings.getLastErrorModes
和settings.getLastErrorDefaults
创建自定义写入关注。
For more information, see Configure Replica Set Tag Sets.请参阅配置副本集标记集以了解更多信息。
members[n].secondaryDelaySecs
-
Optional.
Type: integer
Default: 0
The number of seconds "behind" the primary that this replica set member should "lag".此复制集成员应“滞后”于主复制集的秒数。Use this option to create delayed members.使用此选项可以创建延迟成员。Delayed members maintain a copy of the data that reflects the state of the data at some time in the past.延迟成员维护一份数据副本,该副本反映了过去某个时间的数据状态。Delayed members can contribute to acknowledging write operations issued with Write Concern.延迟的成员可能有助于确认写入关注发出的写入操作。However, they return write acknowledgment no earlier than the configured delay value.但是,它们返回的写入确认不早于配置的延迟值。For write operations issued with对于以"majority"
write concern, the member must also be a voting member (i.e.votes
is greater than0
)."majority"
写入关注发布的写入操作,该成员还必须是有投票权的成员(即,votes
大于0
)。TipSee also:另请参阅:
members[n].votes
-
Optional.
Type: integer
Default: 1
The number of votes a server will cast in a replica set election.服务器将在副本集选举中投出的票数。The number of votes each member has is either每个成员的票数要么是1
or0
, and arbiters always have exactly1
vote.1
,要么是0
,仲裁器总是有1
票。Members withpriority
greater than 0 cannot have 0votes
.priority
大于0
的成员不能有0
票。A replica set can have up to 50 members but only 7 voting members.副本集最多可以有50个成员,但只有7个有投票权的成员。If you need more than 7 members in one replica set, set如果一个副本集中需要7个以上的成员,请将其他无投票权成员的members[n].votes
to0
for the additional non-voting members.members[n].votes
设置为0
。Non-voting (i.e.无表决权(即votes
is0
) members must havepriority
of 0.votes
为0
)成员的priority
必须为0
。Starting in MongoDB 5.0, a newly added secondary does not count as a voting member and cannot be elected until it has reached从MongoDB 5.0开始,新添加的secondary不算作投票成员,在达到SECONDARY
state.SECONDARY
状态之前无法当选。Non-voting members cannot acknowledge write operations issued with a无表决权的成员不能承认以"majority"
write concern."majority"
写入关注发出的写入操作。Tip
settings
settings
-
Optional.
Type: document
A document that contains configuration options that apply to the whole replica set.包含应用于整个复制副本集的配置选项的文档。Thesettings
document contain the following fields:settings
文档包含以下字段:settings.chainingAllowed
-
Optional.
Type: boolean
Default: true
In MongoDB 5.0.1, 4.2.15, 4.4.7, and earlier, if在MongoDB 5.0.1、4.2.15、4.4.7及更早版本中,如果settings.chainingAllowed
is:settings.chainingAllowed
为:true
, replica set secondary members can replicate data from other secondary members.true
,副本集secondary成员可以从其他secondary成员复制数据。false
, secondary members can replicate data only from the primary.false
,secondary成员只能从primary复制数据。
Starting in MongoDB 5.0.2, 4.2.16, and 4.4.8:从MongoDB 5.0.2、4.2.16和4.4.8开始:Replica set secondary members can replicate data from other secondary members even if即使settings.chainingAllowed
isfalse
.settings.chainingAllowed
为false
,副本集secondary成员也可以从其他secondary成员复制数据。To override要覆盖settings.chainingAllowed
, set theenableOverrideClusterChainingSetting
server parameter totrue
.settings.chainingAllowed
enableOverrideClusterChainingSetting
服务器参数设置为true
。The default forenableOverrideClusterChainingSetting
isfalse
.enableOverrideClusterChainingSetting
的默认值为false
。
TipSee also:另请参阅:
settings.getLastErrorDefaults
-
Optional.
Type: document
Unavailable starting in MongoDB 5.0.在MongoDB 5.0中启动时不可用。ImportantStarting in MongoDB 5.0, you cannot specify a default write concern with从MongoDB 5.0开始,除了settings.getLastErrorDefaults
other than the default of{ w: 1, wtimeout: 0 }
.{ w: 1, wtimeout: 0 }
的默认值之外,您不能使用settings.getLastErrorDefaults
指定默认写入关注。Instead, use the相反,使用setDefaultRWConcern
command to set the default read or write concern configuration for a replica set or sharded cluster.setDefaultRWConcern
命令为副本集或分片集群设置默认的读或写入关注配置。
settings.getLastErrorModes
-
Optional.
Type: document
A document used to define a custom write concern through the use of用于通过使用members[n].tags
.members[n].tags
来定义自定义写入关注的文档。The custom write concern can provide data-center awareness.自定义写入关注可以提供数据中心意识。{ getLastErrorModes: {
<name of write concern> : { <tag1>: <number>, .... },
...
} }The<number>
refers to the number of different tag values required to satisfy the write concern.<number>
是指满足写入关注所需的不同标记值的数量。For example, the following例如,以下settings.getLastErrorModes
defines a write concern nameddatacenter
that requires the write to propagate to two members whosedc
tag values differ.settings.getLastErrorModes
定义了一个名为datacenter
的写入关注,该问题要求写入传播到dc
标记值不同的两个成员。{ getLastErrorModes: { datacenter: { "dc": 2 } } }
To use the custom write concern, pass in the write concern name to the要使用自定义写入关系,请将写入关系名称传递给w
Option, e.g.w
选项,例如。{ w: "datacenter" }
See Configure Replica Set Tag Sets for more information and example.有关详细信息和示例,请参阅配置副本集标记集。
settings.heartbeatTimeoutSecs
-
Optional.
Type: int
Default: 10
Number of seconds that the replica set members wait for a successful heartbeat from each other.复制副本集成员等待彼此成功发送检测信号的秒数。If a member does not respond in time, other members mark the delinquent member as inaccessible.如果某个成员没有及时响应,其他成员会将该违规成员标记为无法访问。
settings.electionTimeoutMillis
-
Optional.
Type: int
Default: 10000 (10 seconds)
The time limit in milliseconds for detecting when a replica set's primary is unreachable.检测副本集的主副本何时不可访问的时间限制(以毫秒为单位)。This setting controls failover sensitivity when using此设置控制使用protocolVersion: 1
.protocolVersion: 1
时的故障转移敏感性。You can expect the failover timeout to not exceed the value of您可以期望故障转移超时不超过electionTimeoutMillis
.electionTimeoutMillis
的值。Consider the following when selecting a value:选择值时请考虑以下事项:Higher values result in slower failovers but decreased sensitivity to primary node or network slowness or spottiness.较高的值会导致故障切换较慢,但会降低对主节点或网络缓慢或不稳定的敏感性。Lower values result in faster failover but increased sensitivity to primary node or network slowness or spottiness.值越低,故障切换越快,但对主节点或网络速度慢或不稳定的敏感度越高。
The setting only applies when using该设置仅适用于使用protocolVersion: 1
.protocolVersion: 1
的情况。NoteWhen you step down a primary using当您使用rs.stepDown()
orreplSetStepDown
without setting theforce
field totrue
, the stepped-down primary nominates an eligible secondary to call an election immediately.rs.stepDown()
或replSetStepDown
在未将force
字段设置为true
的情况下退出primary时,退出的primary会提名一个合格的secondary立即进行选举。
settings.catchUpTimeoutMillis
-
Optional.
Type: int
Changed in version 3.6.3.6版更改。Default
: -1, infinite catchup time.:-1,无限追赶时间。Time limit in milliseconds for a newly elected primary to sync (catch up) with the other replica set members that may have more recent writes.新选择的主复制集与其他可能有最近写入的复制集成员同步(赶上)的时间限制(以毫秒为单位)。Infinite or high time limits may reduce the amount of data that the other members would need to roll back after an election but may increase the failover time.无限或高时间限制可能会减少其他成员在选举后需要回滚的数据量,但可能会增加故障转移时间。The newly elected primary ends the catchup period early once it is fully caught up with other members of the set. During the catchup period, the newly elected primary is unavailable for writes from clients.新当选的初选一旦完全赶上了其他成员,就提前结束了追赶期。在追赶期间,新选择的主服务器不可用于客户端的写入。Use使用replSetAbortPrimaryCatchUp
to abort the catchup then complete the transition to primary.replSetAbortPrimaryCatchUp
中止追赶,然后完成到主要的转换。The setting only applies when using该设置仅适用于使用protocolVersion: 1
.protocolVersion: 1
的情况。NoteTo downgrade a replica set initiated in version 3.6 to 3.4, change要将3.6版中启动的复制副本集降级到3.4,请将catchUpTimeoutMillis
from-1
to a positive number.catchUpTimeoutMillis
从-1
更改为正数。Failure to change this value to a positive number causes nodes running version 3.4 to neither restart nor join the replica set.未能将此值更改为正数会导致运行版本3.4的节点既不能重新启动也不能加入副本集。
settings.catchUpTakeoverDelayMillis
-
Optional.
Type: int
Default: 30000 (30 seconds)
Time in milliseconds a node waits to initiate a catchup takeover after determining it is ahead of the current primary.节点在确定其领先于当前primary之后等待启动追赶接管的时间(以毫秒为单位)。During a catchup takeover, the node ahead of the current primary initiates an election to become the new primary of the replica set.在追赶接管过程中,当前主节点之前的节点会启动一个选举,以成为副本集的新主节点。After the node initiating the takeover determines that it is ahead of the current primary, it waits the specified number of milliseconds and then verifies the following:在启动接管的节点确定它领先于当前primary之后,它将等待指定的毫秒数,然后验证以下内容:It is still ahead of the current primary,它仍然领先于当前的初级,It is the most up-to-date node among all available nodes,它是所有可用节点中最新的节点,The current primary is currently catching up to it.当前的初选正在赶上它。
Once determining that all of these conditions are met, the node initiating the takeover immediately runs for election.一旦确定满足所有这些条件,发起接管的节点就会立即运行以进行选举。For more information on Replica Set Elections, see Replica Set Elections.有关副本集选举的详细信息,请参阅副本集选举。NoteSetting将catchUpTakeoverDelayMillis
to-1
disables catchup takeover.catchUpTakeoverDelayMillis
设置为-1
将禁用追赶接管。Setting将catchUpTimeoutMillis
to0
disables primary catchup and consequently also catchup takeover.catchUpTimeoutMillis
设置为0
将禁用主追赶,从而也会禁用追赶接管。
settings.heartbeatIntervalMillis
-
Internal use only.
The frequency in milliseconds of the heartbeats.心跳的频率(以毫秒为单位)。
settings.replicaSetId
-
Type: ObjectId
The ObjectId associated with the replica set and automatically created during与副本集关联并在rs.initiate()
orreplSetInitiate
.rs.initiate()
或replSetInitiate
期间自动创建的ObjectId。You cannot change the您无法更改replicaSetId
.replicaSetId
。