oracle 11g golden gate(ogg)配置的文档中,不支持DDL的同步,下面配置一下支持DDL的ogg。
1.在源端赋予ogg用户相应的权限,修改全局配置文件添加ggschema参数
SQL> grant execute on utl_file to ogg;
Grant succeeded.
GLOBALS参数文件添加ggschema ogg
GGSCI (qht115) 1> edit param ./GLOBALS
CHECKPOINTTABLE ogg.ggschkpt
ggschema ogg
2.关闭recyclebin(目标和源都关闭)
SQL> alter system set recyclebin=off scope=spfile;
SQL> startup force;
3.运行所需要的脚本(之前运行过可以忽略)
SQL> @marker_setup.sql
SQL> @ddl_setup.sql
SQL> @role_setup.sql
SQL> grant ggs_ggsuser_role to ogg;
SQL> @ddl_enable.sql
4.源端修改extract进程的params文件,添加"ddl include all"参数,重启extract进程
GGSCI (qht115) 3> edit params eora_1
EXTRACT EORA_1
SETENV (NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252)
ddl include all --添加这一行
USERID ogg, PASSWORD ogg
EXTTRAIL /u01/ogg/dirdat/aa
TABLE l5m.ogg_test;
修改完了重启一下进程
GGSCI (qht115) 5> stop extract eora_1
EXTRACT EORA_1 is already stopped.
GGSCI (qht115) 6> start extract eora_1
Sending START request to MANAGER ...
EXTRACT EORA_1 starting
5.修改目标端的replicate进程
添加以下内容:
DDL INCLUDE ALL
DDLERROR DEFAULT IGNORE RETRYOP MAXRETRIES 3 RETRYDELAY 5
内容如下:
GGSCI (qht131) 22> edit params RORA_1
REPLICAT RORA_1
SETENV (NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252)
DDL INCLUDE ALL
DDLERROR DEFAULT IGNORE RETRYOP MAXRETRIES 3 RETRYDELAY 5
USERID ogg, PASSWORD ogg
HANDLECOLLISIONS
ASSUMETARGETDEFS
DISCARDFILE /u01/ogg/dirrpt/RORA_aa.DSC, PURGE
MAP l5m.ogg_test, TARGET l5m.ogg_test;
重启一下replicate进程
GGSCI (qht131) 23> stop RORA_1
REPLICAT RORA_1 is already stopped.
GGSCI (qht131) 24> start RORA_1
Sending START request to MANAGER ...
REPLICAT RORA_1 starting
6.验证ddl
源端 :
SQL> ALTER TABLE L5M.OGG_TEST MODIFY(STATUS VARCHAR2(28 BYTE));
Table altered.
目标端:
SQL> desc l5m.ogg_test;
Name Null? Type
----------------------------------------- -------- ----------------------------
OWNER NOT NULL VARCHAR2(30)
TABLE_NAME NOT NULL VARCHAR2(30)
TABLESPACE_NAME VARCHAR2(30)
CLUSTER_NAME VARCHAR2(30)
IOT_NAME VARCHAR2(30)
STATUS VARCHAR2(28)
PCT_FREE NUMBER
ddl语句同步了,status栏位宽度变成了28。