db.fsyncUnlock()

On this page本页内容

Definition定义

db.fsyncUnlock()

Reduces the lock taken by db.fsyncLock() on a mongod instance by 1.db.fsyncLock()mongod实例的锁定减少1。

Important重要

The db.fsyncLock() and db.fsyncUnlock() operations maintain a lock count. db.fsyncLock()db.fsyncUnlock()操作保持锁计数。db.fsyncLock() increments the lock count, and db.fsyncUnlock() decrements the lock count.递增锁计数,db.fsyncUnlock()递减锁计数。

To unlock a mongod instance for writes, the lock count must be zero. 要解锁mongod实例进行写入,锁计数必须为零。That is, for a given number of db.fsyncLock() operations, you must issue a corresponding number of db.fsyncUnlock() operations to unlock the instance for writes.也就是说,对于给定数量的db.fsyncLock()操作,必须发出相应数量的db.fsyncUnlock()命令才能解锁实例进行写入。

db.fsyncUnlock() is an administrative operation. 是管理操作。Typically you will use db.fsyncUnlock() following a database backup operation.通常,您将在数据库备份操作之后使用db.fsyncUnlock()

db.fsyncUnlock() has the syntax:具有以下语法:

db.fsyncUnlock()

The operation returns a document with the following fields:该操作返回包含以下字段的文档:

infoInformation on the status of the operation.有关操作状态的信息。
lockCount (New in version 3.43.4版中的新增功能)The number of locks remaining on the instance after the operation.操作后实例上剩余的锁数。
okThe status code.状态代码。

The db.fsyncUnlock() method wraps the fsyncUnlock command.db.fsyncUnlock()方法包装fsyncUnlock命令。

Compatibility with WiredTiger与WiredTiger的兼容性

db.fsyncLock() ensures that the data files are safe to copy using low-level backup utilities such as cp, scp, or tar. 确保使用低级备份实用程序(如cpscptar)安全地复制数据文件。A mongod started using the copied files contains user-written data that is indistinguishable from the user-written data on the locked mongod.开始使用复制文件的mongod包含用户写入的数据,这些数据与锁定mongod上的用户写入数据无法区分。

The data files of a locked mongod may change due to operations such as journaling syncs or WiredTiger snapshots. 锁定mongod的数据文件可能会因日志同步WiredTiger快照等操作而更改。While this has no affect on the logical data (e.g. data accessed by clients), some backup utilities may detect these changes and emit warnings or fail with errors. 虽然这对逻辑数据(例如客户端访问的数据)没有影响,但一些备份实用程序可能会检测到这些更改并发出警告或错误失败。For more information on MongoDB- recommended backup utilities and procedures, see MongoDB Backup Methods.有关MongoDB推荐的备份实用程序和过程的更多信息,请参阅MongoDB备份方法

Example示例

Consider a situation where db.fsyncLock() has been issued two times. 考虑db.fsyncLock()已发出两次的情况。The following db.fsyncUnlock() operation reduces the locks taken by db.fsyncLock() by 1:以下db.fsyncUnlock()操作将db.fsyncLock()占用的锁减少1:

db.fsyncUnlock()

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 db.fsyncLock() again:要解锁实例进行写入,请再次运行db.fsyncLock()

db.fsyncUnlock()

The operation returns the following document:该操作返回以下文档:

{ "info" : "fsyncUnlock completed", "lockCount" : NumberLong(0), "ok" : 1 }

The mongod instance is unlocked for writes.mongod实例被解锁以进行写入。

←  db.fsyncLock()db.getCollection() →