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

글로벌 컬렉션 샤딩

중요

The feature described on this page is not currently supported on Atlas Infinite clusters during public preview. For the features supported in public preview, see Public Preview Availability.

중요

Flex 클러스터에서 사용할 수 없는 기능

Flex 클러스터는 현재 이 기능을 지원하지 않습니다. 자세히 알아보려면 Atlas Flex 제한 사항을 참조하세요.

참고

  • 글로벌 쓰기는 M30+ 클러스터 계층이 필요한 글로벌 클러스터에서만 지원됩니다.

  • Global Writes가 활성화되면 글로벌 클러스터는 전용 검색 노드를 지원하지 않습니다.

  • Atlas UI를 사용하여 Atlas 관리 샤딩이 활성화된 글로벌 클러스터에 대해서만 글로벌 컬렉션을 샤딩할 수 있습니다.

  • This document assumes prior knowledge of sharding semantics. Review the Sharding documentation before continuing with this tutorial.

In sharded clusters, you can create zones of sharded data based on the shard key. Your zones can segment data based on geographic area. To learn more about sharding based on geographic area, see Segmenting Data by Location.

The Atlas UI supports sharding Global Write collections for only global clusters that use Atlas-Managed Sharding. To shard non-Global-Write collections or Global Write collections that use Self-Managed Sharding, you must use mongosh or application code. To learn more, see Deploy a Sharded Cluster.

클러스터의 Atlas 프로젝트에 대해 Project Owner 또는 Organization Owner 역할이 있어야 Atlas UI에서 글로벌 쓰기에 대한 컬렉션을 샤딩할 수 있습니다.

이 절차를 시작하기 전에 검토하세요:

Atlas Core 클러스터에서 온라인 보관를 구성하여 컬렉션을 샤딩하거나 클러스터 계층을 업그레이드하는 대신 자주 액세스하지 않는 데이터를 Atlas 클러스터에서 MongoDB managed 읽기 전용 연합 데이터베이스 인스턴스로 옮길 수 있습니다. Atlas Infinite 클러스터에서는 공개 미리 보기에서 온라인 아카이브가 지원되지 않습니다. 온라인 보관에 대해 자세히 학습하려면 Atlas에서 온라인 보관 관리를 참조하십시오.

Atlas UI를 통해 샤드 키를 선택한 후 Atlas는 대상 컬렉션을 샤딩하려고 시도합니다. 이 기간 동안에는 사용자가 컬렉션을 수동으로 샤딩하지 않도록 하세요. Atlas가 대상 컬렉션이 Atlas UI를 통해 선택한 키와 다른 키로 샤딩되었음을 감지하면 Atlas는 절차를 중지하고 Atlas UI에 해당 컬렉션에 대한 경고를 표시합니다. Unmanage Collection을(를) 클릭하여 경고를 지울 수 있습니다. 이 작업을 수행하면 기본 컬렉션과 수동으로 선택한 샤드 키는 그대로 두고 Atlas 관리에서 컬렉션을 제거합니다.

You can update a document's shard key value unless the shard key field is the immutable _id field. To learn more, see Change a Document's Shard Key Value.

MongoDB 6.0 이전 버전에서는 글로벌 쓰기가 활성화된 컬렉션에서 기존 문서의 샤드 키 필드 값을 업데이트할 수 없습니다.

중요

샤드 키 값 및 글로벌 클러스터

In all MongoDB versions, you can't reshard a collection on a Global Cluster. To learn more, see Sharding Collections for Global Writes.

글로벌 클러스터에서 컬렉션을 샤딩하려면 다음 안내를 따르세요.

1
  1. 아직 표시되지 않은 경우 탐색 표시줄의 Organizations 메뉴에서 프로젝트가 포함된 조직을 선택합니다.

  2. 아직 표시되지 않은 경우 내비게이션 바의 Projects 메뉴에서 프로젝트를 선택합니다.

  3. 사이드바에서 Database 제목 아래의 Data Explorer를 클릭합니다.

    The Data Explorer displays.

중요: 클러스터 이름을 클릭하여 Cluster 사이드바를 연 다음 제목 아래에 Data Explorer 있는 Shortcuts 를 클릭할 수도 있습니다.

2
3
4
5

다음 옵션 중 하나를 선택할 수 있습니다.

Default

Atlas uses the document that specifies the field or fields as the shard key.

Use unique index as the shard key

Atlas는 기본 인덱스를 사용하여 글로벌 컬렉션의 샤드 키에 고유한 제약 조건을 적용합니다.

Use hashed index as the shard key

Atlas는 샤드 키의 두 번째 필드를 해싱하여 샤딩된 데이터를 균등하게 배포합니다.

선택적으로 Pre-split data for even distribution을 선택하여 컬렉션에 정의된 구역 및 구역 범위를 기반으로 비어 있거나 존재하지 않는 컬렉션에 대해 초기 청크 생성 및 배포를 수행할지 여부를 지정할 수 있습니다.

