정의
rs.reconfigForPSASet( memberIndex, config, { options } )버전 5.0의 신규 항목입니다.
프라이머리-세컨더리-중재자(PSA) 복제본 세트 또는 PSA 아키텍처로 변경되는 복제본 세트에서 일부 재구성 변경을 안전하게 수행합니다. 이 방법은 다음 중 한 가지 경우에만 사용해야 합니다.
기존 3개 멤버로 구성된 PSA 아키텍처의 복제본 세트의 세컨더리 노드를 0이 아닌
priority가 있는 투표 데이터 보유 노드로 재구성하려고 합니다.하나의 투표 데이터 보유 노드 및 하나의 중재자를 포함하는 기존 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단계 접근 방식은 페일오버의 경우 새 세컨더리가 이전 구성의 모든 쓰기를 커밋하기 전에 커밋된 쓰기를 새 세컨더리로 롤백하는 가능성을 방지합니다.
예시
0}이라는 이름의 복제본 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);
두 번째 문은
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") } }