fmysql-finkcdc-doris

流程:
mysql(5.7) -> kakfa(3.3.1)-> kafka -> doris(1.0.0)


--1.mysql建表
CREATE TABLE ods_mysql2 (
 item_id BIGINT,
 source_type BIGINT
);

--2.doris建表
CREATE TABLE flink_sink1
(
    item_id      INT,
    source_type  INT
)
AGGREGATE KEY(item_id, source_type)
DISTRIBUTED BY HASH(item_id) BUCKETS 1
PROPERTIES (
"replication_num" = "1",
"in_memory" = "false",
"storage_format" = "V2"
);

--3.flink创建数据源连接表
CREATE TABLE src_mysql(
 item_id BIGINT,
 source_type BIGINT,
 PRIMARY KEY (`item_id`) NOT ENFORCED
) WITH (
 'connector' = 'mysql-cdc',
 'hostname' = 'hadoop002',
 'port' = '3306',
 'username' = 'root',
 'password' = 'root',
 'database-name' = 'test',
 'table-name' = 'ods_mysql1',
 'scan.incremental.snapshot.enabled' = 'false'
);

--4.flink创建基于kafka的ods连接表
CREATE TABLE ods_mysql_2_kafka (
 item_id BIGINT,
 source_type BIGINT,
 PRIMARY KEY (`item_id`) NOT ENFORCED
) WITH (
 'connector' = 'upsert-kafka',
 'topic' = 'mysql_2_kafka',
 'properties.bootstrap.servers' = 'hadoop001:9092',
 'properties.group.id' = 'mysql_2_kafka_group',
 'key.format' = 'json',
 'value.format' = 'json'
);

--5.flink创建基于kafka的dwd连接表
CREATE TABLE dwd_kafka_2_kafka (
 item_id BIGINT,
 source_type BIGINT,
 PRIMARY KEY (`item_id`) NOT ENFORCED
) WITH (
 'connector' = 'upsert-kafka',
 'topic' = 'kafka_2_kafka',
 'properties.bootstrap.servers' = 'hadoop001:9092',
 'properties.group.id' = 'kafka_2_kafka_group',
  'key.format' = 'json',
 'value.format' = 'json'
);

--6.flink创建基于doris的下沉表
CREATE TABLE flink_sink1 ( 
    item_id      bigint,
    source_type  bigint

WITH ( 
'connector' = 'doris', 
'fenodes' = 'hadoop001:8030', 
'table.identifier' = 'test.flink_sink1', 
'username' = 'root',
'password' = 'root' 
);

--7.执行数据流向insert into任务
insert into ods_mysql_2_kafka select * from src_mysql;
insert into dwd_kafka_2_kafka select * from ods_mysql_2_kafka;
insert into flink_sink1 select * from dwd_kafka_2_kafka;

配置返回格式
SET execution.result-mode=tableau;

start_fe.sh --daemon

CREATE TABLE src_mysql2(
 item_id BIGINT,
 source_type BIGINT
) WITH (
 'connector' = 'mysql-cdc',
 'hostname' = 'hadoop002',
 'port' = '3306',
 'username' = 'root',
 'password' = 'root',
 'database-name' = 'test',
 'table-name' = 'ods_mysql2',
 'scan.incremental.snapshot.enabled' = 'false'
);

CREATE TABLE mysql_2_doris
(
    item_id      bigint,
    source_type  bigint
)
AGGREGATE KEY(item_id, source_type)
DISTRIBUTED BY HASH(item_id) BUCKETS 1
PROPERTIES (
"replication_num" = "1",
"in_memory" = "false",
"storage_format" = "V2"
);

CREATE TABLE mysql_2_doris ( 
    item_id      bigint,
    source_type  bigint

WITH ( 
'connector' = 'doris', 
'fenodes' = 'hadoop001:8030', 
'table.identifier' = 'test.mysql_2_doris', 
'username' = 'root',
'password' = 'root' 
);

insert into mysql_2_doris select * from src_mysql2;
 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值