fsyncUnlock
定義
fsyncUnlock
Reduces the lock count on the server or cluster. To enable write operations, the lock count must be zero.
Starting in MongoDB 7.1 (also available starting in 7.0.2, 6.0.11, and 5.0.22) the
fsync
andfsyncUnlock
commands can run onmongos
to lock and unlock a sharded cluster.Use this command to unblock writes after you finish a backup operation.
重要
Servers maintain an fsync lock count. The
fsync
command with thelock
field set totrue
increments the lock count while thefsyncUnlock
command decrements it. To enable writes on a locked server or cluster, call thefsyncUnlock
command until the lock count reaches zero.fsyncUnlock
is an administrative operation. Typically you will usefsyncUnlock
following a database backup operation.Tip
mongosh
では、このコマンドはdb.fsyncUnlock()
ヘルパー メソッドを通じて実行することもできます。ヘルパー メソッドは
mongosh
ユーザーには便利ですが、データベースコマンドと同じレベルの情報は返されない可能性があります。 便宜上必要ない場合、または追加の戻りフィールドが必要な場合は、 データベースコマンドを使用します。
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
構文
このコマンドの構文は、次のとおりです。
db.adminCommand( { fsyncUnlock: 1, comment: <any> } )
The comment
field is optional and may contain a comment of any data
type.
結果
この操作は、次のフィールドを含むドキュメントを返します。
フィールド | 説明 |
---|---|
| Information on the status of the operation |
| The number of locks remaining on the instance after the operation. |
| ステータス コード。 |
例
Consider a situation where db.fsyncLock()
has been issued two
times. The following fsyncUnlock
operation reduces the
locks taken by db.fsyncLock()
by 1:
db.adminCommand( { fsyncUnlock: 1 } )
この操作を実行すると次のドキュメントが返されます。
{ "info" : "fsyncUnlock completed", "lockCount" : NumberLong(1), "ok" : 1 }
As the lockCount
is greater than 0, the mongod
instance
is locked against writes. To unlock the instance for writes, run the
unlock operation again:
db.adminCommand( { fsyncUnlock: 1 } )
この操作を実行すると次のドキュメントが返されます。
{ "info" : "fsyncUnlock completed", "lockCount" : NumberLong(0), "ok" : 1 }
The mongod
instance is unlocked for writes.