replSetSyncFrom
说明
replSetSyncFrom
Temporarily overrides the default sync target for the current
mongod
. This operation is useful for testing different patterns and in situations where a set member is not replicating from the desired host.提示
在
mongosh
中,该命令也可通过rs.syncFrom()
辅助方法运行。辅助方法对
mongosh
用户来说很方便,但它们返回的信息级别可能与数据库命令不同。如果不追求方便或需要额外的返回字段,请使用数据库命令。Run
replSetSyncFrom
in theadmin
database.
兼容性
此命令可用于以下环境中托管的部署:
MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
重要
M0、M2、M5、M10+ 和 Flex 集群不支持此命令。有关更多信息,请参阅不支持的命令。
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
该命令具有以下语法:
db.adminCommand( { replSetSyncFrom: "hostname<:port>" } )
命令字段
The command takes the following field:
行为
同步逻辑
If an initial sync operation is in progress when you run
replSetSyncFrom
, replSetSyncFrom
stops the in-progress initial sync and
restarts the sync process with the new target.
仅根据需要修改默认同步逻辑,并且始终谨慎操作。
目标
要同步的节点必须是数据集中数据的有效来源。如需从节点同步,节点必须:
有数据。在启动或恢复模式下不能是仲裁节点,必须能够响应数据查询。
可访问。
在副本集配置中是同一集的成员。
使用
members[n].buildIndexes
设置构建索引。集合中的另一个成员,以防止与自身同步。
如果尝试从落后当前节点 10 秒以上的节点复制,mongod
将记录警告,但仍会从落后的节点复制。另请参阅“复制延迟和流量控制”。
持久性
replSetSyncFrom
provide a temporary override of default behavior.
mongod
will revert to the default sync behavior in the
following situations:
For more information the use of replSetSyncFrom
, see
配置自管理辅助节点的同步目标.