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

sh.enableSharding() (mongosh 메서드)

sh.enableSharding(database, primaryShard)

참고

버전 6.0에서 변경되었습니다.

MongoDB 6.0부터는 컬렉션을 샤딩할 때 이 메서드가 필요하지 않습니다.

Explicitly creates a database. Use the mongosh method sh.shardCollection() to shard collections on the database. The mongosh method sh.enableSharding() wraps the enableSharding command.

중요

Mongo쉬 방법

This page documents a mongosh method. This is not the documentation for database commands or language-specific drivers, such as Node.js.

데이터베이스 명령에 대해서는 enableSharding 명령을 참조하십시오.

MongoDB API 드라이버의 경우 언어별 MongoDB 드라이버 설명서를 참조하세요.

이 메서드는 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.

  • MongoDB Atlas: 클라우드에서의 MongoDB 배포를 위한 완전 관리형 서비스

중요

이 명령은 M0 및 Flex 클러스터에서 지원되지 않습니다. 자세한 내용은 지원되지 않는 명령을 참조하세요.

The sh.enableSharding() has the following form:

sh.enableSharding(
<database>,
<primary shard> // Optional.
)

The sh.enableSharding() method takes the following parameter:

Parameter
유형
설명

문자열

생성하려는 데이터베이스의 이름입니다.

문자열

선택 사항. 데이터베이스 의 프라이머리 샤드 입니다. 데이터베이스 의 모든 샤딩되지 않은 컬렉션에 대한 기본값 샤드 입니다.

경고: 일반적으로 프라이머리 샤드 를 지정해서는 됩니다. 클러스터 가 대신 프라이머리 샤드 를 선택하도록 허용합니다.

mongos uses "majority" for the enableSharding command and its helper sh.enableSharding().

일반적으로 명령에 프라이머리 샤드를 지정할 필요가 없습니다. 대신 밸런서가 프라이머리 샤드를 선택하도록 허용합니다.

However, if you do specify the primary shard for a database and the database is already enabled for sharding with a different primary shard, the operation returns an error and the primary shard for the database remains as before. To change the primary shard for a database, use the movePrimary command instead.

mongos에서 실행되는 다음 예시는 명시적으로 shardTest 데이터베이스를 생성합니다.

sh.enableSharding("shardTest")

확인하려면 sh.status()를 실행합니다.

이 페이지 평가하기

이 페이지의 내용