If you select the Pre-split data for even distribution option, you can also specify the minimum number of chunks to create initially when sharding an empty collection with a hashed shard key. Initial chunk distribution allows Atlas to setup zoned sharding quickly. The number of chunks the Atlas creates depends on the number of zones that you define. By default, Atlas creates one chunk per location code and distributes chunks evenly across all shards.

To learn more about these options, see Global Cluster Sharding Reference.

6

Atlas는 컬렉션을 구성한 후 Global Writes 탭 상단 근처에 복합 샤드 키를 표시합니다.

The following sections describe sharding behavior and how to enable sharding for Manage Global Clusters.

For global clusters with Atlas-Managed Sharding enabled, unsharded collections must meet the following compatibility requirements prior to sharding to use Global Writes when sharded:

location 필드의 샤드 키만으로는 병목 현상이 발생할 수 있으며, 특히 국가 또는 지역의 하위 세트에 과반수의 쓰기 작업이 집중되는 워크로드의 경우 병목 현상이 발생할 가능성이 높습니다. Atlas 글로벌 쓰기는 클러스터 전체에 샤딩된 데이터를 효율적으로 분산하기 위해 복합 샤드 키가 필요합니다. Atlas 글로벌 클러스터 샤드 키는 MongoDB 샤드 키와 동일한 제한 사항을 공유합니다. 다음과 같은 Atlas 글로벌 클러스터 제한 사항이 적용됩니다:

  • 복합 샤드 키의 첫 번째 필드는 location이어야 하며 해시할 수 없습니다.

  • 복합 샤드 키에는 세컨더리 샤드 키 필드가 하나만 있을 수 있습니다.

  • 복합 샤드 키의 세컨더리 샤드 키 필드는 해시가 가능합니다.

  • 세컨더리 샤드 키 필드는 배열이 될 수 없습니다.

더욱 자세히 알아봅니다:

중요

샤드 키 변경

샤딩 후 수정할 수 있는 항목은 실행 중인 MongoDB 버전에 따라 다릅니다:

MongoDB 버전
샤드 키 수정
샤드 키 값 수정

MongoDB 7.0

예, Atlas UI만을 사용하여 키에 필드를 추가합니다.

예

MongoDB 8.0

예, Atlas UI만을 사용하여 키에 필드를 추가합니다.

예

In all MongoDB versions, you can't reshard a collection on a Global Cluster.

The Atlas UI supports creating sharded collections with specific validations for Global Writes. To learn more, see Shard a Global Collection for Global Writes in the Atlas UI.

You can also use mongosh to execute the sh.shardCollection(). After sharding the collection, you must use the Atlas UI to enable Global Writes for that collection.

WARNING: If you shard a collection that already has a MongoDB Search index, you might experience a brief period of incomplete search results while the index is building on a shard. Also, if you add a shard for an already sharded collection that contains a MongoDB Search index, your search queries against that collection might return incomplete results until the initial sync process completes on the added shards. To learn more, see initial sync process.

To learn more about sharding collections via the Atlas UI, see Shard a Global Collection for Global Writes in the Atlas UI.

Shard keys use hashed sharding and pre-split data for even distribution.

Atlas는 다음 작업 중 하나를 수행하는 경우 샤드 키의 두 번째 필드를 해시하여 샤딩된 데이터를 균등하게 분배합니다.

  • Atlas UI에서 Use hashed index as the shard key를 선택하여 해시된 인덱스 샤드 키의 사용을 활성화합니다.

  • Set isCustomShardKeyHashed through the API.

비어 있거나 존재하지 않는 컬렉션에 대해 초기 청크 생성 및 배포를 수행할지 여부를 선택적으로 지정할 수 있습니다. 이 작업은 컬렉션에 대해 정의된 구역 및 구역 범위를 기반으로 합니다. 이를 위해 다음 작업 중 하나를 수행합니다:

  • Select Pre-split data for even distribution in the Atlas UI.

  • Set presplitHashedZone using the API.

글로벌 클러스터용 복합 해시 샤드 키를 사용하여 샤딩된 컬렉션을 생성하는 경우 Atlas는 위치 코드당 청크를 최소 1개 생성하고 클러스터 내 샤드에 청크를 균등하게 분배하려고 시도합니다.

You can also specify the minimum number of chunks to create initially when sharding an empty collection with a hashed shard key using the Atlas UI or by setting the numInitialChunks parameter through the API.

참고

샤드당 청크 수를 지정하면 Atlas는 위치 코드당 청크 수와 동일하게 지정된 최소 청크 수 이상을 생성합니다. 최소 청크 수를 지정하면 Atlas는 구역 샤딩을 빠르게 설정합니다. 특히 샤딩 전에 데이터를 지리적으로 배포하는 방법을 이미 알고 있는 경우 더욱 그렇습니다.

