replSetMaintenance
定义
replSetMaintenance
The
replSetMaintenance
admin command enables or disables the maintenance mode for a 从节点 member of a 复制集.
兼容性
此命令可用于以下环境中托管的部署:
MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
重要
M 0 、M 2 、M 5和 M 10 + 集群不支持此命令。 有关更多信息,请参阅不支持的命令。
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
该命令具有以下语法:
db.runCommand( { replSetMaintenance: <boolean> } )
行为
Consider the following behavior when running the
replSetMaintenance
command:
You cannot run the command on the Primary.
You must run the command against the
admin
database.When enabled
replSetMaintenance: true
, the member enters theRECOVERING
state. While the secondary isRECOVERING
:The member is not accessible for read operations.
The member continues to sync its oplog from the Primary.
When a node receives a
replSetMaintenance: true
request, it adds a maintenance mode task to a queue of tasks. If the queue of tasks was empty and now is not, the node will transition toRECOVERING
state and begin to reject read requests. When a node receives areplSetMaintenance: false
request, 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 toSECONDARY
state.If you want to prevent a node from servicing reads, consider using 隐藏的副本集成员 instead.