AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

데이터베이스 덤프로 자체 관리형 클러스터 복원

mongorestore is a tool that reads mongodump binary exports and restores the data to a MongoDB deployment. Use mongorestore to restore a sharded cluster from a mongodump backup.

Ensure you have a mongodump backup of your source cluster. To create one, see Back Up a Self-Managed Sharded Cluster with a Database Dump. If you have file system snapshots, see Restore a Self-Managed Sharded Cluster from Snapshots.

1

청크 마이그레이션으로 인해 복원이 중단되는 것을 방지하려면 mongos 에 연결하고 밸런서를 중지합니다.

sh.stopBalancer()

밸런서가 중지되었는지 확인하려면 다음을 실행합니다.

use config
while( sh.isBalancerRunning().mode != "off" ) {
print( "Waiting for Balancer to stop..." );
sleep( 1000 );
}
2

소스 클러스터의 각 샤딩된 컬렉션에 대해 데이터를 복원하기 전에 대상 클러스터에 컬렉션을 만들고 동일한 샤드 키를 사용하여 샤딩합니다.

각 컬렉션의 샤드 키를 찾으려면 라이브 소스 클러스터에 쿼리합니다.

use config
db.collections.find()

Alternatively, you can use bsondump to inspect the config/collections.bson file from your dump directory:

bsondump /path/to/dump/config/collections.bson
{
"_id": "<database>.<collection>",
...
"key": { "<shardKeyField>": "<key>" },
...
}

참고

유효한 샤드 키 값은 1 또는 "hashed"입니다.

각 샤딩된 컬렉션에 대해 동일한 샤드 키를 사용하여 대상 클러스터에서 컬렉션을 샤딩합니다.

sh.shardCollection(
"<database-name>.<collection-name>",
{ <shardKeyField>: <key> }
)
3

Use mongorestore to connect to mongos and restore the cluster. Exclude the config database to preserve the destination cluster's existing configuration:

mongorestore \
--host <host> \
--port 27017 \
--username <username> \
--password "<password>" \
--authenticationDatabase admin \
--nsExclude='config.*' \
/path/to/backup

중요

The --drop option drops the collection before restoring. If you use --drop after pre-sharding collections, mongorestore removes the sharding configuration.

4

복원이 완료되면 밸런서를 다시 시작합니다.

sh.startBalancer()

밸런서가 실행 중인지 확인하려면 다음과 같이 합니다.

sh.isBalancerRunning().mode
full
5

mongos 에 연결하고 sh.status() 를 실행하여 전체 클러스터 상태를 확인합니다.

sh.status()

모든 샤드에 액세스할 수 있고 통신할 수 있는지 확인하려면 임시 컬렉션에 테스트 문서를 삽입합니다.

db.testRestore.insertOne({ test: 1 })

그 다음 각 샤드 프라이머리에 연결하여 db.collection.find() 를 실행하여 문서가 있는지 확인합니다.

db.testRestore.find()
이 페이지 평가하기