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

setUserWriteBlockMode (데이터베이스 명령)

setUserWriteBlockMode

버전 6.0에 추가 되었습니다.

setUserWriteBlockMode 명령은 전체 클러스터에 대한 쓰기를 차단 및 차단 해제합니다.

During cluster synchronization, mongosync uses the setUserWriteBlockMode command to block writes on both the source and destination clusters. For more information, see the HTTP API start command.

복제본 세트 에 대한 쓰기를 이미 차단한 경우, 지정된 reason 이(가) 처음 쓰기 차단을 활성화할 때 제공한 이유와 일치하지 않으면 global: true 을(를) 사용한 setUserWriteBlockMode 에 대한 후속 호출이 실패하고 IllegalOperation 오류가 발생합니다. 오류 메시지에는 현재 이유와 실패한 명령에 지정된 이유가 모두 포함됩니다. 샤드 클러스터는 이 제약 조건을 시행하다 하지 않습니다.

참고

bypassWriteBlockingMode 권한이 있는 사용자 및 애플리케이션은 차단을 우회하고 쓰기를 계속 수행할 수 있습니다.

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

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

중요

This command is not supported in M0 and Flex clusters. For more information, see Unsupported Commands.

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

db.adminCommand(
{
setUserWriteBlockMode: 1,
global: <boolean>,
reason: <string> // Optional
}
)

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

필드
유형
설명

setUserWriteBlockMode

integer

이 필드를 1 으로 설정합니다.

global

부울

true 로 설정되면 cluster의 쓰기를 차단합니다. cluster에서 쓰기를 활성화하려면 global: false 을 설정합니다.

reason

문자열

선택 사항. 쓰기를 차단하는 이유를 지정합니다. 허용되는 값은 다음과 같습니다.

  • "Unspecified" - 이유를 제공하지 않는 경우 기본값입니다.

  • "ClusterToClusterMigrationInProgress" - 진행 중인 mongosync 마이그레이션 으로 인해 차단된 쓰기 (write)를 나타냅니다.

  • "DiskUseThresholdExceeded" - 디스크 사용량이 임계값을 초과하여 차단된 쓰기를 나타냅니다.

setUserWriteBlockMode 명령을 실행하려면 사용자에게 setUserWriteBlockMode 권한이 있어야 합니다.

  1. 사용자 쓰기 차단 모드를 활성화합니다:

    db.adminCommand( {
    setUserWriteBlockMode: 1,
    global: true
    } )
  2. collection에 기록을 추가합니다:

    db.names.insertOne( { name: "George Washington Cable" } )

    사용자 쓰기 차단이 활성화되어 있기 때문에 서버가 쓰기를 차단합니다.

    출력 예시:

    MongoServerError: User writes blocked
  3. 사용자 쓰기 차단 모드를 비활성화합니다:

    db.adminCommand( {
    setUserWriteBlockMode: 1,
    global: false
    } )
  4. collection에 기록을 추가합니다:

    db.names.insertOne( { name: "George Washington Cable" } )

    insertOne() 메서드는 컬렉션에 씁니다. 사용자 쓰기 차단이 비활성화되어 있으므로 서버에서 쓰기를 허용합니다.