On this page本页内容
rs.remove(hostname)
Removes the member described by the 从当前副本集中删除hostname
parameter from the current replica set. hostname
参数描述的成员。This function will disconnect the shell briefly and forces a reconnection as the replica set renegotiates which member will be primary. 此函数将短暂断开shell连接,并在副本集重新协商哪个成员将是primary
时强制重新连接。As a result, the shell will display an error even if this command succeeds.因此,即使此命令成功,shell也会显示错误。
The rs.remove()
method has the following parameter:rs.remove()
方法具有以下参数:
hostname | string |
Before running the 在运行rs.remove()
operation, it is good practice to shut down the replica set member that you are removing.rs.remove()
操作之前,最好关闭要删除的副本集成员。
By default, replica set members wait for 5 minutes before dropping connections to the removed member. 默认情况下,副本集成员会等待5分钟,然后再断开与已删除成员的连接。In sharded replica sets, you can modify this timeout using the 在分片副本集中,可以使用ShardingTaskExecutorPoolHostTimeoutMS
server parameter.ShardingTaskExecutorPoolHostTimeoutMS
服务器参数修改此超时。
New in version 4.2.在版本4.2中新增。 To immediately drop all outgoing connections from the replica set to the removed member, run the 要立即删除从副本集到已删除成员的所有传出连接,请对副本集上的每个剩余成员运行dropConnections
administrative command on each remaining member on the replica set:dropConnections
管理命令:
db.adminCommand( { "dropConnections" : 1, "hostAndPort" : [ "<hostname>:<port>" ] } )
Replace 将<hostname>
with the hostname of the removed member and <port>
with the port the mongod
listened on.<hostname>
替换为已删除成员的主机名,将<port>
替换为mongod
侦听的端口。