説明
replSetStepDownレプリカセットの プライマリ を セカンダリ になるように指示します。プライマリがステップダウンすると、資格のあるセカンダリでプライマリ選挙が行われます。
コマンドでは、プライマリをすぐにステップダウンするわけではありません。 プライマリと最新の
electableセカンダリがない場合、プライマリはセカンダリが追いつくまで最大secondaryCatchUpPeriodSecs(デフォルトでは 10 秒)待機します。 選択可能なセカンダリが利用可能になると、 コマンドはプライマリを降格します。ステップダウン後は、元のプライマリがセカンダリになり、
replSetStepDown: <seconds>で指定された残りの期間が再びプライマリになることはできません。コマンドの実行について詳しくは、「動作」を参照してください。
注意
このコマンドはプライマリに対してのみ有効であり、プライマリ以外のメンバーで実行するとエラーがスローされます。
Tip
In
mongosh, this command can also be run through thers.stepDown()helper method.Helper methods are convenient for
mongoshusers, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.The
replSetStepDowncan only run on theadmindatabase.
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
重要
このコマンドは、MongoDB Atlas クラスターではサポートされていません。すべてのコマンドに対する Atlas のサポートについては、「サポートされていないコマンド」を参照してください。
構文
このコマンドの構文は、次のとおりです。
db.adminCommand( { replSetStepDown: <seconds>, secondaryCatchUpPeriodSecs: <seconds>, force: <true|false> } )
コマンドフィールド
このコマンドは、次のフィールドを使用します。
フィールド | タイプ | 説明 |
|---|---|---|
| 数値 | プライマリをステップダウンするまでの秒数。この時間中、ステップダウンするノードはプライマリになる資格がありません。数値以外を指定した場合、コマンドは ステップダウン期間は、 |
| 数値 | 任意。 選択可能なセカンダリがプライマリに追いつくまで 指定すると、 |
| ブール値 | 任意。 待機期間内に選択可能で最新のセカンダリが存在しない場合に、プライマリが降格するかどうかを決定するブール値。
デフォルトは |
動作
同時操作
The replSetStepDown command 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 秒)待機します。 ロールバック を防止するために、キャッチアップ期間中にセカンダリがプライマリと最新の状態である場合にのみ、プライマリはステップダウンします。
待機期間の終了までにこの基準を満たす選出可能なセカンダリー候補がいない場合は、プライマリー候補は退任せず、コマンドはエラーとなります。 この動作をオーバーライドして、 force: trueオプションを指定したコマンドを実行すると、プライマリを直ちに降格できます。
プライマリが正常にステップダウンすると、そのノードは、コマンドを受信した時点から始まるreplSetStepDown: <seconds>期間の残りの間、プライマリになることはできません。
クライアント接続
replSetStepDown コマンドによって、すべてのクライアント接続が閉じられるわけではありません。
ステップダウン中の書込み
注意
All writes to the primary fail during the period starting when the replSetStepDown command 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 replSetStepDown 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.
例
デフォルト オプションで降格
次の例では、現在のプライマリで実行すると、メンバーを120秒降格しようとします。
この操作はセカンダリが追いつくまでデフォルトの10秒まで待機します。 適切なセカンダリが存在しない場合は、プライマリは降格せず、コマンドはエラーになります。
注意
All writes to the primary fail during the period starting when the replSetStepDown command 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 replSetStepDown is run are killed. In-progress transactions also fail with TransientTransactionError and can be retried as a whole.
書込みが失敗する最大期間:
secondaryCatchUpPeriodSecs (デフォルトでは 10 秒間) + electionTimeoutMillis(デフォルトでは 10 秒間)。
db.adminCommand( { replSetStepDown: 120 } )
セカンダリ キャッチアップの待機時間を指定する
以下の例では、現在のプライマリで実行すると、メンバーを120秒間降格させ、選択可能なセカンダリが追いつくまで最大15秒待機します。 適切なセカンダリが存在しない場合は、プライマリは降格せず、コマンドはエラーになります。
注意
All writes to the primary fail during the period starting when the replSetStepDown command 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 replSetStepDown is run are killed. In-progress transactions also fail with TransientTransactionError and can be retried as a whole.
書込みが失敗する最大期間:
secondaryCatchUpPeriodSecs (デフォルトでは 10 秒間) + electionTimeoutMillis(デフォルトでは 10 秒間)。
db.adminCommand( { replSetStepDown: 120, secondaryCatchUpPeriodSecs: 15 } )
強制ステップダウンによるセカンダリのキャッチアップを指定する
以下の例では、現在のプライマリで実行すると、メンバーを120秒間降格させ、選択可能なセカンダリが追いつくまで最大15秒待機します。 force: trueオプションのため、適切なセカンダリが存在しない場合でもプライマリは降格します。
注意
All writes to the primary fail during the period starting when the replSetStepDown command 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 replSetStepDown is run are killed. In-progress transactions also fail with TransientTransactionError and can be retried as a whole.
書込みが失敗する最大期間:
secondaryCatchUpPeriodSecs (デフォルトでは 10 秒間) + electionTimeoutMillis(デフォルトでは 10 秒間)。
db.adminCommand( { replSetStepDown: 120, secondaryCatchUpPeriodSecs: 15, force: true } )