정의
addShardToZone샤드를 구역 과 연결합니다. MongoDB는 이 샤드를 지정된 구역과 연결합니다. 구역에 포함되는 청크는 구역과 관련된 샤드에 할당됩니다.
팁
In
mongosh, this command can also be run through thesh.addShardToZone()helper method.Helper methods are convenient for
mongoshusers, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.
You can only run addShardToZone on the admin database from a mongos instance.
호환성
이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
- MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
구문
명령은 다음과 같은 구문을 가집니다:
db.adminCommand( { addShardToZone: <string>, zone: <string> } )
명령 필드
이 명령은 다음 필드를 사용합니다.
필드 | 유형 | 설명 |
|---|---|---|
문자열 | The name of the shard to associate with the zone. | |
문자열 | The name of the zone to associate with the shard. |
mongosh provides the helper method sh.addShardToZone().
행동
구역을 여러 샤드와 연결할 수 있으며, 하나의 샤드가 여러 구역과 연결할 수 있습니다.
샤드 cluster의 구역에 대한 자세한 내용은 구역 매뉴얼 페이지를 참조하세요.
범위
MongoDB는 하나 이상의 샤드 키 값 범위와 연결되지 않은 구역을 효과적으로 무시합니다.
샤드 키 값 범위를 구역과 연결하려면 updateZoneKeyRange 데이터베이스 명령 또는 sh.updateZoneKeyRange() 셸 헬퍼를 사용합니다.
updateZoneKeyRange 데이터베이스 명령과 해당 헬퍼 sh.updateZoneKeyRange() 및 sh.addTagRange()를 비샤드형 컬렉션 또는 존재하지 않는 컬렉션에서 실행할 수 있습니다.
팁
샤드 컬렉션 작업은 비어 있거나 존재하지 않는 컬렉션을 샤딩하기 전에 구역 및 구역 범위를 정의하여 정의된 구역 범위에 대한 청크와 샤드 키 값의 전체 범위를 포함하는 추가 청크를 생성하고 그역 범위를 기반으로 초기 청크 분배를 수행합니다. 이러한 청크의 초기 생성 및 배포를 통해 샤딩을 더 빠르게 설정할 수 있습니다. 초기 분배 이후에는 밸런서가 앞으로의 청크 분배를 관리합니다.
예를 보려면 비어 있거나 존재하지 않는 컬렉션에 대한 구역 및 구역 범위 사전 정의를 참조하세요.
보안
액세스 제어 를 적용하는 샤드 cluster의 경우 다음 중 하나의 권한을 가진 사용자로 인증해야 합니다.
updateconfig데이터베이스의shardscollection에 대한 , 또는,enableSharding클러스터 리소스의 .
The clusterAdmin or clusterManager built-in roles have the appropriate permissions for issuing addShardToZone. See the documentation page for Role-Based Access Control for more information.
예시
다음 예에서는 shard0000 을 JFK 구역과 연결합니다.
db.adminCommand( { addShardToZone : "shard0000" , zone : "JFK" } )
샤드는 여러 구역과 연결할 수 있습니다. 다음 예에서는 LGA 을 shard0000 에 연결합니다.
db.adminCommand( { addShardToZone : "shard0000" , zone : "LGA" } )
shard0000 LGA 구역 및 JFK 구역과 모두 연결됩니다. 균형 잡힌 cluster에서 MongoDB는 두 구역 중 하나에 포함되는 읽기 및 쓰기를 shard0000 으로 라우팅합니다.