0

0

新加表到Oracle Golden Gate的数据复制中

php中文网

php中文网

发布时间:2016-06-07 16:46:24

|

1071人浏览过

|

来源于php中文网

原创

实现向已经上线运行的 Oracle GoldenGate 的环境中增加新的需要复制数据的表。

1.    适用版本
操作方法在任何平台的Oracle GoldenGate - Version: 10.4.0.46  及以后的版本用有效。

2.    目标
实现向已经上线运行的 Oracle GoldenGate 的环境中增加新的需要复制数据的表。

3.    方法
数据复制工具 Oracle GoldenGate 提供了两种增加方法,我们这里逐个介绍。

3.1     第一种:使用 handlecollision 参数
参数 handlecollision 应用于复制进程,就是目标库上的 replicat 进程的配置。

如果在 replicat 上配置了参数,那么复制进程工作时,将会对重复数据和丢失的数据做错误处理。

如果我们要求两点的话,使用该参数是个绝佳选择。

第一、               我们在加新表的 OGG 同步环境中时,能保证源库上对此表不做任何 DML 操作,当然 DDL 操作也不能有。

第二、       我们加了新表后,目标库上的数据不管,手工校验一次,发现不一致再手工处理也可以。

当然,在新加表的过程中,最好是源表不做任何操作。

 

以下步骤是ORACLE 官网提供的,这里不做翻译了。

i)using handlecollisions
----------------------------
1)stop the extract,pump and replicat

once the extract is stopped, wait for the pump to catch up before stopping it.

        once the pump is stopped, wait for the replicat to catch up before stopping it.
2)include the tables that you need to add into the extract parameter file and save it
3)start the extract
4)include the tables that you need to add into the extract pump parameter file and save it
5)start the pump
6)do the initial load for the the new tables( ie you can take the export and import of the new tables that need to to added for replication from source the target database)
7)Wait for the initial load(export and import) to be completed and then include the tables that you need to add into the replicat parameter file with HANDLECOLLISIONS parameter  
eg: MAP hr.dep, TARGET hr.dep, HANDLECOLLISIONS;
MAP hr.country, TARGET hr.country, HANDLECOLLISIONS;

6) start the replicat
7) once the lag becomes zero remove the HANDLECOLLISIONS from the replicat parameter file and restart the replicat
eg :-
MAP hr.dep, TARGET hr.dep;
MAP hr.country, TARGET hr.country;

note:- 4 and 5th step can be skipped if the pump is not configured.

 

3.2     第二种:不使用 handlecollision 参数
这种方法是通用的。因为在实际项目中,我们既不能保证源表的数据在操作 OGG 时无变化,由不能要求项目上接受数据差异或者丢失。

这种方法使用基于表的 SCN 方式同步差异数据。

在同步完成后,,可以除掉关于 SCN 的同步配置。方法简明扼要,很容易理解。

以下步骤是ORACLE 官网提供的,这里也不做翻译了。

Jukedeck
Jukedeck

一个由人工智能驱动的音乐创作工具,允许用户为各种项目生成免版税的音乐。

下载

ii)without using handlecollision
--------------------------------------
1) stop the extract,pump and replicat

once the extract is stopped, wait for the pump to catch up before stopping it.

        once the pump is stopped, wait for the replicat to catch up before stopping it.

2)add the new table in extract parameter file and save it
3)start the extract
4)add the new table in extract pump parameter file and save it
5)start the extract pump
6)get the current SCN from the source database
eg:-
SQL> select current_scn from v$database;

CURRENT_SCN
------------------------
5343407
7) Check that there are no open DML transactions against the table. If there are open transactions, make sure that their starting SCN is higher than the one obtained in step 4) , i.e. 5343407

8)re-sync the the newly added table from source to target(using normal export/import).
Make sure to use FLASHBACK_SCN parameter for the export.

9) Add the table in the replicat parameter file including the below option( FILTER ( @GETENV ("TRANSACTION", "CSN") > ) )as shown in the below example
eg:-
MAP source.test1, TARGET target.test1 ,FILTER ( @GETENV ("TRANSACTION", "CSN") > 5343407);
MAP source.test2, TARGET target.test2 ,FILTER ( @GETENV ("TRANSACTION", "CSN") > 5343407);

