GoldenGate单向复制配置(支持DDL复制)

在上一篇文件中的OGG单向复制配置不支持DLL的同步,只支持DML,因而本文在之前的基础上增加对DDL语句的复制,下面是简要配置过程记录!
一:验证之前的配置不支持DDL复制,这里在source端,新建一张表,发现无法复制到target端!target端也新建相同的表后,DML操作可以成功复制
[root@db1 ~]# su - oracle  
[oracle@db1 ~]$ sqlplus hr/hr  
SQL> create table t2 (id number primary key,name varchar2(20));  
Table created.  
SQL> conn hr/hr@db2  
Connected.  
SQL> select tname from tab where tname='T2';  
no rows selected  
 
SQL> create table t2 (id number primary key,name varchar2(20));  
Table created.  
 
SQL> conn hr/hr  
Connected.  
SQL> insert into t2 values (1,'one');  
1 row created.  
 
SQL> commit;  
Commit complete.  
 
SQL> conn hr/hr@db2  
Connected.  
SQL> select * from t2;  
 
        ID NAME  
---------- --------------------  
         1 one 
二:开始配置OGG支持DDL复制(在source端操作)
1:赋予ogg用户相应的权限,修改全局配置文件添加ggschema参数
SQL> conn /as sysdba  
Connected.  
SQL> grant execute on utl_file to ogg;  
Grant succeeded.  
 
[oracle@db1 ~]$ cd $GGATE   
[oracle@db1 ogg]$ ggsci  
GGSCI (db1) 1> edit param ./GLOBALS  
 
GGSCI (db1) 2> view param ./GLOBALS  
ggschema ogg 
2:运行相关的sql脚本
[oracle@db1 ~]$ cd $GGATE   
[oracle@db1 ogg]$ sqlplus /nolog  
SQL> conn /as sysdba  
Connected.  
SQL> @marker_setup.sql  
 
Marker setup script.  
You will be prompted for the name of a schema for the Oracle GoldenGate database objects.  
NOTE: The schema must be created prior to running this script.  
NOTE: Stop all DDL replication before starting this installation.  
 
Enter Oracle 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.  
 
SQL> show parameter recyclebin;  
 
NAME                                 TYPE        VALUE  
------------------------------------ ----------- ------------------------------  
recyclebin                           string      on  
 
SQL> alter session set recyclebin=off;  
System altered.  

SQL> alter system set recyclebin=off deferred; 
System altered.
 
SQL> show parameter recyclebin;  
 
NAME                                 TYPE        VALUE  
------------------------------------ ----------- ------------------------------  
recyclebin                           string      OFF  
 
1.回收站启动和关闭

回收站默认是开启的.不过我们可以通过参数recyclebin来关闭和开启.

如果只是针对每个session可以通过alter session set recyclebin=off; 和 alter session set recyclebin=on;来关闭和开启

如果是针对所有session可以通过修改系统参数recyclebin来实现,不过这里要注意10g和11g有点不一样,它们的参数类型不同

10g可以用:alter system set recyclebin=off; 和alter system set recyclebin=on;来关闭和开启

11g可以用:alter system set recyclebin=off deferred; 和alter system set recyclebin=on deferred;来关闭和开启



SQL> @ddl_setup.sql  
Oracle GoldenGate DDL Replication setup script.  
Verifying that current user has privileges to install DDL Replication...  
You will be prompted for the name of a schema for the Oracle 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 Oracle GoldenGate schema name:ogg  
 
Working, please wait ...  
Spooling to file ddl_setup_spool.txt  
 
Checking for sessions that are holding locks on Oracle Golden Gate metadata tables ...  
Check complete.  
Using OGG as a Oracle GoldenGate schema name.  
Working, please wait ...  
RECYCLEBIN must be empty.  
This installation will purge RECYCLEBIN for all users.  
To proceed, enter yes. To stop installation, enter no.  
 
Enter yes or no:yes  
————————其他输出省略————————  
 
STATUS OF DDL REPLICATION  
---------------------------------------------------------------------------------------  
SUCCESSFUL installation of DDL Replication software components  
 
