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

replSetステップダウン(データベースコマンド)

replSetStepDown

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

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

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

コマンドの実行について詳しくは、「動作」を参照してください。

注意

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

Tip

In mongosh, this command can also be run through the rs.stepDown() helper method.

Helper methods are convenient for mongosh users, 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 replSetStepDown can only run on the admin database.

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

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

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

重要

このコマンドは、MongoDB Atlas クラスターではサポートされていません。すべてのコマンドに対する Atlas のサポートについては、「サポートされていないコマンド」を参照してください。

このコマンドの構文は、次のとおりです。

db.adminCommand(
{
replSetStepDown: <seconds>,
secondaryCatchUpPeriodSecs: <seconds>,
force: <true|false>
}
)

このコマンドは、次のフィールドを使用します。

フィールド
タイプ
説明

replSetStepDown

数値

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

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

secondaryCatchUpPeriodSecs

数値

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

指定すると、 secondaryCatchUpPeriodSecs10秒、またはforce: trueの場合は0秒のデフォルトの待機時間を上書きします。

force

ブール値

任意。 待機期間内に選択可能で最新のセカンダリが存在しない場合に、プライマリが降格するかどうかを決定するブール値。

trueの場合、適切なセカンダリ メンバーが存在しない場合でもプライマリは降格します。これにより、レプリケーションラグのあるセカンダリが新しいプライマリになると、ロールバックが発生する可能性があります。

falseの場合、適切な セカンダリ メンバーが存在しない場合にはプライマリは降格せず、 コマンドはエラーを返します。

デフォルトは 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 } )