`

GoldenGate DDL配置详解(原创)

 
阅读更多

前言

OS:RHEL 5.4   Oracle:10.2.0.1   GoldenGate:11.2.0.1 For Oracle 10g

注意事项:

1、用户的默认表空间不要指定为SYSTEM,否则在初始化DDL支持时可能会遇到段无法扩展,或包无法编译等错误。
正式应用的话,需要注意ogg用户所在表空间是否有充足的空间。

2、以SYSDBA身份登录到SQL*Plus,此时应该断开所有连接到ORACLE数据库的会话,并且不再允许创建新会话,仅保留刚刚创建的SYSDBA身份登录的SQL*Plus。

配置DDL支持

1、关闭数据库回收站:

SQL>alter system set recyclebin=off scope=both;

2、编辑globals参数文件,标明支持DDL的GG对象存放在哪个schema下:

GGSCI>view param ./globals

GGSCHEMA ogg  

如果由于某些特殊的需求自定义DDL相关对象的名称的话,可以通过重定义位于GoldenGate软件安装目录下params.sql文件中的相关变量值,再配置GLOBALS,新增对象名称的对应关系,例如:
MARKERTABLE <new_table_name>
DDLTABLE <new_table_name>
前者表示Marker表,后一个表示DDL历史表。

一般情况下不需要修改,ORACLE也建议保持数据库对象默认值,该操作为可选操作

3、执行所需脚本

备忘清单

marker_setup.sql

ddl_setup.sql

role_setup.sql

Grant the role to all GoldenGate Extract users

ddl_enable.sql

install and use the optional performance tool

$ cd /home/oracle/ogg

$ sqlplus / as sysdba;

marker_setup.sql

该脚本用于创建DDL的marker表GGS_MARKER,用于存储DDL信息,该表只进行insert操作

SQL> @marker_setup

Marker setup script

You will be prompted for the name of a schema for the GoldenGate database objects.

NOTE: The schema must be created prior to running this script.

NOTE: Stop all DDL replication before starting this installation.

Enter GoldenGate schema name: ogg

Marker setup table script complete, running verification script...

Please enter the name of a schema for the GoldenGate database objects:

Setting schema name to OGG

MARKER TABLE

-------------------------------

OK

MARKER SEQUENCE

-------------------------------

OK

Script complete.

ddl_setup.sql

该脚本创建了进行DDL复制抽取和复制所需的对象

SQL> @ddl_setup

GoldenGate DDL Replication setup script

Verifying that current user has privileges to install DDL Replication...

Checking user sessions...

Check complete.

You will be prompted for the name of a schema for the GoldenGate database objects.

NOTE: For an Oracle 10g source, the system recycle bin must be disabled. For Oracle 11g and later, it can be enabled.

NOTE: The schema must be created prior to running this script.

NOTE: Stop all DDL replication before starting this installation.

Enter GoldenGate schema name: ogg

You will be prompted for the mode of installation.

To install or reinstall DDL replication, enter INITIALSETUP

To upgrade DDL replication, enter NORMAL

Enter mode of installation:INITIALSETUP

Working, please wait ...

Spooling to file ddl_setup_spool.txt

Using ogg as a GoldenGate schema name, INITIALSETUP as a mode of installation.

Working, please wait ...

DDL replication setup script complete, running verification script...

Please enter the name of a schema for the GoldenGate database objects:

Setting schema name to ogg

DDLORA_GETTABLESPACESIZE STATUS:

.....................

.....................

Analyzing installation status...

STATUS OF DDL REPLICATION

-----------------------------------------------------------------------------------

SUCCESSFUL installation of DDL Replication software components

Script complete.

role_setup.sql

创建DDL复制所需的对象

SQL> @role_setup

GGS Role setup script

This script will drop and recreate the role GGS_GGSUSER_ROLE

To use a different role name, quit this script and then edit the params.sql script to change the gg_role parameter to the preferred name. (Do not run the script.)

You will be prompted for the name of a schema for the GoldenGate database objects.

NOTE: The schema must be created prior to running this script.

NOTE: Stop all DDL replication before starting this installation.

Enter GoldenGate schema name: ogg

Wrote file role_setup_set.txt

PL/SQL procedure successfully completed.

Role setup script complete

Grant this role to each user assigned to the Extract, GGSCI, and Manager processes, by using the following SQL command:

GRANT GGS_GGSUSER_ROLE TO <loggedUser>

where <loggedUser> is the user assigned to the GoldenGate processes.

按照上面返回的提示,执行授权操作,注意是将权限授予执行Extract/GGSCI或其它管理操作的用户,我们这里的情况看显然是ggate,执行命令如下:

SQL> GRANT GGS_GGSUSER_ROLE TO GGATE;

Grant succeeded.

ddl_enable.sql

启用DDL复制,实质上是创建触发器,用以想MARKER和HISTORY表插入DDL信息

SQL> @ddl_enable

Trigger altered.

安装性能优化工具 (可选项)

要提高DDL触发器的性能,可以通过ddl_pin脚本,该脚本会将触发器使用的包加载到内存,以此提高效率。该脚本执行时需要引用dbms_shared_pool系统包,因此在使用ddl_pin脚本前需要确保dbms_shared_pool可用。

SQL> @?/rdbms/admin/dbmspool.sql

Package created.

Grant succeeded.

View created.

Package body created.

执行ddl_pin脚本需要指定GoldenGate管理员schema名称,例如:

SQL> @ddl_pin ggate

PL/SQL procedure successfully completed.

PL/SQL procedure successfully completed.

PL/SQL procedure successfully completed.

4、配置抽取和复制进程

抽取进程配置如下

GGSCI (rac1) 44> view params eora
extract eora
userid ogg,password ogg
exttrail ./dirdat/et
rmthost 192.168.1.112, mgrport 7500
rmttrail ./dirdat/rt
ddl 
include all

table hr.*;

抽取复制配置如下

GGSCI (rac2) 17> view params pora
replicat pora
setenv(ORACLE_SID=orcl)
userid ogg, password ogg
assumetargetdefs

handlecollisions
discardfile ./dirrpt/pora.dsc, purge

ddl include all

ddlerror default ignore retryop
map hr.*, target hr.*;

源端进程状态

GGSCI (rac1) 45> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                           
EXTRACT     RUNNING     EORA        00:00:00      00:00:00   

目标端进程状态

GGSCI (rac2) 90> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                           
REPLICAT    RUNNING     PORA        00:00:00      00:00:00 

验证

在Source DB 上创建一张测试表:

 SQL> conn dave/dave;

Connected.

SQL> create table anqing as select *from sys.all_users;

Table created.

到Target DB上验证:

SQL> select count(1) from anqing;

  COUNT(1)

----------

       33

DDL 同步验证成功。

DDL参数语法说明
在配置DDL复制时,需要在Extract 和Replicat 进程的配置文件里添加ddl属性。下面简要减少下这个属性的常用参数,参考至《OGG Windows and UNIX Reference Guide》,英文较简单,我也就不一字一句的翻译了。
DDL语句包含的主要语法如下:
DDL [
{INCLUDE | EXCLUDE}
[, MAPPED | UNMAPPED | OTHER | ALL]
[, OPTYPE <type>]
[, OBJTYPE ‘<type>’]
[, OBJNAME “<name>”]
[, INSTR ‘<string>’]
[, INSTRCOMMENTS ‘<comment_string>’]
]
[...]

{INCLUDE | EXCLUDE}
Use INCLUDE and EXCLUDE to identify the beginning of an inclusion or exclusion clause.
(1)  An inclusion clause containsfiltering criteria that identifies the DDL that this parameter will affect.
(2)  An exclusion clause containsfiltering criteria that excludes specific DDL from this parameter.
The inclusion orexclusion clause must consist of the INCLUDE or EXCLUDE keyword followed by anyvalid combination of other options of the parameter that is being applied.
If you use EXCLUDE, you must create acorresponding INCLUDE clause.
--如果要使用Exclude,那么必须先指定include。
For example, the following is invalid:
DDL EXCLUDE OBJNAME  “hr.*”
--这种语法是错误的。
However, you can use either of thefollowing:
DDL INCLUDE ALL,EXCLUDE OBJNAME “hr.*”
DDL INCLUDE OBJNAME “fin.*”  EXCLUDE  “fin.ss”         --正确语法
An EXCLUDE takes priority over any INCLUDEs that contain the same criteria. You can use multipleinclusion and exclusion clauses.
[, MAPPED | UNMAPPED | OTHER | ALL]
Use MAPPED, UNMAPPED,OTHER, and ALL to apply INCLUDE or EXCLUDE based on the DDL operation scope.
1、MAPPED applies INCLUDE or EXCLUDE to DDL operations that are of MAPPED scope. MAPPED filtering is performed beforefiltering that is specified with other DDL parameter options.
2、UNMAPPED applies INCLUDE or EXCLUDE to DDL operations that are of UNMAPPED scope.
3、OTHER applies INCLUDE or EXCLUDE to DDL operations that are of OTHER scope.
4、ALL applies INCLUDE or EXCLUDE to DDL operations of all scopes.

关于这四种scope的具体范围详见官方文档《OGG Windows and UNIX Reference Guide》
OPTYPE <type>
Use OPTYPE toapply INCLUDE or EXCLUDE to a specific type of DDL operation, such as CREATE, ALTER,and RENAME. For <type>, use any DDL command that is valid for thedatabase.
For example, to include ALTER operations,the correct syntax is:
DDL INCLUDE OPTYPE ALTER
OBJTYPE‘<type>’
Use OBJTYPE to apply INCLUDE or EXCLUDE to a specific type of database object. For <type>,use any object type that is valid for the database, such as TABLE, INDEX, and TRIGGER.For an Oracle materialized view and materialized views log, the correct typesare snapshot and snapshot log, respectively. Enclose the name of the objecttype within single quotes.
For example:
DDL INCLUDE OBJTYPE ‘INDEX’
DDL INCLUDE OBJTYPE ‘SNAPSHOT’

For Oracle object type USER, do not use the OBJNAME option, because OBJNAME expects “owner.object” whereas USER only has aschema.
OBJNAME“<name>”
Use OBJNAME toapply INCLUDE or EXCLUDE to the fully qualified name of an object, for example owner.table_name.This option takes a doublequoted string as input. You can use a wildcard onlyfor the object name.
Example:
DDL INCLUDE OBJNAME “accounts.*”
Do not use OBJNAME for the Oracle USER object,because OBJNAME expects “owner.object” whereas USER only has a schema.
When using OBJNAMEwith MAPPED in a Replicat parameter file, the value for OBJNAME must refer tothe name specified with the TARGET clause of the MAP statement. For example,given the following MAP statement, the correct value is OBJNAME “fin2.*”.
MAP fin.exp_*,TARGET fin2.*;
In the following example, a CREATE TABLE statementexecutes like this on the source:
CREATE TABLE fin.exp_phone;
And like this on the target:
CREATE TABLE fin2.exp_phone;
If a target owner is not specified in the MAP statement, Replicat maps it to the database user that is specified with the USERID parameter.
For DDL that creates triggers, synonyms, and indexes, the value for OBJNAME must be the name of the base object, not the name of the trigger, synonym, or index.
For example, to include the following DDL statement, the correct value is “hr.accounts,” not “hr.insert_trig.”
CREATE TRIGGER hr.insert_trig ON hr.accounts;
For RENAME operations,the value for OBJNAME must be the new table name. For example, to include the following DDL statement, the correct value is “hr.acct.”
ALTER TABLE hr.accounts RENAME TO acct;
The following is an example of how tocombine DDL parameter options.
 DDL    &
INCLUDE UNMAPPED &
    OPTYPE alter &
    OBJTYPE ‘table’ &
    OBJNAME users.tab* &
INCLUDE MAPPED OBJNAME * &
EXCLUDE MAPPED OBJNAME temporary.tab"


参考至: 《OGG Windows and UNIX Reference Guide》

                《OGG Installation and Setup Guide》

                http://junsansi.itpub.net/post/29894/521800

                http://blog.csdn.net/tianlesoftware/article/details/6981358
本文原创,转载请注明出处、作者

如有错误,欢迎指正

邮箱:czmcj@163.com

15
17
分享到:
评论

相关推荐

    oracle goldengate ddl

    ### Oracle GoldenGate DDL配置详解 #### 一、GoldenGate简介 Oracle GoldenGate是一种高性能的数据复制解决方案,能够实现实时的数据加载与复制,支持多种异构数据库环境之间的数据同步。GoldenGate不仅支持DML...

    配置GoldenGate同步DDL语句

    配置GoldenGate同步DDL语句 GoldenGate 是一种数据 replication 和集成工具,能够在异构数据库之间进行数据实时同步和复制。在配置GoldenGate同步DDL语句之前,需要完成一系列的预安装先决步骤,以确保GoldenGate...

    goldengate安装配置

    #### 三、Goldengate同DDL配置详解 在Goldengate进行同DDL(Data Definition Language)配置时,需要执行一系列脚本来设置GoldenGate的相关功能。这些脚本通常位于Goldengate的安装目录下,例如: ```bash ...

    Goldengate安装配置

    ### Goldengate安装配置知识点详解 #### 一、GoldenGate简介 GoldenGate是Oracle公司推出的一款高性能、高可用性的数据复制软件。它提供了一个统一的平台,能够在任何企业环境中实现秒级的数据同步与灾难恢复。...

    Oracle GoldenGate 安装配置详细手册

    2. **定义数据源**:确定需要复制的表或表空间,创建GoldenGate的DDL(数据定义语言)文件。 3. **编写GoldenGate参数文件**:配置extract、pump和replicat进程的参数,指定日志文件位置、数据库连接信息等。 4. **...

    oracle goldengate安装配置

    oracle goldengate安装配置

    goldengate如何安装和配置

    GoldenGate 安装和配置 GoldenGate 是一款数据复制和集成工具,支持多种类型的数据库,包括 Oracle、DB2、SQL Server 等。下面是 GoldenGate 安装和配置的详细步骤。 安装准备 在安装 GoldenGate 之前,需要准备...

    oracle goldengate 单项复制配置(DDL)

    本文将深入解析如何在Linux环境下配置Oracle GoldenGate进行单项复制,特别关注DDL(Data Definition Language)语句的处理。 ### Oracle GoldenGate简介 Oracle GoldenGate是一款由Oracle公司提供的数据复制工具...

    OracleGoldenGate配置手册

    以下是对配置 Oracle GoldenGate 的详细步骤的概述: 1. **Oracle GoldenGate 版本与环境准备**: - 首先,你需要选择适合目标系统的 Oracle GoldenGate 版本。例如,在 Linux x86-64 平台上,对于 MySQL 数据库,...

    (完整word版)Oracle-GoldenGate-11g单向DDL配置实战.doc

    以下将详细阐述如何配置Oracle GoldenGate 11g的单向DDL同步。 首先,环境准备与安装是关键步骤。在源服务器和目标服务器上,确保已经安装了满足版本需求的Oracle数据库。在本例中,源服务器和目标服务器都运行着...

    GoldenGate安装配置两小时教程

    ### GoldenGate安装配置详解 #### 一、GoldenGate概述 GoldenGate是一款强大的数据复制软件,由Oracle公司开发,主要用于在异构系统之间进行实时的数据复制。它可以实现在不同的数据库平台间进行数据同步,并且能够...

    GoldenGate安装配置

    基于实时数据库的GoldenGate数据同步,包括GoldenGate安装配置等

    Oracle GoldenGate 安装配置windows32.docx

    ### Oracle GoldenGate在Windows 32位环境下的安装与配置详解 #### 一、Oracle GoldenGate概述 Oracle GoldenGate是一款高性能、高可用性且具备强大数据整合能力的软件,主要用于异构环境下的数据复制和集成。它...

    Goldengate安装配置文档.pdf

    在本文中,我们将深入探讨Goldengate的安装配置过程以及相关的配置参数。首先,我们从安装开始,然后逐步涉及源端数据库的配置、管理进程的设置,以及一些重要的参数解释。 1. **安装与解压**: - 首先,你需要...

    GoldenGate微服务的安装和配置.docx

    GoldenGate 微服务安装和配置是 Oracle GoldenGate(OGG)最新版本的安装和使用教程,本文将详细介绍 GoldenGate 19.1 微服务的安装和配置过程,附带详细的图文介绍,帮助读者快速掌握 GoldenGate 微服务的安装和...

    GoldenGate安装配置文档及概要使用说明.doc

    ### GoldenGate 安装配置与使用说明 #### 一、GoldenGate 概述 GoldenGate 是一款由 Oracle 提供的企业级数据复制解决方案,能够实现跨平台、跨数据库系统的实时数据复制。它支持多种数据库,包括 Oracle、DB2、...

    GoldenGate19.1微服务的安装和配置.docx

    在本文中,我们将深入探讨Oracle GoldenGate 19.1微服务版本的安装与配置,这是一个用于实时数据复制和集成的高级工具。Oracle GoldenGate 19.1引入了微服务架构,使得管理和操作变得更加灵活和高效。 首先,让我们...

    Oracle+GoldenGate+Director配置手册

    以下是对Oracle GoldenGate和Director配置的详细解析: 1. **Oracle GoldenGate基本概念** - **抽取(Extract)**:在源数据库上运行,捕获更改数据,并将其转化为GoldenGate格式。 - **泵(Replicat)**:在目标...

Global site tag (gtag.js) - Google Analytics