当前位置:网站首页>Flink connector Oracle CDC synchronizes data to MySQL in real time (oracle19c)
Flink connector Oracle CDC synchronizes data to MySQL in real time (oracle19c)
2022-07-29 05:59:00 【Denny Hui】

preparation
In this step, you need to configure Oracle. It mainly includes .
- Turn on Archive log
- Open the database and data table supplemental log
- establish CDC Users and permissions
Be careful : Do not use Oracle Of SYS and SYSTEM User as CDC user . Because these two users can capture a large number of Oracle Change information inside the database , It is unnecessary for business data .Debezium The changes captured by these two users will be filtered out .
Let's start the configuration steps . In the installation Oracle On the machine :
su - oracle
sqlplus / as sysdbaGet into Sqlplus. Then open Archive log.
alter system set db_recovery_file_dest_size = 10G;
alter system set db_recovery_file_dest = '/opt/oracle/oradata/recovery_area' scope=spfile;
shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
# Check Archive log Is it successfully opened
archive log list;Be careful :'/opt/oracle/oradata/recovery_area' If this path does not exist, you need to create it manually (Oracle Create... Under user )
- This step requires restarting the database , Please choose to operate at the right time .
- In the example
/opt/oracle/oradata/recovery_areaCatalog oracle Users need to have read and write permission . - If you execute
alter system set db_recovery_file_dest = '/opt/oracle/oradata/recovery_area' scope=spfile;Time report ORA-32001: write to SPFILE requested but no SPFILE is in use. Need to check spfile file .
show parameter spfile;
# If the output value It's empty , Description... Was not created spfile, Do the following SQL establish
create spfile from pfile;
# Shut down and restart
shutdown immediate;
startup;
# Check spfile Successful creation of
show parameter spfile;Next, make relevant important configuration :
-- Check whether the log archive is enabled
archive log list;
-- Enable supplementary logging for the captured database , So that the data changes capture the state before the changed database rows , The following describes how to configure at the database level .
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
- Create tablespace
CREATE TABLESPACE logminer_tbs DATAFILE '/home/oracle/logminer_tbs.dbf' SIZE 25M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
-- Create user family Bound tablespace LOGMINER_TBS
CREATE USER C##family IDENTIFIED BY zyhcdc DEFAULT TABLESPACE LOGMINER_TBS QUOTA UNLIMITED ON LOGMINER_TBS;
-- grant family user dba Authority
grant connect,resource,dba to C##family;
- And grant permission
GRANT CREATE SESSION TO C##family;
GRANT SELECT ON V_$DATABASE to C##family;
GRANT FLASHBACK ANY TABLE TO C##family;
GRANT SELECT ANY TABLE TO C##family;
GRANT SELECT_CATALOG_ROLE TO C##family;
GRANT EXECUTE_CATALOG_ROLE TO C##family;
GRANT SELECT ANY TRANSACTION TO C##family;
GRANT EXECUTE ON SYS.DBMS_LOGMNR TO C##family;
GRANT SELECT ON V_$LOGMNR_CONTENTS TO C##family;
GRANT CREATE TABLE TO C##family;
GRANT LOCK ANY TABLE TO C##family;
GRANT ALTER ANY TABLE TO C##family;
GRANT CREATE SEQUENCE TO C##family;
GRANT EXECUTE ON DBMS_LOGMNR TO C##family;
GRANT EXECUTE ON DBMS_LOGMNR_D TO C##family;
GRANT SELECT ON V_$LOG TO C##family;
GRANT SELECT ON V_$LOG_HISTORY TO C##family;
GRANT SELECT ON V_$LOGMNR_LOGS TO C##family;
GRANT SELECT ON V_$LOGMNR_CONTENTS TO C##family;
GRANT SELECT ON V_$LOGMNR_PARAMETERS TO C##family;
GRANT SELECT ON V_$LOGFILE TO C##family;
GRANT SELECT ON V_$ARCHIVED_LOG TO C##family;
GRANT SELECT ON V_$ARCHIVE_DEST_STATUS TO C##family;For local use Navicate Connect Oracle:

-- establish STUDENT_INFO surface
create table student_info (
sid number(10) constraint pk_sid primary key,
sname varchar2(10),
sex varchar2(2)
);
-- modify STUDENT_INFO Table to support incremental logging , First in Oracle Created in STUDENT_INFO The table executes the following statement
ALTER TABLE C##FAMILY.STUDENT_INFO ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;

