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

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

rs.stepDown(stepDownSecs, secondaryCatchUpPeriodSecs)

レプリカセットの プライマリセカンダリ になるように指示します。プライマリがステップダウンすると、資格のあるセカンダリでプライマリ選挙が行われます。

この方法では、プライマリをすぐにステップダウンするわけではありません。 プライマリと最新の electable セカンダリがない場合、プライマリはセカンダリが追いつくまで最大 secondaryCatchUpPeriodSecs(デフォルトでは 10 秒)待機します。選択可能なセカンダリが利用可能になると、このメソッドはプライマリを降格します。

ステップダウン後は、元のプライマリがセカンダリになり、stepDownSecs で指定された残りの期間が再びプライマリになることはできません。

メソッドの実行について詳しくは、「動作」を参照してください。

注意

このメソッドはプライマリに対してのみ有効であり、プライマリ以外のノードで実行するとエラーがスローされます。

重要

mongosh メソッド

This page documents a mongosh method. This is not the documentation for database commands or language-specific drivers, such as Node.js.

データベースコマンドについては、replSetStepDown コマンドを参照してください。

MongoDB API ドライバーについては、各言語の「MongoDB ドライバーのドキュメント」を参照してください。

The rs.stepDown() method has the following parameters:

Parameter
タイプ
説明

stepDownSecs

数値

プライマリをステップダウンするまでの秒数。この時間中、ステップダウンするノードはプライマリになる資格がありません。数値以外を指定した場合、コマンドは 60 秒を使用します。

ステップダウン期間は、mongod がコマンドを受信した時点から開始されます。ステップダウン期間は secondaryCatchUpPeriodSecs より大きくなければなりません。

secondaryCatchUpPeriodSecs

数値

任意: 選択可能なセカンダリがプライマリに追いつくまで mongod が待機する秒数。

指定すると、secondaryCatchUpPeriodSecs はデフォルトの待機時間である 10 秒を上書きします。

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

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

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

The rs.stepDown() method attempts to terminate long running user operations that block the primary from stepping down, such as an index build, a write operation or a map-reduce job.

次に、このメソッドはキャッチアップ期間を開始し、セカンダリがプライマリと最新の状態になるまで最大 secondaryCatchUpPeriodSeconds(デフォルトでは 10 秒)待機します。ロールバックを防止するために、キャッチアップ期間中にセカンダリがプライマリと最新の状態である場合にのみ、プライマリはステップダウンします。

待機期間の終了までにこの基準を満たす選出可能なセカンダリー候補がいない場合は、プライマリー候補は退任せず、この方法はエラーとなります。

プライマリが正常にステップダウンすると、そのノードは、メソッドを受信した時点から始まる stepDownSecs 期間の残りの間、プライマリになることはできません。

rs.stepDown() メソッドにより、すべてのクライアント接続が閉じられるわけではありません。

注意

All writes to the primary fail during the period starting when the rs.stepDown() method is received until either a new primary is elected, or if there are no electable secondaries, the original primary resumes normal operation.

Writes that were in progress when rs.stepDown() is run are killed. In-progress transactions also fail with TransientTransactionError and can be retried as a whole.

書込みが失敗する最大期間:

secondaryCatchUpPeriodSecs (デフォルトでは 10 秒間) + electionTimeoutMillis(デフォルトでは 10 秒間)。

When you step down a primary using rs.stepDown() or replSetStepDown without setting the force field to true, the stepped-down primary nominates an eligible secondary to call an election immediately.

このページを評価