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

movePrimary (데이터베이스 명령)

movePrimary

In a sharded cluster, movePrimary reassigns the primary shard which holds all un-sharded collections in the database. movePrimary first changes the primary shard in the cluster metadata, and then migrates all un-sharded collections to the specified shard. Use the command with the following form:

db.adminCommand( { movePrimary: <databaseName>, to: <newPrimaryShard> } )

예를 들어, 다음 명령은 프라이머리 샤드를 test 에서 shard0001 로 이동합니다.

db.adminCommand( { movePrimary : "test", to : "shard0001" } )

명령이 반환되면 데이터베이스의 프라이머리 샤드 위치가 지정된 샤드로 전환됩니다. 샤드를 완전히 서비스 해제하려면 removeShard 명령을 사용합니다.

movePrimary is an administrative command that is only available for mongos instances.

경고

After starting movePrimary, do not perform any read or write operations against any unsharded collection in that database until the command completes. Read or write operations issued against those collections during the migration can result in unexpected behavior, including potential failure of the migration operation or loss of data.

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

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

mongos uses "majority" write concern for movePrimary.

Only run movePrimary after you move unsharded collections using sh.moveCollection(). Starting in MongoDB 8.0, unmoved, unsharded collections are not available during the movePrimary process.

이동 중인 데이터베이스에 MongoDB Search를 사용하는 샤딩되지 않은 컬렉션이 포함되어 있는 경우, movePrimary가 완료된 후에 해당 컬렉션의 검색 인덱스를 사용할 수 없게 됩니다. movePrimary은(는) 이동하는 샤딩되지 않은 컬렉션의 UUID를 업데이트하기 때문에, 해당 컬렉션에 대해 MongoDB Search 인덱스를 수동으로 다시 빌드해야 합니다.

movePrimary may require a significant time to complete depending on the size of the database and factors such as network health or machine resources. During migration, attempts to write or perform any DDL operations to the unsharded collections on the database being moved fail with the error: "movePrimary is in progress".

Consider scheduling a maintenance window during which applications stop all reads and writes to the cluster. Issuing movePrimary during planned downtime mitigates the risk of encountering undefined behavior due to interleaving reads or writes to the unsharded collections in the database.

movePrimary 대상 샤드에 충돌하는 컬렉션 네임스페이스가 포함된 경우 실패합니다. 예를 들면 다음과 같습니다.

  1. 관리자가 movePrimary 를 발행하여 hr 데이터베이스의 프라이머리 샤드를 변경합니다.

  2. movePrimary 가 해당 collection을 이동하는 동안 사용자 또는 애플리케이션이 hr 의 샤딩되지 않은 collection에 대해 쓰기 작업을 실행합니다. 쓰기 작업은 원래 프라이머리 샤드에 collection을 생성합니다.

  3. 나중에 관리자가 movePrimary 를 실행하여 hr 데이터베이스의 원래 프라이머리 샤드를 복원합니다.

  4. movePrimary 인터리빙 쓰기 작업에서 남겨진 충돌 네임스페이스로 인해 실패합니다.

movePrimary 작업의 일부로 대상 샤드는 프라이머리 샤드가 된 후 마이그레이션된 collection의 인덱스를 다시 작성해야 합니다. collection당 인덱스 수와 인덱싱할 데이터의 양에 따라 상당한 시간이 걸릴 수 있습니다.

인덱스 빌드 프로세스에 대한 자세한 내용 은 채워진 collection 에 대한 인덱스 빌드를 참조하세요.

MongoDB 부터 8.0 는movePrimary 변경 스트림이 있는 이벤트 컬렉션을 무효화하지 않습니다. 컬렉션이 새 샤드 로 이동한 후에도 변경 스트림은 컬렉션에서 이벤트를 계속 읽을 수 있습니다.

이전 MongoDB 버전에서는 movePrimary 이(가) 컬렉션 변경 스트림을 무효화하므로 변경 스트림이 컬렉션에서 이벤트를 읽을 수 없습니다.

모든 MongoDB 버전에서 movePrimary 은 이동된 샤딩되지 않은 컬렉션의 UUID 를 업데이트합니다.

전체 절차 는 샤드 클러스터에서 샤드 제거를 참조하세요.

이 페이지 평가하기