AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

rs.remove()(mongoshメソッド)

rs.remove(hostname)

hostname パラメーターで記述されたノードを現在のレプリカセットから削除します。この関数は、shell を一時的に切断し、レプリカセットがどのノードをプライマリにするかを再ネゴシエートするときに再接続を強制します。その結果、このコマンドが成功しても、shell はエラーを表示します。

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

Parameter
タイプ
説明

hostname

string

レプリカセット内のシステムのホスト名

注意

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

このメソッドは、次の環境でホストされている配置で使用できます。

  • MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン

  • MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン

Removing a member changes the number of voting members in the replica set, which can change the implicit default write concern.

You must explicitly set the global default write concern before attempting to reconfigure a replica set with a configuration that would change the implicit default write concern. To set the global default write concern, use the setDefaultRWConcern command.

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 がリスニングしていたポートに置き換えます。

このページを評価