需要额外下载jar包:


mysql-connector-java-8.0.20.jar
flink-connector-jdbc_2.11-1.12.0.jar
下载之后将jar放入到flink-1.12.0/lib下
下载地址:https://ci.apache.org/projects/flink/flink-docs-release-1.12/zh/dev/table/connectors/jdbc.html

启动flink集群

bin/start-cluster.sh

启动Flink sql客户端

bin/sql-client.sh embedded

编写创建表脚本测试

CREATE TABLE t_info_sjy (
 id VARCHAR, 
    sjylx VARCHAR,  
 url VARCHAR,
 port VARCHAR
) WITH (
    'connector.type' = 'jdbc',
    'connector.url' = 'jdbc:mysql://192.168.30.118:3306/jhpt?serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=false',
    'connector.table' = 't_info_sjy',
    'connector.driver' = 'com.mysql.cj.jdbc.Driver',
    'connector.username' = 'root',
    'connector.password' = 'root',
    'connector.lookup.cache.max-rows' = '5000',
    'connector.lookup.cache.ttl' = '10min'
);

select * from t_info_sjy; 查看结果

最后修改于 2021-04-15 17:27:10
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付
上一篇