034-解决streamsets订阅过期binlog导致无法启动问题

2,741 阅读2分钟

这是坚持技术写作计划(含翻译)的第34篇,定个小目标999,每周最少2篇。

streamsets停机时间过长,mysql master设置了自动清除binlog,服务启动时报  ERROR MysqlSource - BinaryLogClient server error: The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.

2019-07-20 11:14:19,713 [user:*admin] [pipeline:demo/demo-e2cf-4f6d-b2dc-ce7fc5aeb041] [runner:] [thread:ProductionPipelineRunnable-demo-e2cf-4f6d-b2dc-ce7fc5aeb041-demo] ERROR MysqlSource - BinaryLogClient server error: The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.
com.github.shyiko.mysql.binlog.network.ServerException: The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.
	at com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:882)
	at com.github.shyiko.mysql.binlog.BinaryLogClient.connect(BinaryLogClient.java:559)
	at com.github.shyiko.mysql.binlog.BinaryLogClient$7.run(BinaryLogClient.java:793)
	at java.lang.Thread.run(Thread.java:748)
2019-07-20 11:14:19,717 [user:*admin] [pipeline:demo/demo-e2cf-4f6d-b2dc-ce7fc5aeb041] [runner:] [thread:ProductionPipelineRunnable-demo-e2cf-4f6d-b2dc-ce7fc5aeb041-demo] ERROR ProductionPipelineRunner - Pipeline execution failed
com.streamsets.pipeline.api.StageException: MYSQL_006 - MySql server error: The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.
	at com.streamsets.pipeline.stage.origin.mysql.MysqlSource.handleErrors(MysqlSource.java:389)
	at com.streamsets.pipeline.stage.origin.mysql.MysqlSource.produce(MysqlSource.java:225)
	at com.streamsets.datacollector.runner.StageRuntime.lambda$execute$2(StageRuntime.java:295)
	at com.streamsets.pipeline.api.impl.CreateByRef.call(CreateByRef.java:40)
	at com.streamsets.datacollector.runner.StageRuntime.execute(StageRuntime.java:243)
	at com.streamsets.datacollector.runner.StageRuntime.execute(StageRuntime.java:310)
	at com.streamsets.datacollector.runner.StagePipe.process(StagePipe.java:219)
	at com.streamsets.datacollector.execution.runner.common.ProductionPipelineRunner.processPipe(ProductionPipelineRunner.java:817)
	at com.streamsets.datacollector.execution.runner.common.ProductionPipelineRunner.runPollSource(ProductionPipelineRunner.java:561)
	at com.streamsets.datacollector.execution.runner.common.ProductionPipelineRunner.run(ProductionPipelineRunner.java:385)
	at com.streamsets.datacollector.runner.Pipeline.run(Pipeline.java:529)
	at com.streamsets.datacollector.execution.runner.common.ProductionPipeline.run(ProductionPipeline.java:110)
	at com.streamsets.datacollector.execution.runner.common.ProductionPipelineRunnable.run(ProductionPipelineRunnable.java:75)
	at com.streamsets.datacollector.execution.runner.standalone.StandaloneRunner.start(StandaloneRunner.java:701)
	at com.streamsets.datacollector.execution.runner.common.AsyncRunner.lambda$start$3(AsyncRunner.java:151)
	at com.streamsets.pipeline.lib.executor.SafeScheduledExecutorService$SafeCallable.lambda$call$0(SafeScheduledExecutorService.java:226)
	at com.streamsets.datacollector.security.GroupsInScope.execute(GroupsInScope.java:33)
	at com.streamsets.pipeline.lib.executor.SafeScheduledExecutorService$SafeCallable.call(SafeScheduledExecutorService.java:222)
	at com.streamsets.pipeline.lib.executor.SafeScheduledExecutorService$SafeCallable.lambda$call$0(SafeScheduledExecutorService.java:226)
	at com.streamsets.datacollector.security.GroupsInScope.execute(GroupsInScope.java:33)
	at com.streamsets.pipeline.lib.executor.SafeScheduledExecutorService$SafeCallable.call(SafeScheduledExecutorService.java:222)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
	at com.streamsets.datacollector.metrics.MetricSafeScheduledExecutorService$MetricsTask.run(MetricSafeScheduledExecutorService.java:100)
	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: com.github.shyiko.mysql.binlog.network.ServerException: The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.
	at com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:882)
	at com.github.shyiko.mysql.binlog.BinaryLogClient.connect(BinaryLogClient.java:559)
	at com.github.shyiko.mysql.binlog.BinaryLogClient$7.run(BinaryLogClient.java:793)
	... 1 more

尝试了手动设置偏移量无果。(参考资料 MySQL Binary Log#Initial Offset
通过查看运行日志,

image.png
 
发现后台还有在运行之前的offset,突然想起在官方文档.

Note: If you change the GTID mode on the database server after you have run a pipeline with the MySQL Binary Log origin, you must reset the origin and change the format of the initial offset value. Otherwise, the origin cannot correctly read the offset. When the pipeline stops, the MySQL Binary Log origin notes the offset where it stops reading. When the pipeline starts again, the origin continues processing from the last saved offset. You can reset the origin to process all requested objects.

以及

image.png

image.png

解决办法就简单了,直接在启动时,Reset Origin即可。会从server的当前binlog进行订阅。
image.png

总结: 
多看官方文档,仔细看,另外,尽量别用翻译工具,否则类似该案例中的origin会被翻译成原点,起源等,会无法联想到sdc的一些概念用词。

参考资料