Flink CDC从 mysql 8 到 flink 1.16.2 的 flink-sql 里,数据已经同步,但flink 作业还有异常。java.lang.RuntimeException: One or more fetchers have encountered exception
at org.apache.flink.connector.base.source.reader.fetcher.SplitFetcherManager.checkErrors(SplitFetcherManager.java:225)
at org.apache.flink.connector.base.source.reader.SourceReaderBase.getNextFetch(SourceReaderBase.java:169)
at org.apache.flink.connector.base.source.reader.SourceReaderBase.pollNext(SourceReaderBase.java:130)
at org.apache.flink.streaming.api.operators.SourceOperator.emitNext(SourceOperator.java:385)
at org.apache.flink.streaming.runtime.io.StreamTaskSourceInput.emitNext(StreamTaskSourceInput.java:68)
at org.apache.flink.streaming.runtime.io.StreamOneInputProcessor.processInput(StreamOneInputProcessor.java:65)
at org.apache.flink.streaming.runtime.tasks.StreamTask.processInput(StreamTask.java:545)
at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.runMailboxLoop(MailboxProcessor.java:231)
at org.apache.flink.streaming.runtime.tasks.StreamTask.runMailboxLoop(StreamTask.java:836)
at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:785)
at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:935)
at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:914)
at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:728)
at org.apache.flink.runtime.taskmanager.Task.run(Task.java:550)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: SplitFetcher thread 0 received unexpected exception while polling the records
at org.apache.flink.connector.base.source.reader.fetcher.SplitFetcher.runOnce(SplitFetcher.java:150)
at org.apache.flink.connector.base.source.reader.fetcher.SplitFetcher.run(SplitFetcher.java:105)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
... 1 more
Caused by: org.apache.flink.util.FlinkRuntimeException: Read split MySqlSnapshotSplit{tableId=test.orders, splitId='test.orders:0', splitKeyType=[order_id
INT NOT NULL], splitStart=null, splitEnd=null, highWatermark=null} error due to org.apache.flink.util.FlinkRuntimeException: Cannot read the binlog filename and position via 'SHOW MASTER STATUS'. Make sure your server is correctly configured.
at com.ververica.cdc.connectors.mysql.debezium.reader.SnapshotSplitReader.checkReadException(SnapshotSplitReader.java:306)
at com.ververica.cdc.connectors.mysql.debezium.reader.SnapshotSplitReader.pollSplitRecords(SnapshotSplitReader.java:253)
at com.ververica.cdc.connectors.mysql.source.reader.MySqlSplitReader.fetch(MySqlSplitReader.java:76)
at org.apache.flink.connector.base.source.reader.fetcher.FetchTask.run(FetchTask.java:58)
at org.apache.flink.connector.base.source.reader.fetcher.SplitFetcher.runOnce(SplitFetcher.java:142)
... 6 more
Caused by: io.debezium.DebeziumException: org.apache.flink.util.FlinkRuntimeException: Cannot read the binlog filename and position via 'SHOW MASTER STATUS'. Make sure your server is correctly configured
at com.ververica.cdc.connectors.mysql.debezium.task.MySqlSnapshotSplitReadTask.execute(MySqlSnapshotSplitReadTask.java:120)
at com.ververica.cdc.connectors.mysql.debezium.reader.SnapshotSplitReader.lambda$submitSplit$0(SnapshotSplitReader.java:130)
... 5 more
Caused by: org.apache.flink.util.FlinkRuntimeException: Cannot read the binlog filename and position via 'SHOW MASTER STATUS'. Make sure your server is correctly configured
at com.ververica.cdc.connectors.mysql.debezium.DebeziumUtils.currentBinlogOffset(DebeziumUtils.java:130)
at com.ververica.cdc.connectors.mysql.debezium.task.MySqlSnapshotSplitReadTask.doExecute(MySqlSnapshotSplitReadTask.java:143)
at com.ververica.cdc.connectors.mysql.debezium.task.MySqlSnapshotSplitReadTask.execute(MySqlSnapshotSplitReadTask.java:115)
... 6 more?
这个异常是由于Flink无法通过'SHOW MASTER STATUS'读取binlog文件名和位置。请确保您的MySQL服务器已正确配置。您可以尝试以下方法来解决这个问题:
SHOW VARIABLES LIKE 'log_bin';
如果结果为OFF,请尝试将其设置为ON:
SET GLOBAL log_bin = ON;
GRANT REPLICATION SLAVE ON *.* TO 'your_mysql_user'@'your_mysql_host';
CREATE TABLE your_table (
...
) WITH (
'connector' = 'mysql-cdc',
'hostname' = 'your_mysql_host',
'port' = 'your_mysql_port',
'username' = 'your_mysql_user',
'password' = 'your_mysql_password',
...
);
log_bin
设置正确,并重启MySQL服务器。这是一个 Flink CDC MySQL Source 插件的问题,说明 MySQL 数据库未能正常连接到 binlog,建议您可以尝试以下操作:
检查 MySQL Server 是否正确配置为 binlog 形式并允许用户执行 SHOW MASTER STATUS 命令。
这段异常堆栈显示,Flink CDC未能正确地从MySQL 8 中读取binlog记录,并且抛出了一个异常。异常的原因可能是Flink CDC在尝试执行“SHOW MASTER STATUS”命令时遇到了错误,该命令用于获取当前binlog的位置信息。请确保您的MySQL服务器已正确配置,并且具有足够的权限来执行该命令。可以尝试以下方法尝试解决这个问题:
从MySQL到Flink 1.16.2 Flink-SQL的数据同步工作出现了一个异常。下面是异常的具体描述:
Caused by: java.lang.RuntimeException: SplitFetcher thread 0 received unexpected exception while polling the records.
这个异常意味着一个Fetcher线程在获取记录的过程中收到了一个意外的异常。Fetcher是用于读取并传输数据的一个组件,它由多个线程组成,每个线程负责读取一部分数据并将其传输给上游节点。
这个异常的具体原因可能是因为数据源的问题或者读取器的问题。我们可以先检查数据源是否健康,比如查看MySQL服务器的状态以及相应的表状态,确认没有任何异常的情况。
如果数据源没问题,我们再检查读取器的相关配置,如fetchSize
、maxConcurrentRequests
等,是否设置得合适。还可以考虑添加setRuntimeMetricEnabled(true)
来开启实时统计信息,观察数据的读取速度以及耗时情况,确认是否有异常情况。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
实时计算Flink版是阿里云提供的全托管Serverless Flink云服务,基于 Apache Flink 构建的企业级、高性能实时大数据处理系统。提供全托管版 Flink 集群和引擎,提高作业开发运维效率。