Note_Logistics_Day03

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
日志服务 SLS,月写入数据量 50GB 1个月
简介: Note_Logistics_Day03

stypora-copy-images-to: img

typora-root-url: ./

Logistics_Day03:业务服务器和大数据服务器

01-[复习]-上次课程内容回顾

主要讲解Docker 基本使用:Docker是什么、Docker 基本命令(镜像image命令和容器container命令)。

Docker容器引擎:虚拟化技术,将应用运行在容器Container中,方便进行部署、测试、迁移等开发操作。

  • 1)、Docker 容器引擎,典型C/S架构,客户端Client和服务端Server
  • 2)、Docker核心组件
  • Repository注册中心中央仓库:hub.docker.com
  • 镜像image,类似模板Template,可以从中央仓库拉取pull,也可以从Dockerfile构建
  • 容器container,类似创建具体实例
  • 3)、Docker命令
  • 镜像命令:search,pull,list,rmi
  • 容器命令:查看ps,创建run,启动与停止,删除容器

02-[了解]-第3天:课程内容提纲

主要讲解:如何将业务系统(仅仅以物流系统Logistics和客户关系管理系统CRM为例)实时增量采集数据到分布式消息队列Kafka(1个业务系统存储1个Topic:一对一)。

  • 1)、Oracle数据库(物流系统Logistics):使用OGG框架实时采集
1)、业务服务器数据库
  物流系统Logistics:Oracle数据库,运行在Docker容器
  客户关系管理系统CRM:MySQL 数据库,运行在Docker容器
2)、OGG 实时采集Oracle数据库表数据
  原理架构
  【如何配置】:OGG配置,一般都是Oracle数据库DBA,直接部署到Docker容器
  使用、测试

03-[理解]-业务服务器环境概述

解压提供项目虚拟机【node1.itcast.cn】和【node2.itcast.cn】,导入到VMWare虚拟机软件中,调整虚拟机资源配置,截图如下:

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-M0btGkHr-1621469545859)(/img/image-20210519082526921.png)]

192.168.88.10     node1.itcast.cn   
192.168.88.20     node2.itcast.cn   
root/123456

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-jsjRT3jM-1621469545861)(/img/image-20210519082554668.png)]

提供2个虚拟机,如果后续使用中,发现服务不可用时,直接删除虚拟机,重新解压,再次导入使用即可。

node2.itcast.cn 虚拟机来说,导入VMware以后,首次启动时,默认情况将安装所有大数据框架服务启动,需要稍等3-5分钟(至少),所有服务启动完成,登录CM界面:http://node2.itcast.cn:7180,关闭所有服务。

CM界面登录用户名和密码:admin/admin

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-t2slojSN-1621469545862)(/img/image-20210519083517633.png)]

物流项目中,为了简化,以物流系统和CRM系统为例,将业务数据存储到数据库中:

所有服务器使用数据库,都是部署在【node1.itcast.cn】机器上,查看镜像和容器

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-vdUCadCo-1621469545862)(/img/1615773180502.png)]

如下图所示,在node1.itcast.cn镜像如下:

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-DfeZNvz2-1621469545863)(/img/1612316929449.png)]

查看node1.itcast.cn创建容器,依据存在镜像image创建,在容器中运行服务:MySQL数据库、Oracle数据库。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-eez70yZC-1621469545864)(/img/1615773268530.png)]

只要启动相应应用容器即可,比如启动MySQL数据库运行的容器,就可以使用MySQL数据库。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-QYe1JsS0-1621469545864)(/img/1615773333383.png)]

04-[掌握]-业务服务器之Oracle 数据库

首先物流系统Logistics使用Oracle数据库,采用Docker容器部署,启动容器Contanier,再启动Oracles数据库,进行访问,查看数据库database中表:物流系统相关业务表。

  • 1)、针对myoracle容器来说,启动容器以后,不会启动Oracle数据库相关服务,需要手动启动
  • 2)、Oracle数据库相关服务:数据库服务Server和监听服务Listener。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-RmjIToto-1621469545865)(/img/1615774271680.png)]

