Initial load:This specifies the Direct Load data synchronization
initial load 初始加载数据同步,直接从源端数据同步数据到目标端数据库
下面开始配置initial load。
准备阶段
环境
这里使用VMware 虚拟机安装了两个Oracle Linux 6.3 操作系统,使用centos 也没有关系,Linux内核都一样,具体怎么使用VM安装Linux,过后也会有教程出来。
下面是两台机器(虚拟机)的配置情况:
role | 机器 host | 数据库 | GlodenDate | hostname | sid |
---|---|---|---|---|---|
source(源端) | 192.168.1.211 | Oracle 11gR2 11.2.0.4 | 12.2.0.1.1 | vmsl | orcl |
target(目标端) | 192.168.1.212 | Oracle 11gR2 11.2.0.4 | 12.2.0.1.1 | target | orcl |
数据库
环境准备好之后,Oracle需要进行以下几步操作:
1. Enabling the archive log mode on the source database(打开日志归档模式),Enabling supplemental logging
source端的操作
打开归档模式
再次查看状态
这里还需要设置Enabling supplemental logging
再次查看状态
2. Creating the GoldenGate administrator user on the target database
Before we start to configure GoldenGate, we need to create an admin user, grant all the necessary privileges, and enable the GoldenGate replication.
在Source 端 和 Target 端分别创建OGG管理用户并赋予权限:
这里贴出source 端操作截图,target 端 同样操作即可
We can also store the GoldenGate user’s database logon credentials using the Credential Store. To do this, firstly, create the wallet and then add the credentials,including the TNS alias to connect to the source container database.
这里可以创建一个用户认证,在extract 进程中可以使用这个认证来配置,下文会使用到
需要的密码就是ggadmin 的密码,密码输入错误会导致这个认证没有用。
在source端 alias 的名称为 srcdb
在target 端 alias 的名称为 tgtdb
domain 都为 admin
以下是 source端的演示截图,target 同样操作即可。
For an Oracle11.2.0.4 database, this has to be explicitly set through the database initialization parameter: ENABLE_GOLDENGATE_REPLICATION=true.
source 和 target 做相同操作
3. source端和target端建好数据表,并在source端数据表中插入数据
在ogg_home 目录中有如下两个sql文件
使用create 文件的创建表(源端和目标端都要创建)
使用insert 文件在source端插入数据
4. Enabling the transaction data capture
GGSCI 命令下登录数据库
设置需要同步的表,捕获表得日志信息
查看捕获表的信息
5. Preparing the operating system
切换root用户,编辑hosts文件,vi/etc/hosts
oracle listener配置
tnsnames.ora
source 端和 target 端都可以参照上述配置。
配置流程
原理图
1. 开启source 端Mgr 进程
进入OGG_HOME,运行 GGSCI 命令
编辑 mgr 的参数配置,使用下面的命令:
edit params mgr
ogg 默认的端口是7809,mgr的配置文件是在ogg_home 目录下的dirprm文件下的,dirprm文件夹存放所有的进程配置文件,进程文件后缀名prm。如果想要编辑mgr的参数,也可以直接进入到这个目录下直接编辑mgr.prm 文件,但通常推荐是在GGSCI下使用edit params 的方式 来编辑,这个方式也是后面配置其他进程例如extract ,replicat 的主要方式。
使用 start mgr 命令启动,使用 info 命令查看mgr 状态
2. 配置抓取进程(extract进程)
source 端
内容如下:
create the ELOAD01 Extract group
4.开启target 端的Mgr 进程
5.create the Replicat’s parameter file
配置 replicat 进程,名称是rload01,上面extract 配置文件中已经指定了。
参数如下:
create the Replicat group called RLOAD01 for the initialload
这里如果没有加上 specialrun 的参数会报错
8.开启source 端的 Extract 进程
查看启动状态,使用
//view report process_name
view report eload01
log 比较长,这里只截取最前一段后最后一段
最后说明有哪些同步操作,insert ,update,delete 。。。。。。
9.在target 端验证一下,看数据有没有过去
target 端只是使用demo_ora_create 文件创建了表,没有insert 数据,如果查到了数据,说明initial load 成功了。