对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

rs。 删除()(mongosh方法)

rs.remove(hostname)

从当前副本集中删除由 hostname 参数描述的成员。此函数将短暂断开 Shell 连接,并在副本集重新协商哪个成员为主节点时强制重新连接。所以即使该命令成功执行,Shell 也会显示错误。

The rs.remove() method has the following parameter:

Parameter
类型
说明

hostname

字符串

副本集中系统的主机名。

注意

Before running the rs.remove() operation, it is good practice to shut down the replica set member that you are removing.

此方法可用于以下环境中托管的部署:

删除节点会改变副本集中投票节点的数量,这可能会改变 隐式默认写关注(write concern)。

在尝试使用会改变隐式默认写关注(write concern)的 配置 重新配置一个 副本集 之前,您必须显式设置全局默认 写关注(write concern) 。要设置全局默认写关注(write concern),请使用 setDefaultRWConcern 命令。

rs.remove() runs the replSetReconfig command with a configuration that omits the removed member. The method waits until a majority of voting replica set members install the new replica configuration before it returns success. A voting member is any replica set member where members[n].votes is 1, including arbiters. To learn how replica set members install a new configuration, see Reconfiguration Waits Until a Majority of Members Install the Replica Configuration.

rs.remove() does not accept a maxTimeMS limit. If a majority of voting members never install the new configuration, the operation waits indefinitely.

默认情况下,副本集节点等待 5 分钟,然后再删除到删除的节点的连接。在分片副本集中,您可以使用 ShardingTaskExecutorPoolHostTimeoutMS 服务器参数修改该超时。

要立即删除从副本集到已删除成员的所有传出连接,请对副本集的每个剩余成员运行 dropConnections 管理命令:

db.adminCommand(
{
"dropConnections" : 1,
"hostAndPort" : [
"<hostname>:<port>"
]
}
)

将 <hostname> 替换为已删除成员的主机名,将 <port> 替换为 mongod 监听的端口。

给本页内容打分

在此页面上