背景: flink 1.13.2 cdh集群
报错:
[ERROR] Could not execute SQL statement. Reason: org.apache.flink.table.api.ValidationException: Could not find any factory for identifier 'mysql-cdc' that implements 'org.apache.flink.table.factories.DynamicTableFactory' in the classpath. Available factory identifiers are: blackhole datagen filesystem kafka print upsert-kafka
原因: 缺少jar包
flink cdc 依赖下载地址:
https://mvnrepository.com/artifact/com.alibaba.ververica/flink-connector-mysql-cdc/1.4.0
报错:
[ERROR] Could not execute SQL statement. Reason: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
原因: 源表中的字段类型 和 cdc创建的表中的字段类型不一致,且无法转换,修改字段类型
报错:
[ERROR] Could not execute SQL statement. Reason: org.apache.flink.table.api.ValidationException: One or more required options are missing. Missing required options are: hostname
原因: 创建表时缺少 hostname 参数
执行 select * from t_name时显示报错如下:
[ERROR] Could not execute SQL statement. Reason: java.lang.NoSuchMethodError: org.apache.flink.table.factories.DynamicTableFactory$Context.getCatalogTable()Lorg/apache/flink/table/catalog/CatalogTable;
原因: 此时采用的是flink-connector-mysql-cdc-1.3.0.jar, 我的flink版本采用的是1.13.2, 后面看了下flink 13版本的cdc需要采用1.4.0版本
当前jar包中引用的flink版本和当前使用的版本不一致, 所以更换了jar包,也就是1.4.0的cdc包后这个问题解决, 但是有新的错误
换成1.4.0之后执行仍然有报错:
[ERROR] Could not execute SQL statement. Reason: java.lang.IllegalStateException: Cannot read the binlog filename and position via 'SHOW MASTER STATUS'. Make sure your server is correctly configured
因为是自己测试, 所以采用的是standalone的mysql, 根据报错, 错误定位在mysql的binlog上;
进入mysql服务, 输入:
mysql> show master status; Empty set (0.00 sec)
显示空集合, 说明mysql没有开启binlog
查看binlog选项:
mysql> show variables like '%log_bin%'; +---------------------------------+-------+ | Variable_name | Value | +---------------------------------+-------+ | log_bin | OFF | | log_bin_basename | | | log_bin_index | | | log_bin_trust_function_creators | OFF | | log_bin_use_v1_row_events | OFF | | sql_log_bin | ON | +---------------------------------+-------+ 6 rows in set (0.00 sec)
可以看到log_bin是OFF.
解决方法在mysql 配置文件 /etc/my.cnf中
[mysqld]下添加:
server-id =1 log-bin=mysql-bin
修改后,重启mysql
再次执行, 可以正常显示表中的内容了.
参考:
Binlog中最容易踩到的坑_justlpf的专栏-CSDN博客
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)