Description描述
replSetSyncFromTemporarily 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.mongod的默认同步目标。此操作对于测试不同模式以及在集合成员未从所需主机复制的情况下非常有用。Tip
In在mongosh, this command can also be run through thers.syncFrom()helper method.mongosh中,此命令也可以通过rs.syncFrom()辅助方法运行。Helper methods are convenient for助手方法对mongoshusers, but they may not return the same level of information as database commands.mongosh用户来说很方便,但它们可能不会返回与数据库命令相同级别的信息。In cases where the convenience is not needed or the additional return fields are required, use the database command.如果不需要便利性或需要额外的返回字段,请使用database命令。Run在replSetSyncFromin theadmindatabase.admin数据库中运行replSetSyncFrom。
Compatibility兼容性
This command is available in deployments hosted in the following environments:此命令在以下环境中托管的部署中可用:
- 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的源代码可用、免费使用和自我管理版本
Important
This command is not supported in MongoDB Atlas clusters. MongoDB Atlas集群不支持此命令。For information on Atlas support for all commands, see Unsupported Commands.有关Atlas支持所有命令的信息,请参阅不支持的命令。
Syntax语法
The command has the following syntax:该命令具有以下语法:
db.adminCommand(
{
replSetSyncFrom: "hostname<:port>"
}
)Command Fields命令字段
The command takes the following field:该命令包含以下字段:
replSetSyncFrom |
|
Behavior行为
Limitations局限性
For 为了使replSetSyncFrom to override the default sync target, settings.chainingAllowed must be set to true.replSetSyncFrom覆盖默认同步目标,settings.chainingAllowed必须设置为true。
If 如果settings.chainingAllowed is set to false, replSetSyncFrom returns ok:1 but does not set the sync target.settings.chainingAllowed设置为false,replSetSyncFrom将返回ok:1,但不设置同步目标。
Starting in MongoDB 5.0.2, you can override 从MongoDB 5.0.2开始,您可以通过将服务器参数settings.chainingAllowed by setting the server parameter enableOverrideClusterChainingSetting to true. This allows syncing from a Secondary member even if settings.chainingAllowed is false.enableOverrideClusterChainingSetting设置为true来覆盖settings.chainingAllowed。这允许从次要成员进行同步,即使settings.chainingAllowed为false。
Sync Logic同步逻辑
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.replSetSyncFrom时正在进行初始同步操作,replSetSyncFrom将停止正在进行的初始同步,并重新启动与新目标的同步过程。
Only modify the default sync logic as needed, and always exercise caution.仅根据需要修改默认同步逻辑,并始终保持谨慎。
Target目标
The member to sync from must be a valid source for data in the set. To sync from a member, the member must:要同步的成员必须是集合中数据的有效来源。要从成员同步,该成员必须:
Have data. It cannot be an arbiter, in startup or recovering mode, and must be able to answer data queries.有数据。在启动或恢复模式下,它不能是仲裁器,必须能够回答数据查询。Be accessible.易于接近。Be a member of the same set in the replica set configuration.成为副本集配置中同一集的成员。Build indexes with the使用members[n].buildIndexessetting.members[n].buildIndexes设置构建索引。A different member of the set, to prevent syncing from itself.集合中的另一个成员,以防止从其自身同步。
If you attempt to replicate from a member that is more than 10 seconds behind the current member, 如果您尝试从落后于当前成员10秒以上的成员进行复制,mongod will log a warning but will still replicate from the lagging member. See also Replication Lag and Flow Control.mongod将记录警告,但仍将从落后成员进行复制。另请参见复制延迟和流控制。
Persistence坚持
replSetSyncFrom provide a temporary override of default behavior. 提供默认行为的临时覆盖。在以下情况下,mongod will revert to the default sync behavior in the following situations:mongod将恢复到默认同步行为:
For more information the use of 有关使用replSetSyncFrom, see Configure a Self-Managed Secondary's Sync Target.replSetSyncFrom的更多信息,请参阅配置自管理辅助服务器的同步目标。