关于单表迁移到分表上,有没有什么好的办法,可以直接用ShardingSphere-Scaling 吗

你好,我这边都排查过了,我是本地测试,用的是root的权限
文档内检查的项都检查过了,都是OK的
只是我现在的数据库版本是:MySQL Ver 8.0.26
我想问下,现在我全量同步已经完成,增量失败的话,可以直接从增量阶段开始吗,跳过全量阶段,是直接执行:
start scaling ${scaling id}
就可以了吗

@sandynz
你好,我这边在增量的时候报了这个错,我尝试自己解决,但是没有什么思路,可以帮我看一下吗,谢谢

[INFO ] 2021-12-08 11:20:55.897 [ShardingSphere-Scaling-execute-0] o.a.s.c.c.d.AbstractInventoryDumper - dump, rowCount=1109879
[INFO ] 2021-12-08 11:21:00.688 [ShardingSphere-Scaling-execute-0] o.a.s.s.c.e.i.AbstractImporter - importer write, rowCount=1109881
[INFO ] 2021-12-08 11:21:00.698 [ShardingSphere-Scaling-execute-1] o.a.s.s.c.job.schedule.JobScheduler - All inventory tasks finished.
[INFO ] 2021-12-08 11:21:00.699 [ShardingSphere-Scaling-execute-1] o.a.s.s.c.job.schedule.JobScheduler - -------------- Start incremental task --------------
[INFO ] 2021-12-08 11:21:00.748 [ShardingSphere-Scaling-execute-1] o.a.s.s.c.e.i.AbstractImporter - importer write
[INFO ] 2021-12-08 11:21:00.748 [ShardingSphere-Scaling-execute-2] o.a.s.s.c.e.i.AbstractImporter - importer write
[INFO ] 2021-12-08 11:21:00.748 [ShardingSphere-Scaling-execute-3] o.a.s.s.c.e.i.AbstractImporter - importer write
[INFO ] 2021-12-08 11:21:00.755 [ShardingSphere-Scaling-execute-0] o.a.s.c.mysql.MySQLIncrementalDumper - incremental dump, jdbcUrl=jdbc:mysql://127.0.0.1:3306/account?serverTimezone=UTC&yearIsDateType=false&useSSL=false
[ERROR] 2021-12-08 11:21:00.795 [nioEventLoopGroup-4-1] o.a.s.cdc.mysql.client.MySQLClient - protocol resolution error
java.lang.RuntimeException: Bad handshake
	at org.apache.shardingsphere.cdc.mysql.client.netty.MySQLNegotiateHandler.channelRead(MySQLNegotiateHandler.java:100)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:302)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
	at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCodec.java:103)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)
[ERROR] 2021-12-08 11:21:00.796 [ShardingSphere-Scaling-execute-4] o.a.s.s.c.job.schedule.JobScheduler - Incremental task execute failed.
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Bad handshake
	at org.apache.shardingsphere.cdc.mysql.client.MySQLClient.waitExpectedResponse(MySQLClient.java:216)
	at org.apache.shardingsphere.cdc.mysql.client.MySQLClient.connect(MySQLClient.java:94)
	at org.apache.shardingsphere.cdc.mysql.MySQLIncrementalDumper.dump(MySQLIncrementalDumper.java:104)
	at org.apache.shardingsphere.cdc.mysql.MySQLIncrementalDumper.start(MySQLIncrementalDumper.java:96)
	at org.apache.shardingsphere.scaling.core.job.task.incremental.IncrementalTask.start(IncrementalTask.java:86)
	at org.apache.shardingsphere.schedule.core.executor.AbstractLifecycleExecutor.run(AbstractLifecycleExecutor.java:47)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
	at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:69)
	at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Bad handshake
	at io.netty.util.concurrent.DefaultPromise.get(DefaultPromise.java:350)
	at org.apache.shardingsphere.cdc.mysql.client.MySQLClient.waitExpectedResponse(MySQLClient.java:204)
	... 12 common frames omitted
Caused by: java.lang.RuntimeException: Bad handshake
	at org.apache.shardingsphere.cdc.mysql.client.netty.MySQLNegotiateHandler.channelRead(MySQLNegotiateHandler.java:100)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:302)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
	at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCodec.java:103)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	... 1 common frames omitted
