定義
fsyncUnlockサーバーまたはクラスターのロック数を軽減します。 書込み (write) 操作を有効にするには、ロック カウントが 0 である必要があります。
MongoDB 7.1以降( 7.0.2以降でも利用可能 )、 6.0.11と5.0 。 22 )
fsyncコマンドとfsyncUnlockコマンドをmongosで実行すると、シャーディングされたクラスターのロックとロックが解除されます。バックアップ操作の完了後に、このコマンドを使用して書込みのブロックを解除します。
重要
Servers maintain an fsync lock count. The
fsynccommand with thelockfield set totrueincrements the lock count while thefsyncUnlockcommand decrements it. To enable writes on a locked server or cluster, call thefsyncUnlockcommand until the lock count reaches zero.fsyncUnlockis an administrative operation. Typically you will usefsyncUnlockfollowing a database backup operation.Tip
In
mongosh, this command can also be run through thedb.fsyncUnlock()helper method.Helper methods are convenient for
mongoshusers, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
構文
このコマンドの構文は、次のとおりです。
db.adminCommand( { fsyncUnlock: 1, comment: <any> } )
commentフィールドは任意であり、任意のデータ型のコメントを含めることができます。
結果
この操作は、次のフィールドを含むドキュメントを返します。
フィールド | 説明 |
|---|---|
| 操作のステータスに関する情報 |
| 操作後にインスタンス上に残っているロックの数。 |
| ステータス コード。 |
例
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" : Long(1), "ok" : 1 }
lockCountが 0 より大きいため、 mongodインスタンスは書き込みに対してロックされます。 インスタンスの書き込みをロックするには、ロック操作を再度実行します。
db.adminCommand( { fsyncUnlock: 1 } )
この操作を実行すると次のドキュメントが返されます。
{ "info" : "fsyncUnlock completed", "lockCount" : Long(0), "ok" : 1 }
mongodインスタンスは書き込み用にロックが解除されています。