DBAtlas · 데이터베이스 운영 아틀라스

멤버를 처음부터 재동기화

MongoDBReplica Set

명령어

// On the SECONDARY to be resynced (NEVER on the PRIMARY):
db.getSiblingDB("admin").shutdownServer()
// At the OS level: empty the dbPath contents (or move them elsewhere as a backup)
// and restart mongod with the same configuration; the member starts an initial sync automatically.
// Monitor progress (stateStr: STARTUP2 -> SECONDARY):
rs.status()

하는 일

MongoDB에는 별도의 resync 명령이 없다. secondary를 중지하고 데이터 디렉터리를 비운 뒤 재시작하면 primary(또는 sync source)에서 새 초기 동기화가 시작된다.

사용 시점

멤버가 너무 뒤처져 oplog window 밖으로 벗어났거나(RECOVERING / too stale) 데이터가 불일치하게 되었을 때.

주의

멤버의 모든 로컬 데이터가 삭제되고 다시 가져와진다. secondary에서만 수행하고 과반수가 계속 동작하는지 확인한다. 동기화 시간과 네트워크/디스크 부하가 크다. 매우 큰 데이터 세트는 정상 멤버의 파일 시스템 스냅샷으로 시딩하는 것이 더 빠르다.

DBAtlas에서 열기 →

관련 항목