Database Manual / Reference / Database Commands / Replication

replSetFreeze (database command数据库命令)

Definition定义

replSetFreeze

The replSetFreeze command prevents a replica set member from seeking election for the specified number of seconds. replSetFreeze命令可防止副本集成员在指定的秒数内寻求选举。Use this command in conjunction with the replSetStepDown command to make a different node in the replica set a primary.将此命令与replSetStepDown命令结合使用,使副本集中的其他节点成为主节点。

Tip

In mongosh, this command can also be run through the rs.freeze() helper method.mongosh中,此命令也可以通过rs.freeze()辅助方法运行。

Helper methods are convenient for mongosh users, but they may not return the same level of information as database commands. 助手方法对mongosh用户来说很方便,但它们可能不会返回与数据库命令相同级别的信息。 In cases where the convenience is not needed or the additional return fields are required, use the database command.如果不需要便利性或需要额外的返回字段,请使用database命令。

Compatibility兼容性

This command is available in deployments hosted in the following environments:此命令在以下环境中托管的部署中可用:

  • MongoDB Enterprise: The subscription-based, self-managed version of MongoDB:MongoDB的基于订阅的自我管理版本
  • MongoDB Community: The source-available, free-to-use, and self-managed version of MongoDB:MongoDB的源代码可用、免费使用和自我管理版本

Important

This command is not supported in MongoDB Atlas clusters. MongoDB Atlas集群不支持此命令。For information on Atlas support for all commands, see Unsupported Commands.有关Atlas支持所有命令的信息,请参阅不支持的命令

Syntax语法

The command has the following syntax:该命令具有以下语法:

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

Behavior行为

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:如果要在指定的秒数过去之前解冻副本集成员,可以发出秒值为0的命令:

db.runCommand(
{
replSetFreeze: 0
}
)

Restarting the mongod process also unfreezes a replica set member.重新启动mongod进程也会解冻副本集成员。

replSetFreeze is an administrative command, and you must issue it against the admin database.是一个管理命令,您必须对admin数据库发出它。