[INFO ] 2021-12-08 11:21:00.796 [ShardingSphere-Scaling-execute-4] o.a.s.s.c.job.schedule.JobScheduler - stop scaling job 675298971731623936
[INFO ] 2021-12-08 11:21:00.796 [ShardingSphere-Scaling-execute-4] o.a.s.s.c.job.schedule.JobScheduler - stop inventory task 675298971731623936 - ds_0.user#0
[INFO ] 2021-12-08 11:21:00.796 [ShardingSphere-Scaling-execute-4] o.a.s.s.c.job.schedule.JobScheduler - stop incremental task 675298971731623936 - ds_0
[ERROR] 2021-12-08 11:29:56.407 [ShardingSphere-Command-1] o.a.s.p.f.c.CommandExecutorTask - Exception occur: 
java.lang.UnsupportedOperationException: unsupported table : `PROFILING`
	at org.apache.shardingsphere.proxy.backend.text.admin.mysql.MySQLInformationSchemaExecutorFactory.newInstance(MySQLInformationSchemaExecutorFactory.java:52)
	at org.apache.shardingsphere.proxy.backend.text.admin.mysql.MySQLAdminExecutorFactory.newInstance(MySQLAdminExecutorFactory.java:105)
	at org.apache.shardingsphere.proxy.backend.text.admin.DatabaseAdminBackendHandlerFactory.newInstance(DatabaseAdminBackendHandlerFactory.java:78)
	at org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandlerFactory.newInstance(TextProtocolBackendHandlerFactory.java:90)
	at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.<init>(MySQLComQueryPacketExecutor.java:55)
	at org.apache.shardingsphere.proxy.frontend.mysql.command.MySQLCommandExecutorFactory.newInstance(MySQLCommandExecutorFactory.java:73)
	at org.apache.shardingsphere.proxy.frontend.mysql.command.MySQLCommandExecuteEngine.getCommandExecutor(MySQLCommandExecuteEngine.java:60)
	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:102)
	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:77)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
[ERROR] 2021-12-08 11:30:09.656 [ShardingSphere-Command-1] o.a.s.p.f.c.CommandExecutorTask - Exception occur: 
java.lang.UnsupportedOperationException: unsupported table : `PROFILING`
	at org.apache.shardingsphere.proxy.backend.text.admin.mysql.MySQLInformationSchemaExecutorFactory.newInstance(MySQLInformationSchemaExecutorFactory.java:52)
	at org.apache.shardingsphere.proxy.backend.text.admin.mysql.MySQLAdminExecutorFactory.newInstance(MySQLAdminExecutorFactory.java:105)
	at org.apache.shardingsphere.proxy.backend.text.admin.DatabaseAdminBackendHandlerFactory.newInstance(DatabaseAdminBackendHandlerFactory.java:78)
	at org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandlerFactory.newInstance(TextProtocolBackendHandlerFactory.java:90)
	at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.<init>(MySQLComQueryPacketExecutor.java:55)
	at org.apache.shardingsphere.proxy.frontend.mysql.command.MySQLCommandExecutorFactory.newInstance(MySQLCommandExecutorFactory.java:73)
	at org.apache.shardingsphere.proxy.frontend.mysql.command.MySQLCommandExecuteEngine.getCommandExecutor(MySQLCommandExecuteEngine.java:60)
	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:102)
	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:77)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

我看了下文档,目前仅支持MySQL(5.1.15 ~ 5.7.x),我本地是用的8.0测试,是因为不支持8.0的协议吗
另外,如果是仅支持MySQL(5.1.15 ~ 5.7.x)
源库:5.6 新库8.0 可以支持吗

现在我全量同步已经完成,增量失败的话,可以直接从增量阶段开始吗,跳过全量阶段

在线重启可能还有问题,你可以试试看。
不行的话就重启下proxy进程。
任务重新开始之后会检查进度的,如果全量完成了就会自动跳过进入下一阶段。

1 个赞

我看了下文档,目前仅支持MySQL(5.1.15 ~ 5.7.x),我本地是用的8.0测试,是因为不支持8.0的协议吗

我之前看到有社区同学支持了8.0的认证协议。目前的工作重点没在支持8.0,我没测试过8.0。可能没有完整支持8.0的协议。

另外,如果是仅支持MySQL(5.1.15 ~ 5.7.x)
源库:5.6 新库8.0 可以支持吗

源端和目标端都需要在支持范围内才可以。

如果对8.0有较强需求的话,可以在ShardingSphere GitHub Discussions提建议,大家一块讨论下,可能会有社区同学来支持。

1 个赞

好的,我了解了,我自己也排查了下,即使我关闭了数据库的SSL还是不行
应该是和8.0版本有关

我刚刚通过docker创建了一个5.6的数据库,目前增量同步是OK的
目前的状态是EXECUTE_INCREMENTAL_TASK

我想问下,现在这个状态后应该怎么操作,我理解是这么操作:
check scaling xx 对数据一致性进行验证
验证新库数据正常后,stop scaling source writing xx
停止任务,或者drop scaling xx

1、如果调用一致性检查,他会停止增量同步吗,还是分开来跑

2、另外我想知道对于存在新旧shardingsphere的情况
checkout scaling xx他会哪些动作


我这边调用了check scaling
另外我在源库添加了一条记录,新库也同样有这条数据,所以我想知道这个一致性检查是怎么来操作,怎么来进行验证
这个结果是正确的吗

