环境搭建
- 安装JDK11
1.JDK11下载
2.配置环境变量
根据不同的使用场景写入环境变量到文件,路径换成自己的
export JAVA_HOME=/home/lzu_admin/opt/jdk-11.0.15.1
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH
实践1—基于FlinkSQL实现MongoDB导入Oracle
-- 设置间隔时间为3秒
SET execution.checkpointing.interval = 3s;
-- 设置本地时区为 Asia/Shanghai
SET table.local-time-zone = Asia/Shanghai;
CREATE TABLE flink_eusp_form_test (
_id STRING,
name STRING,
age INT,
bri STRING,
PRIMARY KEY (_id) NOT ENFORCED
) WITH (
'connector' = 'mongodb-cdc',
'hosts' = '10.240.34.5:28001',
'username' = 'flinkuser',
'password' = 'pwd',
'database' = 'eusp_form_test',
'collection' = 'eusp_form_test'
);
--select * from flink_eusp_form_test;
CREATE TABLE flink_test_flink_sql (
TID STRING,
TNAME STRING,
AGE INTEGER,
BIR STRING,
PRIMARY KEY (TID) NOT ENFORCED
) WITH (
'connector' = 'jdbc',
'url' = 'jdbc:oracle:thin:@//152.16.137.7:40010/lzudw',
'driver' = 'oracle.jdbc.driver.OracleDriver',
'username' = 'lzudw',
'password' = '123456',
'table-name' = 'TEST_FLINK_SQL'
);
INSERT INTO flink_test_flink_sql
SELECT
t._id,
t.name,
t.age,
t.bri
FROM flink_eusp_form_test t;
- 通过对源库(MongoDB)增删改操作观察目标库(oracle)数据变化情况
实践2—…
实践3—…