복제 프로세스가 너무 늦어져 복제본 세트 멤버아 아직 복제하지 못한 oplog를 프라이머리가 덮어쓰면 복제본 세트 멤버는 '부실' 상태가 됩니다. 멤버는 이를 따라잡을 수 없고 '부실' 상태가 됩니다. 이 경우 해당 멤버의 데이터를 제거하고 초기 동기화를 수행하여 멤버를 완전히 다시 동기화해야 합니다.
멤버를 동기화할 때 시스템이 데이터를 대량으로 이동할 수 있는 대역폭을 보유한 시간을 선택합니다. 사용량이 적은 시간이나 유지 관리 기간 동안 동기화를 예약합니다.
이 작업에 대하여
다음 시나리오 중 하나에 해당하는 경우 이 페이지의 절차를 사용하여 복제 세트 멤버를 복원하십시오.
복제 세트에 새 노드를 추가합니다. 인스턴스에 데이터가 없는 경우, 자체 관리형 복제 세트에 멤버 추가 절차에 따라 복제 세트에 새 멤버를 추가하십시오. 기존 멤버를 재구축하지 않고 호스트 이름을 변경하려면 자체 관리형 복제 세트 멤버 교체를 참조하십시오.
기존의 오래된 멤버를 재구축합니다. 인스턴스가 이미 복제 세트에 속해 있지만 오래되었거나 누락된 데이터가 있는 경우, 멤버 자동 동기화를 참조하십시오. 이 옵션은 데이터를 교체하는 데 시간이 더 오래 걸릴 수 있습니다.
복사한 데이터 파일을 사용하여 멤버를 다시 동기화합니다. 복제 세트의 다른 멤버에서 최근 데이터 디렉터리를 복사하려면 다른 멤버에서 데이터 파일을 복사하여 동기화를 참조하세요. 이 옵션은 데이터를 더 빠르게 교체하지만 수동 작업이 더 많이 필요합니다.
롤링 초기 동기화를 수행하십시오. 복제 세트의 모든 멤버를 한 번에 하나씩 다시 동기화하려면 롤링 초기 동기화 수행을 참조하십시오.
고려 사항
복제 세트에서 가장 최신 멤버를 동기화 소스로 사용하십시오. 동기화 소스에 오래된 데이터가 있는 경우, 재동기화된 멤버에서 대부분 커밋된 쓰기 작업이 손실되어 데이터 손실이 발생할 수 있습니다.
If you resync more than one member, resync the most out-of-date secondary first. In most cases, the data-bearing secondary with the highest replication lag is the most out-of-date. Use
rs.printSecondaryReplicationInfo()to check replication lag.복제 세트가 투표 과반수를 잃는 것을 방지하려면 한 번에 두 개 이상의 복제 세트 멤버를 다시 동기화하지 마십시오.
If you copy data files, ensure that your copy includes the content of the
localdatabase.
멤버 자동 동기화
이 절차는 멤버의 기존 데이터를 삭제합니다. 그런 다음 멤버는 일반적인 초기 동기화 프로세스를 통해 다른 멤버로부터 데이터를 복원합니다. 해당 프로세스에 대한 개요는 복제 세트 데이터 동기화를 참조하십시오.
초기 동기화 작업은 세트의 다른 멤버에 영향을 미치고 소스 멤버에 추가 트래픽을 발생시킬 수 있습니다. 동기화하는 멤버는 연결 가능하고 최신 상태인 세트의 다른 멤버가 필요합니다.
복제 세트에서 해당 멤버를 제거합니다.
Use rs.remove() to remove the member. Wait for the method to return successfully. If the method times out, do not continue until the new configuration has been installed on a majority of voting members. To learn more, see Reconfiguration Waits Until a Majority of Members Install the Replica Configuration.
Stop the member's mongod instance.
To ensure a clean shutdown, use the db.shutdownServer() method from mongosh or, on Linux systems, the mongod --shutdown option.
(선택 사항) 회원의 데이터 디렉토리를 백업합니다.
Make a backup of all data and sub-directories from the member's dbPath directory. If a full backup is not required, consider backing up just the diagnostic.data directory to preserve potentially-useful troubleshooting data in the event of an issue. See Full Time Diagnostic Data Capture for more information.
회원의 데이터 디렉터리 내용을 삭제합니다.
멤버의 dbPath 디렉토리에서 모든 데이터 및 하위 디렉토리를 삭제합니다.
Restart the mongod process.
해당 회원을 의결권 없는 회원으로 다시 추가하십시오.
Connect to the primary and use rs.add() to add the member with votes: 0 and priority: 0. Non-voting members must have a priority of 0.
rs.add( { host: "<hostname>:<port>", votes: 0, priority: 0 } )Wait for the method to return successfully. The mongod then performs an initial sync. The length of the initial sync process depends on the size of the database and the network latency between members of the replica set.
Adding the member as a non-voting member prevents the member's initial sync from stalling writes that use the "majority" write concern.
회원이 따라잡을 때까지 기다리세요.
Use rs.status() to confirm that the member has returned to the SECONDARY state. Then use rs.printSecondaryReplicationInfo() to confirm that its replication lag is close to 0. The SECONDARY state alone does not guarantee that the member is up to date.
해당 의원의 투표권을 복원하십시오.
Use rs.conf() to retrieve the current configuration. Set the member's votes and priority to the values that you recorded in the first step, and then apply the configuration with rs.reconfig(). Wait for the method to return successfully.
다른 멤버의 데이터 파일 복사하여 동기화하기
이 접근 방식은 복제 세트의 기존 멤버의 데이터 파일을 사용하여 새 멤버 또는 오래된 멤버에 "시드"를 생성합니다. 데이터 파일은 새 멤버가 oplog를 따라잡을 수 있을 만큼 충분히 최신 상태여야 합니다 . 그렇지 않으면 해당 멤버는 초기 동기화를 수행해야 합니다.
새 회원을 추가하는 경우, "(기존 회원)"이라고 표시된 단계를 건너뛰세요.
(기존 멤버) 복제 세트에서 해당 멤버를 제거합니다.
Use rs.remove() to remove the member. Wait for the method to return successfully. If the method times out, do not continue until the new configuration has been installed on a majority of voting members. To learn more, see Reconfiguration Waits Until a Majority of Members Install the Replica Configuration.
시드 멤버로부터 데이터 파일을 복사합니다.
데이터 파일을 스냅샷이나 직접 복사본으로 캡처할 수 있습니다. 그러나 대부분의 경우 파일 복사 작업 중 데이터 파일이 변경되므로 실행 중인 mongod 인스턴스에서 다른 인스턴스로 데이터 파일을 복사할 수 없습니다.
중요
데이터 파일에 mongodump 백업을 사용할 수 없습니다. 스냅샷 백업만 사용할 수 있습니다. 실행 중인 mongod 인스턴스의 일관된 스냅샷을 캡처하는 방법에 대한 자세한 내용은 자체 관리 배포를 위한 백업 방법 문서를 참조하세요.
해당 회원을 생성하고 투표권이 없는 회원으로 추가하세요.
Start the mongod instance with a new members[n]._id. Then connect to the primary and use rs.add() to add the member with votes: 0 and priority: 0. Non-voting members must have a priority of 0.
rs.add( { host: "<hostname>:<port>", votes: 0, priority: 0 } )메서드가 성공적으로 반환될 때까지 기다리세요.
해당 회원이 따라잡을 수 있도록 시간을 주세요.
Allow the member to apply all operations from the oplog until it reflects the current state of the replica set. To see the current status of the replica set, use rs.printSecondaryReplicationInfo() or rs.status(). Wait until the member's replication lag is close to 0.
해당 의원의 투표권을 복원하십시오.
Use rs.conf() to retrieve the current configuration. Set the member's votes and priority to the values that you recorded earlier, or to 1 and 1 for a new member, and then apply the configuration with rs.reconfig(). Wait for the method to return successfully.
롤링 초기 동기화를 수행합니다.
데이터를 보유한 멤버를 한 번에 하나씩 재동기화합니다. 보조 복제본부터 먼저 재동기화하고 기본 복제본을 마지막으로 재동기화합니다. 이렇게 하면 복제본 세트가 투표 과반수를 잃지 않습니다. 중재 복제본은 데이터를 보유하지 않으므로 재동기화 과정을 건너뜁니다.
Resyncing the only secondary in a replica set with an arbiter can stall writes that use the "majority" write concern. The automatic sync procedure avoids this stall. It re-adds the member as a non-voting member until the member catches up. To learn more, see Mitigate Performance Issues in Self-Managed PSA Replica Sets.
시작하기 전에 모든 멤버가 정상인지 확인하십시오. 또한 초기 동기화에 소요되는 시간을 포함할 수 있도록 oplog 창의 길이가 충분한지 확인하십시오.
보조 멤버 하나를 다시 동기화합니다.
Identify the most out-of-date secondary. In most cases, it is the secondary with the highest replication lag, which you can check with rs.printSecondaryReplicationInfo(). Then use the automatically sync a member procedure to resync that secondary.
프라이머리을 내려놓습니다.
When the secondaries are healthy and caught up, use rs.stepDown() to step down the primary. The method waits for an electable secondary to catch up before it steps down the primary. Confirm that a secondary is elected as the new primary before proceeding.
이전 기본 설정을 다시 동기화하세요.
이전의 기본 멤버가 이제 보조 멤버가 되었습니다. 멤버 자동 동기화 절차를 사용하여 다시 동기화하십시오.
복제 세트를 확인하십시오.
Use rs.status() and check replication lag to confirm that all data-bearing members have returned to a healthy state and are sufficiently caught up.