定義
rs.reconfigForPSASet( memberIndex, config, { options } )バージョン 5.0 の新機能。
プライマリ セカンダリ アービタ(PSA)レプリカセット、または PSA アーキテクチャに変更されているレプリカセットに対して、いくつかの再構成の変更を安全に実行します。 このメソッドは、次のいずれかの場合にのみ使用してください。
PSA アーキテクチャを使用して、既存の 3 ノードのレプリカセット内のセカンダリを再構成し、ゼロ以外の
priorityを持つ投票権のあるデータを保持するノードにする場合があります。1 つの投票権を持つデータを保持するノードと 1 件のアービタを含む既存の 2 ノードのレプリカセットに、優先順位が 0 以外の新しい投票権のあるデータを保持するノードを追加する場合。
警告
追加しているセカンダリが遅延しており、結果のレプリカセットが PSA 構成の場合、最初の構成変更によって 、
"majority"で変更をコミットする必要があるノードの数が変更されます。 この場合、コミット ポイントはセカンダリが追いつくまで遅延します。このメソッドの動作の詳細については、「動作」を参照してください。
互換性
このメソッドは、次の環境でホストされている配置で使用できます。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
構文
The rs.reconfigForPSASet() method has the following syntax:
rs.reconfigForPSASet( memberIndex: <num>, config: <configuration>, { "force" : <boolean>, "maxTimeMS" : <int> } )
Parameter | タイプ | 説明 |
|---|---|---|
| integer | 追加または変更されるセカンダリのインデックス。 |
| ドキュメント | レプリカセットの新しい構成を指定するドキュメント。 |
| ブール値 | 任意 WARNING: Running the 使用可能なレプリカセット ノードに新しい構成を強制的に受け入れさせるには、 強制的に再構成すると、 |
| integer | 任意 Specifies a cumulative time limit in milliseconds for processing each reconfiguration during the |
動作
The rs.reconfigForPSASet() method reconfigures your replica set in two steps:
このメソッドは、レプリカセットを再構成して、
{ votes: 1, priority: 0 }でセカンダリを追加または変更します。Once the added or modified secondary has caught up with all committed writes, the method reconfigures the secondary to have the
priorityspecified in thers.reconfigForPSASet()command ({ votes: 1, priority: <num> }).
2 段階のアプローチにより、新しいセカンダリが以前の構成からすべてのコミット済み書込みを完了する前に新しいセカンダリに フェイルオーバー が発生した場合に、コミットされた書込みをロールバックする可能性を回避できます。
例
rs0 という名前のレプリカセットは以下のような構成になっています。
{ "_id" : "rs0", "version" : 1, "term": 1, "members" : [ { "_id" : 0, "host" : "mongodb0.example.net:27017", "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 1, "tags" : {}, "secondaryDelaySecs" : Long("0"), "votes" : 1 }, { "_id" : 2, "host" : "mongodb1.example.net:27017", "arbiterOnly" : true, "buildIndexes" : true, "hidden" : false, "priority" : 0, "tags" : {}, "secondaryDelaySecs" : Long("0"), "votes" : 1 } ], "protocolVersion" : Long("1"), "writeConcernMajorityJournalDefault": true, "settings" : { "chainingAllowed" : true, "heartbeatIntervalMillis" : 2000, "heartbeatTimeoutSecs" : 10, "electionTimeoutMillis" : 10000, "catchUpTimeoutMillis" : 2000, "getLastErrorModes" : {}, "getLastErrorDefaults" : { "w" : 1, "wtimeout" : 0 }, "replicaSetId" : ObjectId("60e6f83923193faa336889d2") } }
The following sequence of operations add a new secondary to the replica set. The operations are issued in the mongosh shell while connected to the primary.
cfg = rs.conf(); cfg["members"] = [ { "_id" : 0, "host" : "mongodb0.example.net:27017", "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 1, "tags" : {}, "secondaryDelaySecs" : Long("0"), "votes" : 1 }, { "_id" : 1, "host" : "mongodb1.example.net:27017", "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 2, "tags" : {}, "secondaryDelaySecs" : Long("0"), "votes" : 1 }, { "_id" : 2, "host" : "mongodb2.example.net:27017", "arbiterOnly" : true, "buildIndexes" : true, "hidden" : false, "priority" : 0, "tags" : {}, "secondaryDelaySecs" : Long("0"), "votes" : 1 } ] rs.reconfigForPSASet(1, cfg);
2 番目のステートメントは、新しいセカンダリを
members配列に追加します。 この構成では、新しいセカンダリがmemberIndex1に追加されます。memberIndexは配列インデックスと同じです。 追加設定については、「レプリカセットの構成設定 」を参照してください。The last statement calls the
rs.reconfigForPSASet()method with thememberIndex1and the modifiedcfg. ThememberIndexis the array position of the new member in themembersarray. Upon successful reconfiguration, the replica set configuration resembles the following:{ "_id" : "rs0", "version" : 1, "term": 1, "members" : [ { "_id" : 0, "host" : "mongodb0.example.net:27017", "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 1, "tags" : {}, "secondaryDelaySecs" : Long("0"), "votes" : 1 }, { "_id" : 1, "host" : "mongodb1.example.net:27017", "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 2, "tags" : {}, "secondaryDelaySecs" : Long("0"), "votes" : 1 }, { "_id" : 2, "host" : "mongodb2.example.net:27017", "arbiterOnly" : true, "buildIndexes" : true, "hidden" : false, "priority" : 0, "tags" : {}, "secondaryDelaySecs" : Long("0"), "votes" : 1 } ], "protocolVersion" : Long("1"), "writeConcernMajorityJournalDefault": true, "settings" : { "chainingAllowed" : true, "heartbeatIntervalMillis" : 2000, "heartbeatTimeoutSecs" : 10, "electionTimeoutMillis" : 10000, "catchUpTimeoutMillis" : 2000, "getLastErrorModes" : {}, "getLastErrorDefaults" : { "w" : 1, "wtimeout" : 0 }, "replicaSetId" : ObjectId("60e6f83923193faa336889d2") } }