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

rs.reconfigForPSASet()(mongoshメソッド)

rs.reconfigForPSASet( memberIndex, config, { options } )

バージョン 5.0 の新機能。

プライマリ セカンダリ アービタ(PSA)レプリカセット、または PSA アーキテクチャに変更されているレプリカセットに対して、いくつかの再構成の変更を安全に実行します。 このメソッドは、次のいずれかの場合にのみ使用してください。

警告

追加しているセカンダリが遅延しており、結果のレプリカセットが 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
タイプ
説明

memberIndex

integer

追加または変更されるセカンダリのインデックス。

config

ドキュメント

レプリカセットの新しい構成を指定するドキュメント

force

ブール値

任意

WARNING: Running the rs.reconfigForPSASet() method with force: true is not recommended and can lead to committed writes being rolled back.

使用可能なレプリカセット ノードに新しい構成を強制的に受け入れさせるには、true を指定します。デフォルトは false です。

強制的に再構成すると、"majority" がコミットした書き込みのロールバックなど、予期しない動作や望ましくない動作が発生する可能性があります。

maxTimeMS

integer

任意

Specifies a cumulative time limit in milliseconds for processing each reconfiguration during the rs.reconfigForPSASet() operation. By default, rs.reconfigForPSASet() waits indefinitely for the replica configurations to propagate to a majority of replica set members.

The rs.reconfigForPSASet() method reconfigures your replica set in two steps:

  1. このメソッドは、レプリカセットを再構成して、 { votes: 1, priority: 0 }でセカンダリを追加または変更します。

  2. Once the added or modified secondary has caught up with all committed writes, the method reconfigures the secondary to have the priority specified in the rs.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);
  1. 最初のステートメントは、 rs.conf()メソッドを使用してレプリカセットの現在の構成を含むドキュメントを取得し、そのドキュメントをローカル変数cfgに保存します。

  2. 2 番目のステートメントは、新しいセカンダリをmembers配列に追加します。 この構成では、新しいセカンダリがmemberIndex 1に追加されます。 memberIndexは配列インデックスと同じです。 追加設定については、「レプリカセットの構成設定 」を参照してください。

  3. The last statement calls the rs.reconfigForPSASet() method with the memberIndex 1 and the modified cfg. The memberIndex is the array position of the new member in the members array. 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")
    }
    }
このページを評価