# 使用VMWare 启动node1.itcast.cn虚拟机,使用root用户(密码123456)登录
# 1) 启动容器
[root@node1 ~]# docker ps -a
cb7a41433712        kungkk/oracle11g_centos7:latest   "/bin/bash"              9 months ago        Exited (255) 6 months ago   0.0.0.0:1521->1521/tcp                                    myoracle
[root@node1 ~]# docker start myoracle
myoracle
[root@node1 ~]# docker ps
CONTAINER ID        IMAGE                             COMMAND             CREATED             STATUS              PORTS                    NAMES
cb7a41433712        kungkk/oracle11g_centos7:latest   "/bin/bash"         9 months ago        Up 11 seconds       0.0.0.0:1521->1521/tcp   myoracle
[root@node1 ~]# docker exec -it myoracle /bin/bash
# 2) 启动Oracle数据库服务
[root@node1 ~]# docker exec -it myoracle /bin/bash
[root@server01 oracle]# su - oracle
Last login: Mon Aug 31 09:00:22 UTC 2020 on pts/2
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US): No such file or directory
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US): No such file or directory
[oracle@server01 ~]$ 
[oracle@server01 ~]$ which sqlplus
/u01/app/oracle/product/11.2.0/bin/sqlplus
[oracle@server01 ~]$ 
[oracle@server01 ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.1.0 Production on Mon Mar 15 02:03:24 2021
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 1202556928 bytes
Fixed Size                  2212816 bytes
Variable Size             654314544 bytes
Database Buffers          536870912 bytes
Redo Buffers                9158656 bytes
Database mounted.
Database opened.
# 3) 启动Oracle监听服务
[root@node1 ~]# docker exec -it myoracle /bin/bash
[root@server01 oracle]# su - oracle
Last login: Mon Mar 15 02:02:42 UTC 2021 on pts/0
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US): No such file or directory
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US): No such file or directory
[oracle@server01 ~]$ 
[oracle@server01 ~]$ cd $ORACLE_HOME/bin 
[oracle@server01 bin]$ 
[oracle@server01 bin]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 15-MAR-2021 02:06:40
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
Starting /u01/app/oracle/product/11.2.0//bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/server01/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=server01)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                15-MAR-2021 02:06:42
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/server01/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=server01)(PORT=1521)))
The listener supports no services
The command completed successfully
# 当Oracle数据库服务和监听服务启动完成以后,执行如下命令,如果成功,表示服务OK
SQL> select instance_name AS "SID",host_name,version  from v$instance;
SID
--------------------------------
HOST_NAME
--------------------------------------------------------------------------------
VERSION
----------------------------------
orcl
server01
11.2.0.1.0

使用工具:DBeave数据库客户端,连接Oracle数据库

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-NdKrkrzc-1621469545865)(/img/1615774285905.png)]

创建Oracle数据库连接,填写上述配置信息,测试连接是否成功过

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-f1C6aP9a-1621469545866)(/img/1615774455827.png)]

连接到Oracle数据库,打开表,查看数据

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-w7KXjcs3-1621469545866)(/img/1615774525332.png)]

05-[掌握]-业务服务器之MySQL 数据库

客户关系管理系统CRM使用MySQL数据库存储业务数据,同样也是使用Docker 容器部署,启动容器(容器启动以后,就会启动MySQL数据库)。

启动容器,并且使用客户端DBeave连接MySQL数据库,方便操作数据库中表的数据

