对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

fsyncUnlock(数据库命令)

fsyncUnlock

减少服务器或集群上的锁计数。 要启用写入操作,锁计数必须为零。

从MongoDB 7.0.2开始 (从6.0.11和5.0.22开始也可用) fsyncfsyncUnlock命令可以在mongos上运行以锁和解锁分片集群。

完成备份操作后,使用此命令取消阻止写入。

重要

Servers maintain an fsync lock count. The fsync command with the lock field set to true increments the lock count while the fsyncUnlock command decrements it. To enable writes on a locked server or cluster, call the fsyncUnlock command until the lock count reaches zero.

fsyncUnlock is an administrative operation. Typically you will use fsyncUnlock following a database backup operation.

提示

In mongosh, this command can also be run through the db.fsyncUnlock() helper method.

Helper methods are convenient for mongosh users, 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.

此命令可用于以下环境中托管的部署:

该命令具有以下语法:

db.adminCommand(
{
fsyncUnlock: 1,
comment: <any>
}
)

comment字段是可选的,可以包含任何数据类型的注释。

该操作返回一个包含以下字段的文档:

字段
说明

info

有关操作状态的信息

lockCount

操作后实例上剩余的锁数量。

ok

状态代码。

db.fsyncLock()考虑已发出两次 的情况。以下 操作将fsyncUnlock 占用的锁减少db.fsyncLock() 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实例已解锁,无法写入。

给本页内容打分