Docs Menu

replSetstepDown

replSetStepDown

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

The command does not immediately step down the primary. If no electable secondaries are up to date with the primary, the primary waits up to secondaryCatchUpPeriodSecs (by default 10 seconds) for a secondary to catch up. Once an electable secondary is available, the command steps down the primary.

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

For a detailed explanation of the command 's execution, see 動作.

注意

The command is only valid against the primary and throws an error if run on a non-primary member.

Tip

mongoshでは、このコマンドはrs.stepDown()ヘルパー メソッドを通じて実行することもできます。

ヘルパー メソッドはmongoshユーザーには便利ですが、データベースコマンドと同じレベルの情報は返されない可能性があります。 便宜上必要ない場合、または追加の戻りフィールドが必要な場合は、 データベースコマンドを使用します。

The replSetStepDown can only run on the admin database.

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

  • MongoDB Atlas はクラウドでの MongoDB 配置のためのフルマネージド サービスです

重要

このコマンドは、M0 、M2 、M5 、M10 +、および Flex クラスターではサポートされていません。詳細については、「 サポートされていないコマンド 」を参照してください。

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

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

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

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

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

フィールド
タイプ
説明

replSetStepDown

数値

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

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

secondaryCatchUpPeriodSecs

数値

Optional. The number of seconds that the mongod will wait for an electable secondary to catch up to the primary.

When specified, secondaryCatchUpPeriodSecs overrides the default wait time of either 10 seconds or if force: true, 0 seconds.

force

ブール値

Optional. A boolean that determines whether the primary steps down if no electable and up-to-date secondary exists within the wait period.

If true, the primary steps down even if no suitable secondary member exists; this could lead to rollbacks if a secondary with replication lag becomes the new primary.

If false, the primary does not step down if no suitable secondary member exists and the command returns an error.

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

The command then initiates a catchup period where it waits up to secondaryCatchUpPeriodSeconds, by default 10 seconds, for a secondary to become up-to-date with the primary. The primary only steps down if a secondary is up-to-date with the primary during the catchup period to prevent rollbacks.

If no electable secondary meets this criterion by the end of the waiting period, the primary does not step down and the command errors. You can override this behavior and issue with command with the force: true option to immediately step down the primary.

Once the primary steps down successfully, that node cannot become the primary for the remainder of the replSetStepDown: <seconds> period, which began when the node received the command.

replSetStepDown command doesn't close all client connections.

注意

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.

replSetStepDownの実行時に進行中であった書込みは強制終了されます。 進行中のトランザクションTransientTransactionErrorで失敗し、全体が再試行できます。

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

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.

The following example, run on the current primary, attempts to step down the member for 120 seconds.

The operation waits up to the default 10 seconds for a secondary to catch up. If no suitable secondary exists, the primary does not step down and the command errors.

注意

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.

replSetStepDownの実行時に進行中であった書込みは強制終了されます。 進行中のトランザクションTransientTransactionErrorで失敗し、全体が再試行できます。

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

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

db.adminCommand( { replSetStepDown: 120 } )

The following example, run on the current primary, attempts to step down the member for 120 seconds, waiting up to 15 seconds for an electable secondary to catch up. If no suitable secondary exists, the primary does not step down and the command errors.

注意

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.

replSetStepDownの実行時に進行中であった書込みは強制終了されます。 進行中のトランザクションTransientTransactionErrorで失敗し、全体が再試行できます。

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

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

db.adminCommand( { replSetStepDown: 120, secondaryCatchUpPeriodSecs: 15 } )

The following example, run on the current primary, attempts to step down the member for 120 seconds, waiting up to 15 seconds for an electable secondary to catch up. Because of the force: true option, the primary steps down even if no suitable secondary exists.

注意

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.

replSetStepDownの実行時に進行中であった書込みは強制終了されます。 進行中のトランザクションTransientTransactionErrorで失敗し、全体が再試行できます。

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

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

db.adminCommand( { replSetStepDown: 120, secondaryCatchUpPeriodSecs: 15, force: true } )

以下も参照してください。