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 tosecondaryCatchUpPeriodSecs
(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 theadmin
database.
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
MongoDB Atlas はクラウドでの MongoDB 配置のためのフルマネージド サービスです
重要
このコマンドは、M0 、M2 、M5 、M10 +、および Flex クラスターではサポートされていません。詳細については、「 サポートされていないコマンド 」を参照してください。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
構文
このコマンドの構文は、次のとおりです。
db.adminCommand( { replSetStepDown: <seconds>, secondaryCatchUpPeriodSecs: <seconds>, force: <true|false> } )
コマンドフィールド
このコマンドは、次のフィールドを使用します。
フィールド | タイプ | 説明 |
---|---|---|
| 数値 | プライマリをステップダウンするまでの秒数。この時間中、ステップダウンするノードはプライマリになる資格がありません。数値以外を指定した場合、コマンドは ステップダウン期間は、 |
| 数値 | Optional. The number of seconds that the When specified, |
| ブール値 | Optional. A boolean that determines whether the primary steps down if no electable and up-to-date secondary exists within the wait period. If If デフォルトは |
動作
同時操作
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.
例
Step Down with Default Options
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 } )
Specify Wait Time for Secondary Catch Up
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 } )
Specify Secondary Catch Up with Force Step Down
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 } )
以下も参照してください。