# 使用VMWare 启动node1.itcast.cn虚拟机,使用root用户(密码123456)登录
[root@node1 ~]# docker ps -a
CONTAINER ID        IMAGE                             COMMAND                  CREATED             STATUS                      PORTS                                                     NAMES
28888fad98c9        canal/canal-server:v1.1.2         "/alidata/bin/main.s…"   9 months ago        Exited (255) 6 months ago   2222/tcp, 8000/tcp, 11112/tcp, 0.0.0.0:11111->11111/tcp   canal-server
8b5cd2152ed9        mysql:5.7                         "docker-entrypoint.s…"   9 months ago        Exited (0) 41 hours ago                                                               mysql
cb7a41433712        kungkk/oracle11g_centos7:latest   "/bin/bash"              9 months ago        Up 18 minutes               0.0.0.0:1521->1521/tcp                                    myoracle
[root@node1 ~]# 
[root@node1 ~]# docker start mysql
mysql
[root@node1 ~]# docker ps
CONTAINER ID        IMAGE                             COMMAND                  CREATED             STATUS              PORTS                               NAMES
8b5cd2152ed9        mysql:5.7                         "docker-entrypoint.s…"   9 months ago        Up 6 seconds        0.0.0.0:3306->3306/tcp, 33060/tcp   mysql
cb7a41433712        kungkk/oracle11g_centos7:latest   "/bin/bash"              9 months ago        Up 19 minutes       0.0.0.0:1521->1521/tcp              myoracle

上述启动容器以后,数据库MySQL也就启动,首先进入容器,使用mysql命令行,连接MySQL数据库:

[root@node1 ~]# docker exec -it mysql /bin/bash
root@8b5cd2152ed9:/# 
root@8b5cd2152ed9:/# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.30-log MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| canal_tsdb         |
| crm                |
| mysql              |
| performance_schema |
| sys                |
| test               |
+--------------------+
7 rows in set (0.65 sec)
mysql> use crm ;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables ;
+--------------------------+
| Tables_in_crm            |
+--------------------------+
| crm_address              |
| crm_consumer_address_map |
| crm_customer             |
+--------------------------+
3 rows in set (0.00 sec)
mysql> select * from crm_customer limit 5 ;
+----+------+------+-------------+-------+------+------------+---------------------+----------------+-------+---------------------+---------------------+---------------------+--------+
| id | name | tel  | mobile      | email | type | is_own_reg | reg_dt              | reg_channel_id | state | cdt                 | udt                 | last_login_dt       | remark |
+----+------+------+-------------+-------+------+------------+---------------------+----------------+-------+---------------------+---------------------+---------------------+--------+
|  1 | ???  | NULL | 18*******99 | NULL  |    1 |          0 | 2013-09-10 18:54:00 |              0 |     1 | 2013-09-10 18:54:00 | 2013-09-10 18:54:00 | 2013-09-10 18:54:00 | NULL   |
|  2 | ??   | NULL | 15*******70 | NULL  |    2 |          0 | 2012-01-18 22:31:00 |              0 |     1 | 2012-01-18 22:31:00 | 2012-01-18 22:31:00 | 2012-01-18 22:31:00 | NULL   |
|  3 | ??   | NULL | 15*******22 | NULL  |    1 |          0 | 2013-02-21 07:31:00 |              0 |     1 | 2013-02-21 07:31:00 | 2013-02-21 07:31:00 | 2013-02-21 07:31:00 | NULL   |
|  4 | ???  | NULL | 15*******71 | NULL  |    1 |          0 | 2016-04-08 23:16:00 |              0 |     1 | 2016-04-08 23:16:00 | 2016-04-08 23:16:00 | 2016-04-08 23:16:00 | NULL   |
|  5 | ???  | NULL | 15*******32 | NULL  |    1 |          0 | 2010-09-28 01:07:00 |              0 |     1 | 2010-09-28 01:07:00 | 2010-09-28 01:07:00 | 2010-09-28 01:07:00 | NULL   |
+----+------+------+-------------+-------+------+------------+---------------------+----------------+-------+---------------------+---------------------+---------------------+--------+
5 rows in set (0.00 sec)
mysql> 

继续使用DBeave连接MySQL数据库,配置:

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-kY3gTe8u-1621469545867)(/img/1615774940959.png)]

选择CRM系统数据库:crm,打开某张表数据进行查看

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-cBkfjPE8-1621469545867)(/img/1615774996162.png)]

06-[掌握]-OGG 数据同步之功能概述

针对整个物流项目来说,数据采集属于实时增量采集数据,只要业务数据一旦产生,就立即将业务数据获取,进行ETL转换,存储到存储引擎中(比如Kudu数据库和Es索引等)。

  • 1)、业务数据量比较多,快速存储
  • 2)、实时性业务分析统计,快速分析