글로벌 쓰기를 위해 컬렉션을 샤딩하는 동안 Atlas에서 오류가 발생하면 화면 상단의 배너에 메시지가 나타납니다.

  1. 오류 및 오류가 발생한 네임스페이스 에 대해 학습 See Details 을 클릭합니다. 전체 오류 메시지와 Fix Now 버튼이 포함된 모달 창 나타납니다.

  2. Close를 클릭하고 Atlas UI에서 컬렉션으로 이동합니다. Fix Now 버튼을 클릭하여 해당 Atlas 클러스터의 Atlas UI로 이동할 수도 있습니다.

  3. 오류 메시지에 언급된 컬렉션에 대한 Global Writes 탭을 클릭합니다.

  4. 글로벌 쓰기 샤딩 작업을 취소하려면 Unmanage Collection을 클릭합니다. 샤딩 작업을 취소하려면 Project Data Access Admin 역할이 있어야 합니다.

오류 메시지에 표시된 대로 컬렉션에 필요한 사항을 변경한 후 샤딩 프로세스를 다시 시작할 수 있습니다.

발생할 수 있는 오류는 다음과 같습니다:

사용자 지정 샤드 키에 인덱스가 이미 존재합니다.
복합 샤드 키의 두 번째 부분으로 선택한 필드가 이미 인덱싱된 경우 샤딩 작업이 실패할 수 있습니다.
컬렉션이 이미 샤딩되었습니다.
컬렉션이 이미 수동으로 샤딩된 경우 작업이 실패합니다.
컬렉션에는 사용자 지정 기본 데이터 정렬이 있습니다.
컬렉션의 사용자 지정 기본 데이터 정렬로 인해 샤딩 오류가 발생할 수 있습니다.

쓰기 작업의 각 문서에 대해 MongoDB는 샤드 키(포함된 경우)의 location 필드를 사용하여 데이터를 라우팅할 구역을 결정합니다. MongoDB는 해당 구역과 관련된 샤드를 문서 작성 대상으로 선택하여 지리적으로 격리되고 분할된 데이터 저장을 용이하게 합니다.

경고

쓰기 작업에 샤드 키가 포함되어 있지 않거나 샤드 키가 포함되어 있지만 location 필드가 없는 경우, 쓰기 작업은 성공하지만 결과 문서는 배포되지 않습니다.

MongoDB 글로벌 쓰기를 위한 샤딩 컬렉션에 정의된 기준을 충족하는 삽입된 문서에 대해서만 이 동작을 보장할 수 있습니다. 구체적으로, MongoDB location 필드 가 ISO-3166-1 alpha 2 또는 ISO-3166-2을 준수하지 않는 문서 클러스터 의 샤드 로 라우팅할 수 있습니다.

MongoDB 쿼리 라우팅은 읽기 작업에 전체 샤드 키가 포함되어 있고 동시에 location 값이 지원되는 ISO-3166-1 alpha 2 국가 코드("US", "DE", "IN") 또는 지원되는 ISO-3166-2 하위 지역 코드("US-DC", "DE-BE", "IN-DL")에 해당하는지 여부에 따라 달라집니다.

  • 전체 샤드 키를 포함하고 location 값이 글로벌 쓰기에 대한 요건을 충족하는 쿼리의 경우, MongoDB는 쿼리에 지정된 location 값에 매핑되는 구역으로 읽기 작업을 타깃팅합니다.

  • location 값을 포함하지 않는 읽기 작업의 경우, 또는 location 값이 지원되는 ISO-3166-1 알파 2 국가 코드와 일치하지 않거나 ISO-3166-2 세분화 코드인 경우, MongoDB는 클러스터의 모든 영역에 읽기 작업을 브로드캐스트해야 합니다.

  • For Global Writes zones that have Read-only nodes in geographically distant regions, clients in those regions can query the local Read-only node for that zone by specifying the full shard key as part of the query and issuing the read operation with a Read Preference of nearest.

중요

세컨더리 읽기는 세컨더리 노드와 프라이머리 노드 사이의 복제 지연 수준에 따라 오래된 데이터를 반환할 수 있습니다.

To learn more, see MongoDB Read Preference and MongoDB Query Routing.

Global Writes clusters support the same Ranged and Hashed sharding strategies as a standard Atlas sharded cluster. For sharded collections whose shard keys and document schema don't support Global Writes, MongoDB distributes the sharded data evenly across the available shards in the cluster with respect to the chosen shard key. Consider using a separate sharded cluster for data that can't take advantage of Global Writes.

샤딩 후에는 글로벌 쓰기를 지원하기 위해 컬렉션을 수정할 수 없습니다. 향후 컬렉션에 글로벌 쓰기를 사용할 수 있도록 허용하는 샤드 키를 선택하는 것이 좋습니다.

팁

To learn more about Global Writes sharding requirements, see Sharding Collections for Global Writes.

Global Clusters provide the same support for unsharded collections as a standard Atlas sharded cluster. For each database in the cluster, MongoDB stores its unsharded collections on a primary shard. Use sh.status() from mongosh to determine the primary shard for the database.