DROP TABLE IF EXISTS `user_flink_primary_from`;
CREATE TABLE `user_flink_primary_from` (
`id` int(11) NOT NULL,
`user_name` varchar(200) DEFAULT NULL,
`create_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`age` int(3) DEFAULT NULL,
`remark` varchar(200) DEFAULT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
------------------------------------
DROP TABLE IF EXISTS `user_flink_primary_to`;
CREATE TABLE `user_flink_primary_to` (
`id` int(11) NOT NULL,
`user_name` varchar(200) DEFAULT NULL,
`create_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`age` int(3) DEFAULT NULL,
`remark` varchar(200) DEFAULT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
------------------------------------
#创建虚拟mysql表
CREATE TABLE user_flink_primary_from (
id int,
user_name string,
create_time timestamp(3),
age int,
remark string,
PRIMARY KEY (id) not ENFORCED
) WITH (
'connector' = 'mysql-cdc',
'hostname' = '172.22.46.34',
'port' = '3306',
'username'= 'root',
'password' = 'xxx',
'database-name' = 'flink',
'table-name' = 'user_flink_primary_from'
)
------------------------------------
#创建虚拟mysql表
CREATE TABLE user_flink_primary_to (
id int,
user_name string,
create_time timestamp(3),
age int,
remark string,
PRIMARY KEY (id) not ENFORCED
) WITH (
'connector'= 'jdbc',
'url' = 'jdbc:mysql://172.22.46.33:3306/flink?characterEncoding=utf8&useSSl=false&serverTimezone=Asia/Shanghai',
'username'= 'root',
'password' = 'xxx',
'table-name' = 'user_flink_primary_to',
'driver' = 'com.mysql.jdbc.Driver',
'scan.fetch-size' = '200'
)
------------------------------------
insert into user_flink_primary_to select * from user_flink_primary_from;
文章来源:https://www.toymoban.com/news/detail-618345.html
文章来源地址https://www.toymoban.com/news/detail-618345.html
到了这里,关于flink实时同步的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!