使用OGG中间件(框架)实时采集Oracle数据库表的数据,同步到Kafka分布式消息队列中。

OGG 是一种基于日志的结构化数据复制软件,它通过解析源数据库在线日志:online log或归档日志:archive log获得数据的增删改变化(数据量只有日志的四分之一左右);

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-U2k9pp4B-1621469545868)(/img/1612320791630.png)]

OGG 能够实现大量交易数据的实时捕捉,变换和投递,实现源数据库与目标数据库的数据同步,保持最少10ms的数据延迟。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-tIH4Mh89-1621469545868)(/img/1615776620433.png)]

应用场景:主要三个方面

  • 高可用(HA:High Availability)容灾
  • 数据库迁移、升级(支持跨版本、异构数据库、零宕机时间、亚秒级恢复)
  • 实时数据集成(支持异构数据库、多源数据库)

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-bwI4fXJY-1621469545869)(/img/1615776882220.png)]

07-[掌握]-OGG 数据同步之基本原理及架构

Oracle GoldenGate 实现原理是通过抽取源端的redo log 或者 archive log ,然后通过TCP/IP投递到目标端,最后解析还原应用到目标端,使目标端实现 同源端数据同步。

详细OGG如何数据同步,基本原理和架构:

  • 1)、源端(SRC):获取Oracle数据表数据,从日志文件获取
  • 管理者:MGR(Manger)
  • 第一、进程:Extract提取进程,获取日志数据文件
  • 第二、本地缓存:Local TrailFile,将日志文件数据存储到本地TrailFile文件中,缓存
  • 第三、进程:(可选)Pump进程,将本地Local TrailFile发送给目标端
  • 2)、目标端(DST):发送数据到目标,如Topic
  • 管理者:MGR(Manger)
  • 第一、进程:Collect进程,接收源端pump进程发送的数据,新版添加进程
  • 第二、远程缓存:RemoteTrailFile,目标端接收到数据文件以后,进行缓存
  • 第三、进程:Replicat进程,复制进程,解析RemoteTrailFile文件,转换JSON格式,发送到Kafka

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-M4wB1aH3-1621469545869)(/img/1612321610205.png)]

OGG采集数据时,完整结构如上如所示:分为源端SRC和目标端DST,都有自己管理进程MGR。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-qurbjIwG-1621469545870)(/img/1615777550837.png)]

Extract 进程用来捕获数据源,有三种类型:

  • 1)、initial load:加载整张表的数据,属于批量加载
  • 2)、恢复日志/事务日志:恢复数据库表的数据
  • 3)、捕获模型,实时监控日志文件,已有数据,立即捕获

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-LP2bY0Co-1621469545870)(/img/1615777650890.png)]

Data pump 是Extract的辅助可选组件,如果不配置Data pump,Extract将捕获的数据直接发给目标机器上的Collector进程。

08-[理解]-OGG 数据同步之拓扑结构及支持环境

OGG架构和原理,发现架构划分比较细(分工比较细),OGG在实际项目中,使用时,常见拓扑结构和支持环境,以后如果考虑使用OGG实时同步数据时参考。

Oracle数据库配置集群Cluster,称为Oracle RAC(Real Application Cluster

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-f1CDtZFO-1621469545870)(/img/1615778086744.png)]

由此可见,GoldenGate TDM的复制模式非常灵活,用户可以根据自己的需求选择特定的复制方式,并根据系统扩展对复制进行扩展。

源和目标的操作系统和数据库可以进行任意的组合。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-to6k01Ee-1621469545871)(/img/1615778445595.png)]

目前来说,如果企业项目使用OGG进行数据同步时,通常还是SRC为:Oracle数据库,DST:Oracle数据库或Kafka消息队列。

09-[掌握]-OGG 数据同步之测试环境准备

如何配置OGG实现实时数据同步到Kafka,无需掌握步骤,比较繁琐,让DBA完成。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-pimIV7dm-1621469545871)(/img/1615779520603.png)]