thus ,Oracle Configuration complete ;
Flink CDC To configure :
Here we use Flink SQL CLI Do a demonstration :
Use the following command to switch to Flink Catalog
cd flink-1.14.0Start with the following command Flink SQL CLI:
./bin/sql-client.shWe should see CLI Welcome screen of the client .

stay Flink SQL CLI Use in Flink DDL Create table
Create a table that captures changed data from the corresponding database table .
Oracle CDC Tables can be defined as follows :
-- register an Oracle table 'student_info' in Flink SQL
Flink SQL> CREATE TABLE student_info (
SID INT NOT NULL,
SNAME STRING,
SEX STRING,
PRIMARY KEY(SID) NOT ENFORCED
) WITH (
'connector' = 'oracle-cdc',
'hostname' = 'localhost',
'port' = '1521',
'username' = 'C##family',
'password' = 'zyhcdc',
'database-name' = 'ORCLCDB',
'schema-name' = 'C##FAMILY',
'table-name' = 'STUDENT_INFO');
-- read snapshot and binlogs from products table
Flink SQL> SELECT * FROM student_info;In defining a data outflow to MySQL Table of :
-- register an Oracle table 'mysql_user' in Flink SQL
Flink SQL> CREATE TABLE mysql_user (
SID INT ,
SNAME STRING,
SEX STRING,
PRIMARY KEY(SID) NOT ENFORCED
) WITH (
'connector' = 'jdbc',
'url' = 'jdbc:mysql://localhost:3306/test_cdc',
'username' = 'root',
'password' = 'root123',
'table-name' = 'user'
);
Flink SQL> insert into mysql_user select SID,SNAME,SEX from student_info;
[INFO] Submitting SQL update statement to the cluster...
[INFO] SQL update statement has been successfully submitted to the cluster:
Job ID: 1966fdd63bb36c14908fe8e31408db58
Complete the above configuration ;Flink connector Oracle CDC Real time data synchronization to MySQL That's it ; You can test it yourself later .


If there is a primary key, it will be automatically merge.
边栏推荐
- Thinkphp6 pipeline mode pipeline use
- 『全闪实测』数据库加速解决方案
- 并发编程学习笔记 之 原子操作类AtomicReference、AtomicStampedReference详解
- 30 knowledge points that must be mastered in quantitative development [what is level-2 data]
- Laravel service container (Application of context binding)
- Flutter 绘制技巧探索:一起画箭头(技巧拓展)
- Training log 7 of the project "construction of Shandong University mobile Internet development technology teaching website"
- 主流实时流处理计算框架Flink初体验。
- Simple optimization of interesting apps for deep learning (suitable for novices)
- 超简单集成HMS ML Kit 人脸检测实现可爱贴纸
猜你喜欢

“山东大学移动互联网开发技术教学网站建设”项目实训日志四

mysql 的show profiles 使用。

与张小姐的春夏秋冬(2)

【综述】图像分类网络

Laravel service container (inheritance and events)

CMD window under Windows connects to MySQL and operates the table

这些你一定要知道的进程知识

Training log 4 of the project "construction of Shandong University mobile Internet development technology teaching website"

Realize the scheduled backup of MySQL database in Linux environment through simple script (mysqldump command backup)

Lock lock of concurrent programming learning notes and its implementation basic usage of reentrantlock, reentrantreadwritelock and stampedlock
随机推荐
Laravel service container (Application of context binding)
并发编程学习笔记 之 工具类CountDownLatch、CyclicBarrier详解
『全闪实测』数据库加速解决方案
Research on the implementation principle of reentrantlock in concurrent programming learning notes
datax安装
Print out all prime numbers between 1-100
yum本地源制作
剑指核心-TaoCloud全闪SDS助力构建高性能云服务
Intelligent security of the fifth space ⼤ real competition problem ----------- PNG diagram ⽚ converter
Reporting Service 2016 自定义身份验证
[database] database course design - vaccination database
重庆大道云行作为软件产业代表受邀参加渝中区重点项目签约仪式
D3.JS 纵向关系图(加箭头,连接线文字描述)
深入理解MMAP原理,让大厂都爱不释手的技术
Bare metal cloud FASS high performance elastic block storage solution
Android Studio 实现登录注册-源代码 (连接MySql数据库)
Training log II of the project "construction of Shandong University mobile Internet development technology teaching website"
Breaking through the hardware bottleneck (I): the development of Intel Architecture and bottleneck mining
并发编程学习笔记 之 Lock锁及其实现类ReentrantLock、ReentrantReadWriteLock和StampedLock的基本用法
nacos外置数据库的配置与使用