Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1208467
  • 博文数量: 350
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 5668
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-23 17:53
文章分类

全部博文(350)

文章存档

2013年(350)

分类: Oracle

2013-04-10 13:37:58

4、配置DDL支持


4.1 配置用户及表空间

一般第一步都是创建用户。前面我们已经做过操作,用户已建好,这里仍然沿用前面创建的ggate用户,当然此刻也可以创建一个新的用户,注意用户的默认表空间不要指定为SYSTEM,否则在初始化DDL支持时可能会遇到段无法扩展,或包无法编译等错误。

正式应用的话,需要注意ggate用户所在表空间是否有充足的空间。

为ggate用户授予utl_file的execute权限,执行命令如下:

    SQL> grant execute on utl_file to ggate;


    Grant succeeded.


4.2 配置全局参数文件


    GGSCI (ora9node1) 14> edit param ./GLOBALS

增加下列内容:

    GGSCHEMA ggate

接下来有一个可选操作,就是说是否要自定义DDL相关对象的名称,一般情况下不需要修改,也建议保持对象默认值,如果由于某些特殊的需求要改的话,那么就需要现在改,而不能等到部署完成。

修改主要是通过重定义params.sql中的相关变量值,该文件位于GoldenGate软件目录下,编译并保存即可。

另外,改完params.sql后,还需要修改GLOBALS配置文件,新增对象名称的对应关系,例如:

    MARKERTABLE 

    DDLTABLE   

前者表示Marker表,后一个表示DDL历史表。


4.3 执行配置脚本

接下来要执行一堆的脚本,这些脚本均在GoldenGate安装目录,因此建议移动到GoldenGate目录下,以方便调用脚本(当然,直接完整路径方式调用也是可以的):

    [oracle@ora9node1 ~]$ cd /data/oracle/ora9i/ggate/

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

本步要执行的脚本比如多,先列个列表备忘:

  
        
  • 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
  •   

详细执行步骤如下:

4.3.1 执行marker_setup脚本

该脚本安装marker系统,这部分为启用DLL支持所必备,执行该脚本时会提示输入GoldenGate管理帐户schema名,例如:

    [oracle@ora9node1 ggate]$ sqlplus "/ as sysdba"

    SQL> set line 150 pages 1000

    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:ggate



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

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

    Setting schema name to GGATE


    MARKER TABLE

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

    OK


    MARKER SEQUENCE

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

    OK


    Script complete.


4.3.2 执行ddl_setup脚本

执行该脚本要确认关闭掉所有ORACLE会话,未被关闭的会话会以列表形式显示,执行过程中会要求希望对象属主,并选择安装模式。

如果是初次安装就选择“INITIALSETUP”,该模式假设当前没有任何GoldenGate DDL对象存在,如果存在则会删除并重建。如果是重新安装,则应该选择“NORMAL”。具体执行示例如下:

    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:ggate


    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 GGATE 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 GGATE


    DDLORA_GETTABLESPACESIZE STATUS:


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

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

    Analyzing installation status...



    STATUS OF DDL REPLICATION

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

    SUCCESSFUL installation of DDL Replication software components


    Script complete.


4.3.3 执行role_setup脚本

该操作会重建DDL同步所需的权限,授予GoldenGate中的DDL对象以DML权限,执行示例如下:

    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:ggate

    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 


    where  is the user assigned to the GoldenGate processes.


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

    SQL> GRANT GGS_GGSUSER_ROLE TO GGATE;


    Grant succeeded.


4.3.4 执行ddl_enable脚本

启用DDL触发器,以捕获DDL操作:

    SQL> @ddl_enable


    Trigger altered.


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

要提高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.


然后,用于同步DDL操作的对象就创建完成了。


4.4 测试DDL同步

首先在源端修改extract进程的配置文件,例如:

    GGSCI (ora9node1) 18> edit param ext2

在适当位置增加下列内容:

    DDL INCLUDE ALL OPTYPE CREATE OBJTYPE 'table'

该语句用以支持create table操作,如果需要其它如alter/drop等,则增加相应配置即可。


启动extract进程:

    GGSCI (ora9node1) 20> start extract ext2


    Sending START request to MANAGER ...

    EXTRACT EXT2 starting


随后sqlplus中创建新表:

    SQL> conn jss/jss

    Connected.

    SQL> select * from tab;


    TNAME                          TABTYPE  CLUSTERID

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

    J1                             TABLE

    J2                             TABLE


    2 rows selected.


    SQL> create table j3(id number);


    Table created.


登录到目标端ggsci命令行模式下,同样需要对replicat的参数进行配置:

    GGSCI (rhel5u3) 4> edit param rep2

在适当位置增加一模一样的内容(当然此处也可以与源端不同,具体根本实际情况设定):

    DDL INCLUDE ALL OPTYPE CREATE OBJTYPE 'table'

启动replicat进程:

    GGSCI (rhel5u3) 5> start replicat rep2


    Sending START request to MANAGER ...

    REPLICAT REP2 starting


查看新创建的对象是否同步过来的:

    GGSCI (rhel5u3) 9> dblogin userid ggate,password ggate

    Successfully logged into database.


    GGSCI (rhel5u3) 10> list tables jss.j3

    JSS.J3


    Found 1 tables matching list criteria.

成功同步。
=========================================

阅读(2063) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~