setUserWriteBlockMode
정의
setUserWriteBlockMode
버전 6.0에 추가.
The
setUserWriteBlockMode
command blocks and unblocks writes to the entire cluster.During cluster-to-cluster sync,
mongosync
, the cluster-to-cluster synchronization tool, uses thesetUserWriteBlockMode
command to block writes on the destination cluster. For more information, see the HTTP API 시작하기 command.참고
Users and applications with the
bypassWriteBlockingMode
privilege can bypass the block and continue to perform writes.
호환성
이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
중요
이 명령은 MongoDB Atlas 클러스터에서 지원되지 않습니다. 모든 명령에 대한 Atlas 지원 에 대한 자세한 내용은 지원되지 않는 명령을 참조하세요.
구문
명령은 다음과 같은 구문을 가집니다:
db.adminCommand( { setUserWriteBlockMode: 1, global: <boolean> } )
명령 필드
이 명령은 다음 필드를 사용합니다.
필드 | 유형 | 설명 |
---|---|---|
| integer | Set this field to |
| 부울 | Blocks writes on a cluster when set to |
필요한 액세스 권한
To execute the setUserWriteBlockMode
command, the user must
have the setUserWriteBlockMode
privilege.
예시
Enable user write block mode:
db.adminCommand( { setUserWriteBlockMode: 1, global: true } ) Add a record to the collection:
db.names.insertOne( { name: "George Washington Cable" } ) The server blocks the write because the user write block is enabled.
Example Output:
MongoServerError: User writes blocked Disable user write block mode:
db.adminCommand( { setUserWriteBlockMode: 1, global: false } ) Add a record to the collection:
db.names.insertOne( { name: "George Washington Cable" } ) The
insertOne()
method writes to a collection. The server allows the write because the user write block is disabled.