10)start the replicat

11)verify the tables on source and table and once the lag is zero remove the filter parameter from the replicat parameter file and restart.

 

4.    参数说明
HANDLECOLLISIONS | NOHANDLECOLLISIONS

Valid for  Replicat

Use the HANDLECOLLISIONS and NOHANDLECOLLISIONS parameters to control whether or not Replicat tries to resolve duplicate-record and missing-record errors when applying SQL on the target. These errors can occur during an initial load, when data from source tables is being loaded to target tables while GoldenGate is replicating transactional changes that are being made to those tables. When GoldenGate applies the replicated changes after the load is finished, HANDLECOLLISIONS causes Replicat to overwrite duplicate records in the target tables and provides alternate handling of errors for missing records.

You can use HANDLECOLLISIONS and NOHANDLECOLLISIONS in the following ways:

● You can use either HANDLECOLLISIONS or NOHANDLECOLLISIONS at the root level of the parameter file to affect all MAP statements.

● You can use HANDLECOLLISIONS and NOHANDLECOLLISIONS as on-off switches for groups of tables to enable or disable error handling as needed. One remains in effect for all subsequent MAP statements until the other is encountered.

●  You can use HANDLECOLLISIONS and NOHANDLECOLLISIONS within a MAP statement to enable and disable the functionality for a specific table. See page 204.

Any of the preceding methods can be combined. The use within a MAP statement overrides other settings. The use as a toggle overrides a global setting. For example, you could have a global NOHANDLECOLLISIONS setting, and then use HANDLECOLLISIONS within MAP statements to enable it only for certain tables.

更多Oracle相关信息见Oracle 专题页面 ?tid=12

linux

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
go语言 注释编码
go语言 注释编码

本专题整合了go语言注释、注释规范等等内容,阅读专题下面的文章了解更多详细内容。

2

2026.01.31

go语言 math包
go语言 math包

本专题整合了go语言math包相关内容,阅读专题下面的文章了解更多详细内容。

1

2026.01.31

go语言输入函数
go语言输入函数

本专题整合了go语言输入相关教程内容,阅读专题下面的文章了解更多详细内容。

1

2026.01.31

golang 循环遍历
golang 循环遍历

本专题整合了golang循环遍历相关教程,阅读专题下面的文章了解更多详细内容。

0

2026.01.31

Golang人工智能合集
Golang人工智能合集

本专题整合了Golang人工智能相关内容,阅读专题下面的文章了解更多详细内容。

1

2026.01.31

2026赚钱平台入口大全
2026赚钱平台入口大全

2026年最新赚钱平台入口汇总,涵盖任务众包、内容创作、电商运营、技能变现等多类正规渠道,助你轻松开启副业增收之路。阅读专题下面的文章了解更多详细内容。

76

2026.01.31

高干文在线阅读网站大全
高干文在线阅读网站大全

汇集热门1v1高干文免费阅读资源,涵盖都市言情、京味大院、军旅高干等经典题材,情节紧凑、人物鲜明。阅读专题下面的文章了解更多详细内容。

73

2026.01.31

无需付费的漫画app大全
无需付费的漫画app大全

想找真正免费又无套路的漫画App?本合集精选多款永久免费、资源丰富、无广告干扰的优质漫画应用,涵盖国漫、日漫、韩漫及经典老番,满足各类阅读需求。阅读专题下面的文章了解更多详细内容。

67

2026.01.31

漫画免费在线观看地址大全
漫画免费在线观看地址大全

想找免费又资源丰富的漫画网站?本合集精选2025-2026年热门平台,涵盖国漫、日漫、韩漫等多类型作品,支持高清流畅阅读与离线缓存。阅读专题下面的文章了解更多详细内容。

19

2026.01.31

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
Django 教程
Django 教程

共28课时 | 3.7万人学习

SQL 教程
SQL 教程

共61课时 | 3.6万人学习

C 教程
C 教程

共75课时 | 4.3万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号