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

enableSharding(데이터베이스 명령)

enableSharding

참고

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

MongoDB 6.0부터는 collection을 샤딩 하는 데 이 명령이 필요 하지 않습니다 .

The enableSharding command explicitly creates a database.

In mongosh, this command can also be run through the sh.enableSharding() helper method.

Helper methods are convenient for mongosh users, 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.

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

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

명령은 다음과 같은 구문을 가집니다:

  • 권장. 생성할 데이터베이스를 지정합니다:

    db.adminCommand(
    {
    enableSharding: "<database name>"
    }
    )
  • 선택적으로 명령에 프라이머리 샤드 사양을 포함할 수 있지만, 이는 권장되지 않습니다.

    db.adminCommand(
    {
    enableSharding: "<database name>",
    primaryShard: "<shard name>"
    }
    )

You can only run the enableSharding command on the admin database from a mongos instance.

이 명령은 다음 필드를 사용합니다.

필드
유형
설명

문자열

사용하려는 데이터베이스. 데이터베이스가 존재하지 않는 경우 생성됩니다.

문자열

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

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

이 명령은 작업 상태가 포함된 문서를 반환합니다.

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

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

However, if you do specify the primaryShard in the command for a database and the database is already sharding enabled 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 movePrimary instead.

mongos 에서 실행되는 다음 명령은 shardTest 데이터베이스를 생성합니다.

db.adminCommand( { enableSharding: "shardTest" } )
이 페이지 평가하기