On this page本页内容
fsyncUnlock
Reduces the lock taken by 将fsync (with the lock option) on a mongod instance by 1.mongod实例上fsync(使用lock选项)所占用的锁减少1。
The fsync lock and fsyncUnlock operations maintain a lock count. fsync lock和fsyncUnlock操作保持锁定计数。Each 每个fsync lock operation increments the lock count, and fsyncUnlock decrements the lock count.fsync lock操作都会增加锁定计数,而fsyncUnlock会减少锁定计数。
To unlock a 要解锁mongod instance for writes, the lock count must be zero. mongod实例进行写入,锁计数必须为零。That is, for a given number of 也就是说,对于给定数量的fsynclock operations, you must issue a corresponding number of fsyncUnlock operations to unlock the instance for writes.fsynclock操作,必须发出相应数量的fsyncUnlock操作来解锁实例以进行写入。
fsyncUnlock is an administrative operation. 是管理操作。Typically you will use 通常,您将在数据库备份操作之后使用fsyncUnlock following a database backup operation.fsyncUnlock。
To run the 要运行fsyncUnlock command, use the db.adminCommand() method:fsyncUnlock命令,请使用db.adminCommand()方法:
db.adminCommand( { fsyncUnlock: 1, comment: <any> } )
The comment field is optional and may contain a comment of any data type.comment字段是可选的,可以包含任何数据类型的注释。
The operation returns a document with the following fields:该操作返回具有以下字段的文档:
info | |
lockCount (New in version 3.4) | |
ok |
mongosh provides the helper method 提供了助手方法db.fsyncUnlock().db.fsyncUnlock()。
Consider a situation where 考虑db.fsyncLock() has been issued two times. db.fsyncLock()已发出两次的情况。The following 以下fsyncUnlock operation reduces the locks taken by db.fsyncLock() by 1:fsyncUnlock操作将db.fsyncLock()所取的锁减少1:
db.adminCommand( { fsyncUnlock: 1 } )
The operation returns the following document:该操作返回以下文档:
{ "info" : "fsyncUnlock completed", "lockCount" : NumberLong(1), "ok" : 1 }
As the 由于lockCount is greater than 0, the mongod instance is locked against writes. lockCount大于0,mongod实例被锁定,无法写入。To unlock the instance for writes, run the unlock operation again:要解锁实例以进行写入,请再次运行解锁操作:
db.adminCommand( { fsyncUnlock: 1 } )
The operation returns the following document:该操作返回以下文档:
{ "info" : "fsyncUnlock completed", "lockCount" : NumberLong(0), "ok" : 1 }
The mongod instance is unlocked for writes.mongod实例已解锁以进行写入。