Database Manual / Reference / Database Commands / Replication

appendOplogNote (database command数据库命令)

Definition定义

appendOplogNote
Writes a non-operational entry to the oplog.将非操作性条目写入oplog

Compatibility兼容性

This command is available in deployments hosted in the following environments:此命令在以下环境中托管的部署中可用:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud:云中MongoDB部署的完全托管服务

Important

This command is not supported in M0 and Flex clusters. For more information, see Unsupported Commands.M0和Flex集群不支持此命令。有关详细信息,请参阅不支持的命令

  • MongoDB Enterprise: The subscription-based, self-managed version of MongoDB:MongoDB的基于订阅的自我管理版本
  • MongoDB Community: The source-available, free-to-use, and self-managed version of MongoDB:MongoDB的源代码可用、免费使用和自我管理版本

Syntax语法

You can only run the appendOplogNote command on the admin database.您只能在admin数据库上运行appendOplogNote命令。

The command has this syntax:该命令具有以下语法:

db.adminCommand(
{
appendOplogNote: 1,
data: <document>
}
)

Command Fields命令字段

Field字段Type类型Description描述
appendOplogNoteany任意Set to any value.设置为任何值。
datadocument文档The document to append to the oplog.要附加到oplog的文档。

Example示例

To append a non-operational entry to the oplog, use the db.adminCommand() method:要将非操作条目附加到oplog,请使用db.adminCommand()方法:

db.adminCommand(
{
appendOplogNote: 1,
data: {
msg: "Appending test message to oplog"
}
}
)

Example oplog entry:oplog条目示例:

{
op: "n",
ns: "",
o: {
msg: "Appending test message to oplog"
},
ts: Timestamp({ t: 1689177321, i: 1 }),
t: Long("1"),
v: Long("2"),
wall: ISODate("2023-07-12T15:55:21.180Z")
}