Definition定义
replSetMaintenanceThereplSetMaintenanceadmin command enables or disables the maintenance mode for a secondary member of a replica set.replSetMaintenance管理命令启用或禁用副本集secondary成员的维护模式。
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(
{
replSetMaintenance: <boolean>
}
)Behavior行为
Consider the following behavior when running the 运行replSetMaintenance command:replSetMaintenance命令时,请考虑以下行为:
You cannot run the command on the Primary.您无法在主服务器上运行该命令。You must run the command against the您必须对admindatabase.admin数据库运行该命令。When enabled启用replSetMaintenance: true, the member enters theRECOVERINGstate. While the secondary isRECOVERING:replSetMaintenance:true时,成员将进入RECOVERING状态。当secondary正在恢复时:When a node receives a当节点收到replSetMaintenance: truerequest, it adds a maintenance mode task to a queue of tasks.replSetMaintenance: true请求时,它会将维护模式任务添加到任务队列中。If the queue of tasks was empty and now is not, the node will transition to如果任务队列为空,而现在不是,则节点将转换到RECOVERINGstate and begin to reject read requests.RECOVERING状态并开始拒绝读取请求。When a node receives a当节点收到replSetMaintenance: falserequest, it removes a maintenance mode task from the queue (even if that task was initiated by a different client). If the request empties the maintenance mode task queue, the node will return toSECONDARYstate.replSetMaintenance:false请求时,它会从队列中删除维护模式任务(即使该任务是由其他客户端发起的)。如果请求清空了维护模式任务队列,则节点将返回SECONDARY状态。If you want to prevent a node from servicing reads, consider using Hidden Replica Set Members instead.如果要阻止节点为读取提供服务,请考虑使用隐藏副本集成员。