Failed to prepare TableSyncChunk plugin: Cannot chunk table `ccda`.`pending_0` using the character c

来源:互联网 发布:linux 修改主机名 编辑:程序博客网 时间:2024/05/18 03:39

当我用pt-table-sync命令--print或者--execute时,报如下错误:

[root@PC ~]# pt-table-sync --replicate=ccda.checksums --tables=pending_0 --charset=utf8 h=127.0.0.1,u=root,p=system@123 h=192.168.1.202 u=root,p=system@123 --port 3307 --print > /download/diff.log

Failed to prepare TableSyncChunk plugin: Cannot chunk table `ccda`.`pending_0` using the character column _id, most likely because all values start with the same character. This table must be synced separately by specifying a list of --algorithms without the Chunk algorithm at /usr/local/bin/pt-table-sync line 4049.  while doing ccda.pending_0 on 192.168.1.202


而且,我发现,当差异量小时,并不报该错误。差异量大时,才报了这个错误。

虽然报错,但是用--execute发现,实际上也同步了大部分数据,会丢失部分数据。比如,我测试的表差异数据应该是45万条记录,但是发现只同步了34万数据。


pt-table-sync --help

查看algorithms

--algorithms=s            Algorithm to use when comparing the tables, in
                            order of preference (default Chunk,Nibble,GroupBy,
                            Stream)


--解决办法:

用Nibble算法同步(其他算法我没有试验,不知是否可行)。

pt-table-sync --algorithms=Nibble --replicate=ccda.checksums --tables=pending_0 --charset=UTF8 h=127.0.0.1,u=root,p=system@123 h=192.168.1.202 u=root,p=system@123 --port 3307 --execute


--注意:--charset=UTF8最好指定是大写的UTF8,因为我发现在有的机器上指定了小写的utf8,还是会出现中文乱码。


0 0