1、streampark-jdbc
flink-connector-jdbc-1.16.3.jar
2、mysql-cdc
flink-connector-mysql-cdc、flink-sql-connector-mysql-cdc
3、elasticsearch
flink-sql-connector-elasticsearch7、elasticsearch
4、sql示例
CREATE TABLE IF NOT EXISTS source_t_wechat_mp(
`id` bigint NOT NULL,
`fakeid` STRING NULL,
`aid` STRING NULL,
`digest` STRING NULL,
`link` STRING NULL,
`title` STRING NULL,
`is_full` STRING NULL,
`update_time` BIGINT NULL,
`created_time` Timestamp NOT NULL,
PRIMARY KEY (`id`) NOT ENFORCED
) with (
'connector' = 'mysql-cdc',
'hostname' = '172.17.66.151',
'port' = '3306',
'database-name' = 'netspider',
'username' = 'sitdbuser',
'password' = 'Topsperity31@sit',
'table-name' = 't_wechat_mp',
'scan.startup.mode' = 'initial',
'jdbc.properties.useSSL' = 'false'
);
CREATE TABLE IF NOT EXISTS source_t_wechat_mp_article (
`id` bigint NOT NULL,
`fakeid` STRING NULL ,
`mp_id` int NULL ,
`article_content` STRING ,
`created_time` Timestamp ,
PRIMARY KEY (`id`) NOT ENFORCED
) with (
'connector' = 'mysql-cdc',
'hostname' = '172.17.66.151',
'port' = '3306',
'database-name' = 'netspider',
'username' = 'sitdbuser',
'password' = 'Topsperity31@sit',
'table-name' = 't_wechat_mp_article',
'scan.startup.mode' = 'initial',
'jdbc.properties.useSSL' = 'false'
);
CREATE TABLE IF NOT EXISTS index_article_details_wechat(
dataSource STRING,
bizNo STRING,
newsId STRING,
title STRING,
brief STRING,
status STRING,
content STRING,
newsPubOrg STRING,
author STRING,
pubDate bigint,
createdTime Timestamp,
link STRING ,
PRIMARY KEY (`bizNo`) NOT ENFORCED ) WITH (
'connector' = 'elasticsearch-7',
'hosts' = 'http://172.17.66.169:9200',
'username'='tebon',
'password'='Tebon@p123!',
'index' = 'index_article_details_wechat',
'sink.bulk-flush.backoff.strategy' = 'EXPONENTIAL');
insert into index_article_details_wechat(dataSource, bizNo, newsId,title,brief ,status,content,newsPubOrg,author,pubDate,createdTime,link)
select 'qsgzh',m.aid,m.aid,m.title,m.digest,'1', a.article_content,'券商公众号','券商公众号', CAST(concat(CAST(m.update_time as String),CAST('000' as String)) as Bigint), m.created_time,m.link
from source_t_wechat_mp m INNER JOIN source_t_wechat_mp_article a on a.mp_id = m.id;