You can manage the collections in your clusters using the Atlas UI and mongosh.
필수 역할
다음 표에서는 Atlas 프로젝트에서 컬렉션을 관리하는 데 필요한 역할에 대해 설명합니다:
작업 | 필수 역할 |
|---|---|
컬렉션 생성 | |
컬렉션 보기 | 최소한 |
제거 컬렉션 | 다음 역할 중 하나입니다. |
샤드 컬렉션 | 다음 역할 중 하나입니다. |
컬렉션 생성
팁
새 데이터베이스에서 첫 번째 컬렉션을 만들려면 데이터베이스 생성을 참조하세요.
중요
config 및 system 데이터베이스에서는 새 컬렉션을 만들 수 없습니다. Atlas는 가까운 시일 내에 이러한 데이터베이스의 기존 컬렉션에 대한 쓰기 기능을 중단할 예정입니다.
Atlas UI를 통해 기존 데이터베이스에서 컬렉션을 만들려면 다음과 같이 하세요:
컬렉션 보기
Atlas UI를 통해 클러스터의 데이터베이스 및 컬렉션을 보는 방법:
Atlas 에서 프로젝트 의 Data Explorer 페이지로 이동합니다.
아직 표시되지 않은 경우 탐색 표시줄의 Organizations 메뉴에서 프로젝트가 포함된 조직을 선택합니다.
아직 표시되지 않은 경우 내비게이션 바의 Projects 메뉴에서 프로젝트를 선택합니다.
사이드바에서 Database 제목 아래의 Data Explorer를 클릭합니다.
The Data Explorer displays.
중요: 클러스터 이름을 클릭하여 Cluster 사이드바를 연 다음 제목 아래에 Data Explorer 있는 Shortcuts 를 클릭할 수도 있습니다.
데이터베이스에서 컬렉션을 봅니다.
데이터베이스의 이름을 클릭합니다.
참고
Atlas는 collStats를 사용하여 캐시된 메타데이터를 기반으로 이 탭에 표시되는 문서 수를 계산합니다. 이 개수는 컬렉션의 실제 문서 수와 다를 수 있습니다. 예를 들어, 예기치 않은 종료로 인해 집계가 중단될 수 있습니다. 가장 정확한 문서 수를 계산하려면 db.collection.countDocuments() 메서드를 사용합니다.
수집 데이터 시각화
데이터베이스와 컬렉션의 데이터를 시각화하기 위해 MongoDB Charts를 실행합니다.
Atlas 에서 프로젝트 의 Data Explorer 페이지로 이동합니다.
아직 표시되지 않은 경우 탐색 표시줄의 Organizations 메뉴에서 프로젝트가 포함된 조직을 선택합니다.
아직 표시되지 않은 경우 내비게이션 바의 Projects 메뉴에서 프로젝트를 선택합니다.
사이드바에서 Database 제목 아래의 Data Explorer를 클릭합니다.
The Data Explorer displays.
중요: 클러스터 이름을 클릭하여 Cluster 사이드바를 연 다음 제목 아래에 Data Explorer 있는 Shortcuts 를 클릭할 수도 있습니다.
MongoDB Charts 시작
To visualize data in MongoDB Charts from the Atlas UI, click Visualize Your Data when viewing a specific database or collection. Charts loads the data source and you can start building a chart in the Charts view. For detailed steps, see Build Charts.
제거 collection
Atlas UI를 통해 문서 및 인덱스를 포함한 컬렉션을 제거하려면 다음을 수행합니다.
Atlas 에서 프로젝트 의 Data Explorer 페이지로 이동합니다.
아직 표시되지 않은 경우 탐색 표시줄의 Organizations 메뉴에서 프로젝트가 포함된 조직을 선택합니다.
아직 표시되지 않은 경우 내비게이션 바의 Projects 메뉴에서 프로젝트를 선택합니다.
사이드바에서 Database 제목 아래의 Data Explorer를 클릭합니다.
The Data Explorer displays.
중요: 클러스터 이름을 클릭하여 Cluster 사이드바를 연 다음 제목 아래에 Data Explorer 있는 Shortcuts 를 클릭할 수도 있습니다.
Collection 샤드
If you have large data sets and perform high throughput operations, you can shard a collection to distribute data across the shards.
You cannot shard a collection through the Atlas UI. To shard a collection, first confirm that your cluster is a sharded cluster, then take the following steps to shard the collection in mongosh:
Connect to MongoDB from mongosh.
mongosh 를 통해 클러스터에 연결을 참조하세요.
샤드하려는 컬렉션을 샤드합니다.
컬렉션을 샤딩하려면 다음 명령을 실행합니다.
sh.shardCollection("<database>.<collection>", { "<indexed-field>" : 1 } )
예시
sample_analytics.customers 컬렉션을 샤드하기 위해:
sh.shardCollection("sample_analytics.customers", { "username" : 1 } )
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, see Shard a Collection in the MongoDB manual.