Script. complete.  
 
SQL> @role_setup.sql  
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  
where is the user assigned to the GoldenGate processes.  
 
SQL> grant ggs_ggsuser_role to ogg;  
Grant succeeded.  
 
SQL> @ddl_enable.sql  
Trigger altered.  
 
SQL> @?/rdbms/admin/dbmspool.sql   
Package created.  
Grant succeeded.  
View created.  
Package body created.  
 
SQL> @ddl_pin.sql ogg  
PL/SQL procedure successfully completed.  
PL/SQL procedure successfully completed.  
PL/SQL procedure successfully completed. 
3:source端修改extract进程的params文件,添加"ddl include all"参数,重启extract进程
GGSCI (db1) 1> view params eora_t1  
extract eora_t1  
setenv (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)  
ddl include all  
userid ogg,password ogg  
exttrail ./dirdat/aa  
table hr.*;  
 
GGSCI (db1) 2> stop extract eora_t1  
Sending STOP request to EXTRACT EORA_T1 ...  
Request processed.  
 
GGSCI (db1) 3> start extract eora_t1  
Sending START request to MANAGER ...  
EXTRACT EORA_T1 starting  
 
GGSCI (db1) 4> info extract eora_t1  
EXTRACT    EORA_T1   Last Started 2012-06-20 15:42   Status RUNNING  
Checkpoint Lag       00:00:00 (updated 00:00:10 ago)  
Log Read Checkpoint  Oracle Redo Logs  
                     2012-06-20 15:42:58  Seqno 3, RBA 50044416  
                     SCN 0.567478 (567478) 
4:target端修改replicat进程的params文件,添加"ddl include all"和"ddlerror default ignore retryop maxretries 3 retrydelay 5" 参数,重启replicat进程
[root@db2 ~]# su - oracle  
[oracle@db2 ~]$ cd $GGATE   
[oracle@db2 ogg]$ ggsci  
GGSCI (db2) 1> edit params rora_t1  
GGSCI (db2) 2> view params rora_t1  
replicat rora_t1  
setenv (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)  
ddl include all  
ddlerror default ignore retryop maxretries 3 retrydelay 5  
userid ogg,password ogg  
handlecollisions  
assumetargetdefs  
discardfile ./dirrpt/rora_t1.dsc,purge  
map hr.* ,target hr.*;  
 
GGSCI (db2) 3> stop replicat rora_t1  
Sending STOP request to REPLICAT RORA_T1 ...  
Request processed.  
 
GGSCI (db2) 4> start replicat rora_t1  
Sending START request to MANAGER ...  
REPLICAT RORA_T1 starting  
 
GGSCI (db2) 5> info replicat rora_t1  
REPLICAT   RORA_T1   Last Started 2012-06-20 15:50   Status RUNNING  
Checkpoint Lag       00:00:00 (updated 00:00:00 ago)  
Log Read Checkpoint  File ./dirdat/pa000000  
                     First Record  RBA 4780973 
三:测试
[oracle@db1 ogg]$ sqlplus hr/hr  
SQL> alter table t2 add location varchar2(200);  
Table altered.  
 
SQL> conn hr/hr@db2  
Connected.  
SQL> desc t2  
 Name                                      Null?    Type  
 ----------------------------------------- -------- ----------------------------  
 ID                                        NOT NULL NUMBER  
 NAME                                               VARCHAR2(20)  
 LOCATION                                           VARCHAR2(200)  
 
SQL> conn hr/hr  
Connected.  
SQL> create table t3 as select object_id,object_name from dba_objects;  
 
Table created.  
 
SQL> conn hr/hr@db2  
Connected.  
SQL> select tname from tab where tname='T3';  
 
TNAME  
------------------------------  
T3  
 
SQL> desc t3;  
 Name                                      Null?    Type  
 ----------------------------------------- -------- ----------------------------  
 OBJECT_ID                                          NUMBER  
 OBJECT_NAME                                        VARCHAR2(128) 


注:本文根据”51CTO斩月博客“进行整理。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28698327/viewspace-767339/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/28698327/viewspace-767339/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值