提供虚拟机【node1.itcast.cn】中Docker 容器【myoracle】已经安装完OGG(源端和目标端),只需要启动OGG的源端SRC服务和目标端DST服务即可。

  • 1)、源端SRC
  • Manager管理(mgr)、Extract进程、LocalTrail、Pump进程
  • 2)、目标端DST
  • Manager管理(mgr)、Remote Trail 、复制进程Replicat

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-wv9v9JjV-1621469545872)(/img/1612324623208.png)]

由于使用OGG实时采集Oracle数据库表数据(日志文件),将数据同步到Kafka消息对象,所以首先启动Kafka服务(先启动Zookeeper服务),打开提供【node2.itcast.cn】,使用CM界面启动ZK和Kafka服务。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-nkuzJIQ4-1621469545872)(/img/1615779939494.png)]

启动OGG配置服务,分为源端和目标端,参考提供【启动命令:Oracle数据库和OGG服务.txt】,具体命令;

#  ============= 切换到 oracle 账号,并且启动Oracle数据库 =============
# 第一步:启动源端mgr进程
[root@node1 ~]# docker exec -it myoracle /bin/bash
[root@server01 oracle]# su - oracle
Last login: Mon Mar 15 02:06:07 UTC 2021 on pts/1
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US): No such file or directory
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US): No such file or directory
[oracle@server01 ~]$ cd $OGG_SRC_HOME
[oracle@server01 src]$ ./ggsci 
Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.3 14400833 OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Aug 23 2012 20:20:21
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
GGSCI (server01) 1> start mgr
Manager started.
GGSCI (server01) 2> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                           
EXTRACT     ABENDED     EXTKAFKA    00:00:00      4598:05:35  
EXTRACT     ABENDED     PUKAFKA     00:00:00      4598:05:31  
# 第二步:启动目标端mgr进程
[root@node1 ~]# docker exec -it myoracle /bin/bash
[root@server01 oracle]# su - oracle
Last login: Mon Mar 15 03:48:01 UTC 2021 on pts/0
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US): No such file or directory
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US): No such file or directory
[oracle@server01 ~]$ cd $OGG_TGR_HOME
[oracle@server01 tgr]$ ./ggsci
start mgrOracle GoldenGate for Big Data
Version 12.3.1.1.1
Oracle GoldenGate Command Interpreter
Version 12.3.0.1.0 OGGCORE_OGGADP.12.3.0.1.0GA_PLATFORMS_170828.1608
Linux, x64, 64bit (optimized), Generic on Aug 28 2017 17:13:45
Operating system character set identified as US-ASCII.
Copyright (C) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
GGSCI (server01) 2> start mgr
Manager started.
GGSCI (server01) 3> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                           
REPLICAT    ABENDED     REKAFKA     00:00:00      4598:06:12  
# 第三步:启动源端extract进程
GGSCI (server01) 3> start EXTKAFKA
Sending START request to MANAGER ...
EXTRACT EXTKAFKA starting
# 第四步:启动源端pump进程
GGSCI (server01) 4> start PUKAFKA
Sending START request to MANAGER ...
EXTRACT PUKAFKA starting
GGSCI (server01) 5> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                           
EXTRACT     RUNNING     EXTKAFKA    4598:08:10    00:00:00    
EXTRACT     RUNNING     PUKAFKA     00:00:00      4598:07:38  
# 第五步:启动目标端replicate进程
GGSCI (server01) 4> start REKAFKA
Sending START request to MANAGER ...
REPLICAT REKAFKA starting
GGSCI (server01) 7> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                           
REPLICAT    RUNNING     REKAFKA     00:00:00      00:00:08    

使用KafkaTool工具连接Kafka集群,查看Topic信息和数据

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-m1NefDF8-1621469545873)(/img/1615780362820.png)]

10-[掌握]-OGG 数据同步之物流数据同步Kafka

采用OGG中间件将Oracle数据库表的数据实时同步到Kafka消息队列中:

  • 1)、源端 :Oracle数据库【itcast】
  • 2)、采集工具:OGG,分为SRC和DST
  • 3)、目标端:Kafka 消息队列【logistics】

测试:向Oracle数据库某张表中插入insert、更新update及删除delete操作,查看Kafka Topic中数据

