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 start 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.