alibaba / MongoShake

MongoShake is a universal data replication platform based on MongoDB's oplog. Redundant replication and active-active replication are two most important functions. 基于mongodb oplog的集群复制工具,可以满足迁移和同步的需求,进一步实现灾备和多活功能。
GNU General Public License v3.0
1.72k stars 441 forks source link

使用2.4.2版本同步3.4 sharding到4.2版本 sharding,显示replica to sharding,不执行sharding collection #343

Closed amnesia01 closed 4 years ago

amnesia01 commented 4 years ago

[docsyncer.IsShardingToSharding:43] replication from [replica] to [sharding] 我看代码是判断mongos, 但是我配置了mongos 也没用呢

vinllen commented 4 years ago

只有sharding到sharding才会执行shard collection,源端是replica的话,目的端也无法知道按哪个shard key进行shard collection操作

amnesia01 commented 4 years ago

感谢回复!

  1. 源是sharding集群,但是版本太低不能用change stream,查了2.4.2的代码 如果增量不是change stream 会把mongosurl 清空,这样fromisharding 判断 mongos is nil 就不是sharding了。 主要是不执行shardcollection,这个手动执行也没问题吧
  2. 我自己改了下,编译了,shard collection是没问题了,但是增量 oplog执行的时候报 Failed to target upsert by query :: could not extract exact shard key。这样还不如是识别为 replica,至少复制没问题 多谢!!
vinllen commented 4 years ago
  1. 对于源端是sharding,change stream模式是从mongos拉取的,而oplog模式是从shard拉取的,所以在oplog拉取模式里面,mongos的地址是没有意义的。
  2. upsert命令是需要shard key的,正常同步应该是个update,你是启用了incr_sync.executor.upsert,文档有说明,在目的端是sharding的情况,这个参数不要启用
amnesia01 commented 4 years ago
  1. 但是在判断源端是不是sharding的时候会有问题的呀,sharding集群被判断成了replica
  2. 感谢,我再试一下
vinllen commented 4 years ago

你说的这个问题我明天验证一下

leoxu8703 commented 4 years ago

我们从3.6同步4.0以及3.4到3.6分片集群,都变成replicat to shard.无法实现分片到分片同步。预先创建分片集合则没有问题。

vinllen commented 4 years ago

感谢反馈,这个的确是bug,我近期将会release下个小版本进行修复

vinllen commented 4 years ago

2.4.4版本已经发布