目前OGG11版本,延迟性相对较大,在2s左右,需要进行合理化调参配置,到OGG12版本,很快。

  • 1)、插入数据测试
-- 插入数据INSERT
INSERT INTO ITCAST."tbl_company"("id", "company_name", "city_id", "company_number", "company_addr", "company_addr_gis", "company_tel", "is_sub_company", "state", "cdt", "udt", "remark")VALUES(11, '广州传智速递邮箱公司', 440100, NULL, '广州校区', '117.28177895734918_31.842711680531399', NULL, 1, 1, TO_DATE('2020-06-13 15:24:51','yyyy-mm-dd hh24:mi:ss'), TO_DATE('2020-06-13 15:24:51','yyyy-mm-dd hh24:mi:ss'), NULL);

同步至Kafka Topic中JSON数据

{
  "table": "ITCAST.tbl_company",
  "op_type": "I",
  "op_ts": "2021-03-15 03:57:07.000306",
  "current_ts": "2021-03-15T03:57:20.578000",
  "pos": "00000000150000001245",
  "after": {
    "id": 11,
    "company_name": "广州传智速递邮箱公司",
    "city_id": 440100,
    "company_number": null,
    "company_addr": "广州校区",
    "company_addr_gis": "117.28177895734918_31.842711680531399",
    "company_tel": null,
    "is_sub_company": 1,
    "state": 1,
    "cdt": "2020-06-13 15:24:51",
    "udt": "2020-06-13 15:24:51",
    "remark": null
  }
}
  • 2)、更新数据测试
-- 更新数据UPDATE
UPDATE ITCAST."tbl_company" SET "company_name"='广州传智速递有限公司-1' WHERE "id"=11;

同步至Kafka Topic中JSON数据

{
  "table": "ITCAST.tbl_company",
  "op_type": "U",
  "op_ts": "2021-03-15 03:59:28.000248",
  "current_ts": "2021-03-15T03:59:40.378000",
  "pos": "00000000150000001980",
  "before": {
    "id": 11,
    "company_name": "广州传智速递邮箱公司",
    "city_id": 440100,
    "company_number": null,
    "company_addr": "广州校区",
    "company_addr_gis": "117.28177895734918_31.842711680531399",
    "company_tel": null,
    "is_sub_company": 1,
    "state": 1,
    "cdt": "2020-06-13 15:24:51",
    "udt": "2020-06-13 15:24:51",
    "remark": null
  },
  "after": {
    "id": 11,
    "company_name": "广州传智速递有限公司-1",
    "city_id": 440100,
    "company_number": null,
    "company_addr": "广州校区",
    "company_addr_gis": "117.28177895734918_31.842711680531399",
    "company_tel": null,
    "is_sub_company": 1,
    "state": 1,
    "cdt": "2020-06-13 15:24:51",
    "udt": "2020-06-13 15:24:51",
    "remark": null
  }
}
  • 3)、删除数据测试
-- 删除数据DELETE
DELETE ITCAST."tbl_company" WHERE "id"=11;

同步至Kafka Topic中JSON数据

{
  "table": "ITCAST.tbl_company",
  "op_type": "D",
  "op_ts": "2021-03-15 04:01:16.000109",
  "current_ts": "2021-03-15T04:01:30.756000",
  "pos": "00000000150000002328",
  "before": {
    "id": 11,
    "company_name": "广州传智速递有限公司-1",
    "city_id": 440100,
    "company_number": null,
    "company_addr": "广州校区",
    "company_addr_gis": "117.28177895734918_31.842711680531399",
    "company_tel": null,
    "is_sub_company": 1,
    "state": 1,
    "cdt": "2020-06-13 15:24:51",
    "udt": "2020-06-13 15:24:51",
    "remark": null
  }
}

可以查看Oracle数据库日志存储,命令如下:

