replSetMaintenance

On this page本页内容

Definition定义

replSetMaintenance

The replSetMaintenance admin command enables or disables the maintenance mode for a secondary member of a replica set.replSetMaintenanceadmin命令可启用或禁用副本集辅助成员的维护模式。

The command has the following prototype form:该命令具有以下原型形式:

{ 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 admin database.您必须对admin数据库运行该命令。
  • When enabled replSetMaintenance: true, the member enters the RECOVERING state. 当启用replSetMaintenance: true时,成员将进入RECOVERING状态。While the secondary is RECOVERING:当辅助设备为RECOVERING时:

    • The member is not accessible for read operations.读取操作无法访问该成员。
    • The member continues to sync its oplog from the Primary.成员继续从主服务器同步其oplog
  • When a node receives a replSetMaintenance: true request, 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 RECOVERING state and begin to reject read requests. 如果任务队列是空的,而现在不是空的,则节点将转换到RECOVERING状态并开始拒绝读取请求。When a node receives a replSetMaintenance: false request, it removes a maintenance mode task from the queue (even if that task was initiated by a different client). 当节点接收到replSetMaintenance:false请求时,它会从队列中删除维护模式任务(即使该任务是由其他客户端启动的)。If the request empties the maintenance mode task queue, the node will return to SECONDARY state.如果请求清空维护模式任务队列,则节点将返回SECONDARY状态。
  • If you want to prevent a node from servicing reads, consider using Hidden Replica Set Members instead.如果要阻止节点为读取提供服务,请考虑改用隐藏副本集成员
←  replSetInitiatereplSetReconfig →