Docs 菜单

replSetFreeze

replSetFreeze

The replSetFreeze command prevents a replica set member from seeking election for the specified number of seconds. Use this command in conjunction with the replSetStepDown command to make a different node in the replica set a primary.

提示

mongosh 中,该命令也可通过 rs.freeze() 辅助方法运行。

辅助方法对 mongosh 用户来说很方便,但它们返回的信息级别可能与数据库命令不同。如果不追求方便或需要额外的返回字段,请使用数据库命令。

此命令可用于以下环境中托管的部署:

重要

M0 、M2 、M5 、M10 + 和 Flex 集群不支持此命令。有关更多信息,请参阅不支持的命令。

该命令具有以下语法:

db.runCommand(
{
replSetFreeze: <seconds>
}
)

If you want to unfreeze a replica set member before the specified number of seconds has elapsed, you can issue the command with a seconds value of 0:

db.runCommand(
{
replSetFreeze: 0
}
)

Restarting the mongod process also unfreezes a replica set member.

replSetFreeze is an administrative command, and you must issue it against the 管理库.