[root@node1 ~]# docker exec -it myoracle /bin/bash
[root@server01 oracle]# su - oracle
[oracle@server01 ~]$ source ~/.bash_profile 
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US): No such file or directory
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US): No such file or directory
[oracle@server01 ~]$ 
[oracle@server01 ~]$ cd $ORACLE_BASE/flash_recovery_area/ORCL 
[oracle@server01 ORCL]$ ll
total 4
drwxr-x---. 22 oracle oinstall 4096 Mar 15 02:03 archivelog
drwxr-x---.  2 oracle oinstall    6 May 28  2020 onlinelog
[oracle@server01 ORCL]$ ll archivelog/
drwxr-x---. 2 oracle oinstall   70 Mar 15 02:33 2021_03_15
[oracle@server01 ORCL]$ 
[oracle@server01 ORCL]$ cd archivelog/   
[oracle@server01 archivelog]$ cd 2021_03_15
[oracle@server01 2021_03_15]$ ll
total 47308
-rw-r-----. 1 oracle oinstall  2518528 Mar 15 02:03 o1_mf_1_95_j4xj46x5_.arc
-rw-r-----. 1 oracle oinstall 45922816 Mar 15 02:33 o1_mf_1_96_j4xkwl5y_.arc
file or directory
[oracle@server01 ~]$
[oracle@server01 ~]$ cd O R A C L E B A S E / f l a s h r e c o v e r y a r e a / O R C L [ o r a c l e @ s e r v e r 01 O R C L ] ORACLE_BASE/flash_recovery_area/ORCL [oracle@server01 ORCL]ORACLEBASE/flashrecoveryarea/ORCL[oracle@server01ORCL] ll
total 4
drwxr-x—. 22 oracle oinstall 4096 Mar 15 02:03 archivelog
drwxr-x—. 2 oracle oinstall 6 May 28 2020 onlinelog
[oracle@server01 ORCL]$ ll archivelog/
drwxr-x—. 2 oracle oinstall 70 Mar 15 02:33 2021_03_15
[oracle@server01 ORCL]$
[oracle@server01 ORCL]$ cd archivelog/
[oracle@server01 archivelog]$ cd 2021_03_15
[oracle@server01 2021_03_15]$ ll
total 47308
-rw-r-----. 1 oracle oinstall 2518528 Mar 15 02:03 o1_mf_1_95_j4xj46x5_.arc
-rw-r-----. 1 oracle oinstall 45922816 Mar 15 02:33 o1_mf_1_96_j4xkwl5y_.arc

         


目录
相关文章
|
7月前
|
canal 消息中间件 关系型数据库
Note_Logistics_Day04
Note_Logistics_Day04
55 0
Delivery Automatic Creation for Inter-company STO
Delivery Automatic Creation for Inter-company STO
Delivery Automatic Creation for Inter-company STO
Determination of movement type in SAP STO outbound delivery
Determination of movement type in SAP STO outbound delivery
Determination of movement type in SAP STO outbound delivery
SAP RETAIL 维护Plant Profile 报错 - No customer account group assigned to business partner grouping ZNM2
SAP RETAIL 维护Plant Profile 报错 - No customer account group assigned to business partner grouping ZNM2
SAP RETAIL 维护Plant Profile 报错 - No customer account group assigned to business partner grouping ZNM2
SAP RETAIL Allocation Rule based on Material Group(二)
SAP RETAIL Allocation Rule based on Material Group(二)
SAP RETAIL Allocation Rule based on Material Group(二)
SAP RETAIL Allocation Rule based on Material Group(一)
SAP RETAIL Allocation Rule based on Material Group(一)
SAP RETAIL Allocation Rule based on Material Group(一)
Delivery Automatic Creation for UB type STO
Delivery Automatic Creation for UB type STO
Delivery Automatic Creation for UB type STO
PAT (Advanced Level) Practice - 1087 All Roads Lead to Rome(30 分)
PAT (Advanced Level) Practice - 1087 All Roads Lead to Rome(30 分)
101 0
PAT (Advanced Level) Practice - 1107 Social Clusters(30 分)
PAT (Advanced Level) Practice - 1107 Social Clusters(30 分)
145 0
|
供应链
PAT (Advanced Level) Practice - 1079 Total Sales of Supply Chain(25 分)
PAT (Advanced Level) Practice - 1079 Total Sales of Supply Chain(25 分)
140 0