stopdrop只是提供了这样的功能,基本上是不需要用的。真实环境使用的时候谨慎操作。

checkcheckout是给手动模式使用的,就是clusterAutoSwitchAlgorithm没配置的情况。并且各自有使用条件。
check做数据一致性校验,那需要判断全量和增量都完成的情况下执行才有可能校验通过。
checkout是让新规则生效,前置步骤没完成是不会执行成功的。

1、如果调用一致性检查,他会停止增量同步吗,还是分开来跑

不会停止增量同步。它是在源端和目标端都没有数据变化的前提下,再做数据校验。

2、另外我想知道对于存在新旧shardingsphere的情况
checkout scaling xx他会哪些动作

符合条件的情况下直接刷新新规则到注册中心。

看起来目标端是少一条数据的。
源端的新增数据是怎么添加的?
新增的数据已经同步到目标端了么?

所以我想知道这个一致性检查是怎么来操作,怎么来进行验证

目前的默认实现是对两端的全量数据进行CRC32计算、然后比对结果。

源数据是直接通过insert into方式插入的,新增的数据确实已经同步到目标端了

我想了解下这几个状态之间的切换是怎么判断的,
即怎么从增量迁移中到基本完成,判断条件是什么
基本完成再到已完成的条件是什么

我下午看还是EXECUTE_INCREMENTAL_TASK,现在就已经是FINISHED了

我自己理解的数据步骤是:
○ 确认增量数据已全部同步完成
○ 设置只读
○ 代码发布版本
○ 数据校验
○ 关闭同步

所以我希望手动控制数据校验和关闭同步,这个可以做到吗

EXECUTE_INCREMENTAL_TASK 增量迁移中
ALMOST_FINISHED 基本完成
FINISHED 已完成

@sandynz 你好,这个问题可以帮忙解答下吗
我想了解下这几个状态之间的切换是怎么判断的,
即怎么从增量迁移中到基本完成,判断条件是什么
基本完成再到已完成的条件是什么

抱歉,刚看到。

增量迁移中到数据校验开始,是有一个检测算法来判断的,通过clusterAutoSwitchAlgorithm配置。如果配置了IDLE类型(目前自带IDLE这种兼容各种数据库类型的实现,不满足需求的话可以通过SPI自定义),那么会等待增量同步不再活动超过一定时间(通过incremental-task-idle-minute-threshold配置,默认30分钟,可自行调整)。

ALMOST_FINISHED 偏内部使用的状态,不用特别在意这个状态。目前的设置逻辑:数据校验完成之后、切换配置之前。

FINISHED 是指整个流程完成了,新规则已生效。

顺带说明下,以上配置限5.0.0版。目前正在重构scaling,下个版本会有较大调整,包括配置和相关DistSQL,大概在1月份发布。

1 个赞

好的,非常期待 :stuck_out_tongue_closed_eyes:

另外我想问下,设置为只读这一步是必要的吗
如果说一直持续检查增量同步是OK的,也需要设置为只读吗

因为我们之前使用如DTS这样的工具是基本不需要设置只读的

我还想贡献下文档,如果我提的话会考虑合入吗
如果1月份版本调整会比较大的话

另外我想问下,设置为只读这一步是必要的吗
如果说一直持续检查增量同步是OK的,也需要设置为只读吗
因为我们之前使用如DTS这样的工具是基本不需要设置只读的

据我了解DTS之类的工具是需要设置只读(停写)的。下面是之前对业界DTS产品特性的简单调研截图:

设置只读一般是系统自动操作的,不需要人工介入。当然也可以有手动模式。

存储层带多副本的情况更容易支持不停写。比如新的分布式数据库。

scaling的定位不再是第三方工具,是ShardingSphere的核心部分,未来可能更接近分布式数据库自带的扩缩容功能。

1 个赞

我还想贡献下文档,如果我提的话会考虑合入吗
如果1月份版本调整会比较大的话

欢迎贡献,可以合入。发版不影响社区贡献,早提早合入。
发版之前会检查并调整一遍文档。

1 个赞

你好,我这边提了个PR,希望可以看一下
如果有什么问题,我再修改下

1 个赞

你好,欢迎参与社区贡献。
我加了一些review comment,有时间的时候看下。

有一些是通用的文档格式要求:

  • 中文文档英文单词前后需要用空格隔开
  • URL链接都用Markdown语法、写相对路径、不直接包含中文

PR comment大致归类:

  • 论坛的回复偏口语化,还会额外带入一些解释说明,不适合放在官方文档,需要做一些调整
  • scaling引用到其他功能的话,尽量链接到相关页面,不重复写
  • 命名:proxy、scaling,不带Sharding前缀
  • 对应的英文文档也需要改下

好的,我改一下,谢谢指导 :grin:

京ICP备2021015875号