注意
This page applies to Atlas Infinite clusters and Atlas Core clusters. On an Atlas Infinite cluster, you can read the oplog collection as described on this page, but you can't set an oplog size. The collection serves change streams and some internal functions rather than replication, which the storage layer handles. To learn how the oplog behaves on an Atlas Infinite cluster, see Oplog on Atlas Infinite clusters.
oplog 是一个特殊的固定大小集合,它记录修改数据库中存储的数据的操作。
You must precede a $regex query on an oplog in a Free cluster or a Flex cluster with a carat (^). Otherwise, the following error occurs:
MongoServerError: Oplog ns RegEx queries must begin with ^
添加具有 Oplog 访问权限的用户
要访问 oplog,数据库用户必须具有 local 数据库的读取权限。要创建对 local 具有读取权限的用户:
AtlasGoDatabase & Network Access在Atlas中,Go项目的 页面。
如果尚未显示,请从导航栏上的 Organizations 菜单中选择包含项目的组织。
如果尚未显示,请从导航栏的 Projects 菜单中选择您的项目。
在侧边栏中,单击 Security 标题下的 Database & Network Access。
The Database & Network Access page displays after you complete the preceding steps.
访问 Oplog
Connect to your cluster with the
mongosh, using the credentials of the new database user with access to thelocaldatabase.切换到
local数据库。> use local
注意
要增加集群 oplog 大小,请参阅设置 Oplog 大小。
您无法使用 MongoDB 命令 replSetResizeOplog 来调整 oplog 的大小。