配置Golden gate同步ddl语句
Upcoming SlideShare
Loading in...5
×
 

配置Golden gate同步ddl语句

on

  • 3,819 views

 

Statistics

Views

Total Views
3,819
Views on SlideShare
2,138
Embed Views
1,681

Actions

Likes
0
Downloads
71
Comments
0

11 Embeds 1,681

http://www.askmaclean.com 1332
http://www.oracledatabase12g.com 240
http://www.oracledatabase12c.com 71
http://translate.googleusercontent.com 18
http://oracledatabase12c.com 9
http://xianguo.com 4
http://webcache.googleusercontent.com 2
http://131.253.14.66 2
http://www.askmaclean.com HTTP 1
http://zhuaxia.com 1
http://www.slideshare.net 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

配置Golden gate同步ddl语句 配置Golden gate同步ddl语句 Document Transcript

  • 配置 GoldenGate 同步 DDL 语句 by Maclean.liu liu.maclean@gmail.com www.oracledatabase12g.com
  • About Mel Email:liu.maclean@gmail.coml Blog:www.oracledatabase12g.coml Oracle Certified Database Administrator Master 10gand 11gl Over 6 years experience with Oracle DBA technologyl Over 7 years experience with Linux technologyl Member Independent Oracle Users Groupl Member All China Users Groupl Presents for advanced Oracle topics: RAC,DataGuard, Performance Tuning and Oracle Internal.
  • 之前有客户选用了 Quest 的 shareplex 复制软件来 achive 一个上海到北京的 live standby 环境,所以有机会参加了几次 shareplex 的切换演练,虽然我对 shareplex 十分陌生(直到现在也是)。在实际切换期间也多次听到shareplex 的工程师反复强调复制环境中不能有 BLOB/CLOB 等大对象,也不能出现 DDL 语句(shareplex 不能复制 LOB 和 DDL 吗,未经证实);可能该环境中的确很少变更,所以客户方的经理并不 concern 这一点:”我们不做DDL 就是了嘛!” 这个复制环境因为数据库最初设计的时候没有考虑用主键或 unique index 且个别主用业务表上有巨多列(多于 200 个列)的原因导致后来 add 上追加日志后出现重做日志产生量水涨船高的问题。不过相比起 goldengate 有点惊人的价格来说(如果你需要 data repair 功能,记得你还需要另外购买 veridata),似乎 shareplex 对于中国客户还是有着不少的优势。 shareplex 还是 goldengate, 这是个问题。在配置 Goldengate 同步 DDL 语句前,要求在数据库内完成一系列的预安装先题步骤;其中包括建立合适的Goldengate 用户,如:create user maclean identified by maclean;grant dba to maclean;/* 之后 maclean 用户将用以配置 extract 和 pump */之后我们需要执行一系列同步 DLL 语句要用到的 GoldenGate 脚本,这些脚本存放在 GG 的安装目录下:[maclean@rh2 gg]$ pwd/home/maclean/gg[maclean@rh2 gg]$ ls -l dd*.sql-r--r--r-- 1 maclean oinstall 1059 2010-03-12 ddl_cleartrace.sql-r--r--r-- 1 maclean oinstall 4189 2010-03-12 ddl_ddl2file.sql-r--r--r-- 1 maclean oinstall 746 2010-03-12 ddl_disable.sql-r--r--r-- 1 maclean oinstall 692 2010-03-12 ddl_enable.sql-r--r--r-- 1 maclean oinstall 388 2010-03-12 ddl_nopurgeRecyclebin.sql-r--r--r-- 1 maclean oinstall 12424 2010-05-21 ddl_ora10.sql-r--r--r-- 1 maclean oinstall 3863 2010-05-21 ddl_ora10upCommon.sql-r--r--r-- 1 maclean oinstall 11064 2010-03-12 ddl_ora11.sql-r--r--r-- 1 maclean oinstall 12365 2010-03-12 ddl_ora9.sql-r--r--r-- 1 maclean oinstall 1026 2010-03-12 ddl_pin.sql-r--r--r-- 1 maclean oinstall 1227 2010-03-12 ddl_purgeRecyclebin.sql-r--r--r-- 1 maclean oinstall 3686 2010-05-13 ddl_remove.sql-r--r--r-- 1 maclean oinstall 425 2009-06-29 ddl_session1.sql-r--r--r-- 1 maclean oinstall 1053 2009-06-23 ddl_session.sql
  • -r-xr-xr-x 1 maclean oinstall 228606 06-29 13:48 ddl_setup.sql-r--r--r-- 1 maclean oinstall 8872 2010-03-12 ddl_status.sql-r--r--r-- 1 maclean oinstall 2506 2010-03-12 ddl_staymetadata_off.sql-r--r--r-- 1 maclean oinstall 2501 2010-03-12 ddl_staymetadata_on.sql-r--r--r-- 1 maclean oinstall 2955 2010-03-12 ddl_tracelevel.sql-r--r--r-- 1 maclean oinstall 2543 2010-03-12 ddl_trace_off.sql-r--r--r-- 1 maclean oinstall 2862 2010-03-12 ddl_trace_on.sql/* 执行 goldengate ddl 同步安装脚本要求以 SYSDBA 身份登录 */[maclean@rh2 gg]$ sqlplus / as sysdbaSQL*Plus: Release 10.2.0.4.0 - Production on Mon Dec 6 18:01:46 2010Copyright (c) 1982, 2007, Oracle. All Rights Reserved.Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> alter system set recyclebin=off;System altered./* 同步 DDL 要求我们关闭 10g 中的回收站特性 */SQL> @marker_setupMarker setup scriptYou 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:macleanMarker setup table script complete, running verification script...Please enter the name of a schema for the GoldenGate database objects:Setting schema name to MACLEANMARKER TABLE-------------------------------OKMARKER SEQUENCE-------------------------------OKScript complete./* 以 SYSDBA 登陆数据库并执行当前 GG 安装目录下的 market_setup 脚本,该脚本用以建立一个 DDL 标记表
  • 包括以下列: seqNo NUMBER NOT NULL, -- sequence number fragmentNo NUMBER NOT NULL, -- fragment number (message divided into fragments) optime CHAR(19) NOT NULL, -- time of operation TYPE VARCHAR2 (100) NOT NULL, -- type of marker SUBTYPE VARCHAR2 (100) NOT NULL, -- subtype of marker marker_text VARCHAR2 (4000) NOT NULL, -- fragment text (message divided into fragments numbered with fragmentNo)*/SQL> @ddl_setupGoldenGate DDL Replication setup scriptVerifying 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 11gand 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:macleanYou will be prompted for the mode of installation.To install or reinstall DDL replication, enter INITIALSETUPTo upgrade DDL replication, enter NORMALEnter mode of installation:INITIALSETUPWorking, please wait ...Spooling to file ddl_setup_spool.txtUsing MACLEAN as a GoldenGate schema name, INITIALSETUP as a mode of installation.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:yesDDL replication setup script complete, running verification script...Please enter the name of a schema for the GoldenGate database objects:Setting schema name to MACLEANDDLORA_GETTABLESPACESIZE STATUS:Line/pos Error---------- -----------------------------------------------------------------No errors No errorsCLEAR_TRACE STATUS:Line/pos Error---------- -----------------------------------------------------------------No errors No errorsCREATE_TRACE STATUS:Line/pos Error---------- -----------------------------------------------------------------No errors No errorsTRACE_PUT_LINE STATUS:Line/pos Error---------- -----------------------------------------------------------------No errors No errorsINITIAL_SETUP STATUS:Line/pos Error---------- -----------------------------------------------------------------No errors No errorsDDLVERSIONSPECIFIC PACKAGE STATUS:Line/pos Error---------- -----------------------------------------------------------------No errors No errors
  • DDLREPLICATION PACKAGE STATUS:Line/pos Error---------- -----------------------------------------------------------------No errors No errorsDDLREPLICATION PACKAGE BODY STATUS:Line/pos Error---------- -----------------------------------------------------------------No errors No errorsDDL HISTORY TABLE-----------------------------------OKDDL HISTORY TABLE(1)-----------------------------------OKDDL DUMP TABLES-----------------------------------OKDDL DUMP COLUMNS-----------------------------------OKDDL DUMP LOG GROUPS-----------------------------------OKDDL DUMP PARTITIONS-----------------------------------OKDDL DUMP PRIMARY KEYS-----------------------------------OKDDL SEQUENCE-----------------------------------OKGGS_TEMP_COLS-----------------------------------OKGGS_TEMP_UK-----------------------------------OK
  • DDL TRIGGER CODE STATUS:Line/pos Error---------- -----------------------------------------------------------------No errors No errorsDDL TRIGGER INSTALL STATUS-----------------------------------OKDDL TRIGGER RUNNING STATUS-----------------------------------ENABLEDSTAYMETADATA IN TRIGGER-----------------------------------OFFDDL TRIGGER SQL TRACING-----------------------------------0DDL TRIGGER TRACE LEVEL-----------------------------------0LOCATION OF DDL TRACE FILE--------------------------------------------------------------------------------/s01/10gdb/admin/clinica/udump/ggs_ddl_trace.logAnalyzing installation status...STATUS OF DDL REPLICATION--------------------------------------------------------------------------------SUCCESSFUL installation of DDL Replication software componentsScript complete./* 以 INITIALSETUP 选项运行 ddl_setup.sql 将在数据库中创建捕获 DDL 语句的 Trigger 等必要组件 */SQL> @role_setupGGS Role setup scriptThis script will drop and recreate the role GGS_GGSUSER_ROLETo 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:macleanWrote file role_setup_set.txtPL/SQL procedure successfully completed.Role setup script completeGrant this role to each user assigned to the Extract, GGSCI, and Manager processes, byusing the following SQL command:GRANT GGS_GGSUSER_ROLE TOwhere is the user assigned to the GoldenGate processes./* role_setup 脚本用以建立 GGS_GGSUSER_ROLE 角色 */我们需要将该 GGS_GGSUSER_ROLE 授予给 extract group 参数中定义的 userid 用户SQL> grant GGS_GGSUSER_ROLE to maclean;Grant succeeded.SQL> @ddl_enableTrigger altered./*ddl_enable.sql 将正式 enable ddl 捕获触发器,即:ALTER TRIGGER sys .&ddl_trigger_name ENABLE;*/SQL> @?/rdbms/admin/dbmspoolPackage created.Grant succeeded.View created.Package body created./* 执行 dbmspool 包将在数据库中创建 DBMS_SHARED_POOL 包,之后需要用到*/SQL> @ddl_pinEnter value for 1: macleanPL/SQL procedure successfully completed.Enter value for 1: macleanPL/SQL procedure successfully completed.PL/SQL procedure successfully completed.
  • /* ddl_pin.sql 通过 dbms_shared_pool.keep 存储过程将 DDLReplication 相关的对象 keep 在共享池中, 以保证这些对象不要 reload,提升性能*/以上脚本都运行完成后,DDL 语句同步的先题条件就达成了。接着我们要来配置 GG 部分的 extract 和 replicat:[maclean@rh2 gg]$ ggsciOracle GoldenGate Command Interpreter for OracleVersion 11.1.1.0.0 Build 078Linux, x64, 64bit (optimized), Oracle 10 on Jul 28 2010 13:21:11Copyright (C) 1995, 2010, Oracle and/or its affiliates. All rights reserved.GGSCI (rh2.oracle.com) 1> add extract load1,tranlog,begin nowEXTRACT added.GGSCI (rh2.oracle.com) 2> add rmttrail /s01/rmt/ma,megabytes 100,extract load1RMTTRAIL added.GGSCI (rh2.oracle.com) 5> encrypt password macleanNo key specified, using default key...Encrypted password: AACAAAAAAAAAAAHANCUEFHPAVCYDNJVDGGSCI (rh2.oracle.com) 16> start extract load1Sending START request to MANAGER ...EXTRACT LOAD1 startingGGSCI (rh2.oracle.com) 19> view params load1extract load1userid maclean, password AACAAAAAAAAAAAHANCUEFHPAVCYDNJVD,encryptkey defaultRMTHOST rh3.oracle.com, MGRPORT 7809RMTTRAIL /s01/rmt/maDDL INCLUDE MAPPEDTable sender.*;
  • /* 以上为源端的 extract load1 的配置,采用了 DDL INCLUDE MAPPED 的 DDL 同步方式 */GGSCI (rh3.oracle.com) 59> add replicat rep1,exttrail /s01/rmt/ma,beginnow,checkpointtable maclean.checkpointREPLICAT added.GGSCI (rh3.oracle.com) 62> view params rep1replicat rep1userid maclean,password macleanASSUMETARGETDEFSdiscardfile /s01/discard/rep1.log,append,megabytes 10-- Support DDL hereDDLmap sender.* , target receiver.*;GGSCI (rh3.oracle.com) 60> start replicat rep1Sending START request to MANAGER ...REPLICAT REP1 startingGGSCI (rh3.oracle.com) 63> info allProgram Status Group Lag Time Since ChkptMANAGER RUNNINGREPLICAT RUNNING REP1 00:00:00 00:00:07/* 以上为目标端的 replicat rep1 配置,DDL 语句将由 sender 用户映射到 receiver 用户 */接下来我们对具体的 DDL 同步进行测试:/ * 在源端建立测试用表 tddl */SQL> conn sender/senderConnected.SQL> create table tddl (t1 int);Table created.
  • REP1.rep 报告文件出现以下信息:Opened trail file /s01/rmt/ma000000 at 2010-12-07 03:50:192010-12-07 03:52:13 INFO OGG-01407 Setting current schema for DDL operation to[RECEIVER].2010-12-07 03:52:13 INFO OGG-01408 Restoring current schema for DDL operation to[MACLEAN].SQL> conn receiver/receiver;Connected.SQL> desc tddlName Null? Type----------------------------------------- -------- ----------------------------T1 NUMBER(38)/* create table 的 DDL 语句被正确同步了 *//* 可以从 gg 管理者名下的 ggs_marker 表看到捕获到的建表语句 似乎可以分为 DDL 正文和变量 2 段*/SQL> set linesize 65 pagesize 1400;SQL> select marker_text 2 from ggs_marker 3 where seqno = (select seqno from ggs_marker where marker_text like %tddl%); 4MARKER_TEXT-----------------------------------------------------------------,C1=create table tddl (t1 int) ,,C5=16,,B2=,,G4=,,B3=SENDER,,B4=TDDL,,C12=,,C13=,,B5=TABLE,,B6=CREATE,,B7=16,,B8=MACLEAN.GGS_DDL_HIST,,B9=SENDER,,C7=10.2.0.4.0,,C8=10.2.0.3,,C9=,,C10=1,,C11=clinica,,G3=NONUNIQUE,,C14=NO,,C17(1)=NLS_LANGUAGE,,C18(1)=AMERICAN,,C17(2)=NLS_TERRITORY,,C18(2)=AMERICA,,C17(3)=NLS_CURRENCY,,C18(3)=$,,C17(4)=NLS_ISO_CURRENCY,,C18(4)=AMERICA,,C17(5)=NLS_NUMERIC_CHARACTERS,,C18(5)=.,,,C17(6)=NLS_CALENDAR,,C18(6)=GREGORIAN,,C17(7)=NLS_DATE_FORMAT,,C18(7)=DD-MON-RR,,C17(8)=NLS_DATE_LANGUAGE,,C18(8)=AMERICAN,,C17(9)=NLS_SORT,,C18(9)=BINARY,,C17(10)=NLS_TIME_FORMAT,,C18(10)=HH.MI.SSXFF AM,,C17(11)=N
  • LS_TIMESTAMP_FORMAT,,C18(11)=DD-MON-RR HH.MI.SSXFF AM,,C17(12)=NLS_TIME_TZ_FORMAT,,C18(12)=HH.MI.SSXFF AM TZR,,C17(13)=NLS_TIMESTAMP_TZ_FORMAT,,C18(13)=DD-MON-RR HH.MI.SSXFF AM TZR,,C17(14)=NLS_DUAL_CURRENCY,,C18(14)=$,,C17(15)=NLS_COMP,,C18(15)=BINARY,,C17(16)=NLS_LENGTH_SEMANTICS,,C18(16)=BYTE,,C17(17)=NLS_NCHAR_CONV_EXCP,,C18(17)=FALSE,,C19=17,SQL> conn sender/senderConnected.SQL> insert into tddl values(&a);Enter value for a: 1old 1: insert into tddl values(&a)new 1: insert into tddl values(1)1 row created.SQL> /Enter value for a: 2old 1: insert into tddl values(&a)new 1: insert into tddl values(2)1 row created.SQL> commit;Commit complete.SQL> alter table tddl add tclob clob default I am testing;Table altered./* 我们来看看添加有默认值的 clob 字段这样的 DDL 语句是否能够同步成功 */SQL> conn receiver/receiverConnected.SQL> set linesize 100 pagesize 1400;SQL> select * from tddl; T1 TCLOB------------------------------------------------------------------------------------------ 1 I am testing
  • 2 I am testing/* 以上测试表明 gg 成功复制了添加有默认值的 clob 字段这样的 DDL 语句 */我们可以从源端的$ORACLE_BASE/admin/$sid/udump 目录下的 ggs_ddl_trace.log 日志文件中找到以下记录:SESS 154688-2010-12-06 19:08:42 : DDL : *************************Start of log for DDL sequence [18], v[ $Id://depot/releases/OpenSys/v11.1.1.0/redist/SQLScripts/ddl_setup.sql#2 $ ] trace level [0], owner schema of DDL package [MACLEAN], objtype [TABLE]name [SENDER.TDDL]SESS 154688-2010-12-06 19:08:42 : DDLTRACE1 : Before Trigger: point inexecution = [1.0], objtype [TABLE] name [SENDER.TDDL]SESS 154688-2010-12-06 19:08:42 : DDL : DDL operation[ alter table tddl add tclob clob default I am testing ], sequence [18],DDL type [ALTER] TABLE, real object type [TABLE], validity [VALID], object ID [57772], object [SENDER.TDDL],real object [SENDER.TDDL], base object schema [], base object name [], logged as [SENDER]SESS 154688-2010-12-06 19:08:42 : DDL : Start SCN found [45357217]SESS 154688-2010-12-06 19:08:42 : DDL : ------------------------- End of log for DDLsequence [18]接下来我们会测试更多不同 DDL 语句的同步,这些我能想到的 DDL 语句包括: • CREATE USER • CREATE TABLESPACE • CREATE PROCEDURE • CREATE PROFILE • CREATE DIRECTORY • CREATE EXTERNAL TABLE 等等
  • 但在这之前我们需要修改我们在 GoldenGate 同步 DDL 语句(1)中配置的 extract 和 replicat 的参数文件:GGSCI (rh2.oracle.com) 2> view params load1extract load1userid maclean, password AACAAAAAAAAAAAHANCUEFHPAVCYDNJVD,encryptkey defaultRMTHOST rh3.oracle.com, MGRPORT 7809RMTTRAIL /s01/rmt/maDDL INCLUDE ALLTable sender.*;/*源端将 DLL INCLUDE MAPPED 修改为 DLL INCLUDE ALL, 不同于 MAPPED,INCLUDE ALL 意味包含所有 DDL 语句 MAPPED applies INCLUDE or EXCLUDE to DDL operations that are of MAPPED scope. MAPPED filtering is performed before filtering that is specified with other DDL parameter options ALL applies INCLUDE or EXCLUDE to DDL operations of all scopes.*/GGSCI (rh2.oracle.com) 4> stop extract load1Sending STOP request to EXTRACT LOAD1 ...Request processed.GGSCI (rh2.oracle.com) 5> start extract load1Sending START request to MANAGER ...EXTRACT LOAD1 startingGGSCI (rh3.oracle.com) 3> view params rep1replicat rep1userid maclean,password macleanASSUMETARGETDEFSdiscardfile /s01/discard/rep1.log,append,megabytes 10-- Support DDL hereDDL INCLUDE ALLDDLERROR DEFAULT IGNORE RETRYOP MAXRETRIES 3 RETRYDELAY 5map sender.* , target receiver.*;
  • /* 目标端也需要将原来的 DDL 补充为 DDL INCLUDE ALL 以及加上 DDLERROR DEFAULT IGNORE RETRYOP MAXRETRIES 3 RETRYDELAY 5 *//* DDLERROR 参数指定了出现 DDL 同步错误时的处理方式,此处为以 5 秒(RETRYDELAY) 为间隔重试 3 次(MAXRETRIES),若该 DDL 仍报错,则忽略该 DDL*/GGSCI (rh3.oracle.com) 4> stop replicat rep1Sending STOP request to REPLICAT REP1 ...Request processed.GGSCI (rh3.oracle.com) 5> start replicat rep1Sending START request to MANAGER ...REPLICAT REP1 starting接下来我们要具体测试多种 DDL 语句的 gg 同步情况:SQL> create user guser identified by guser;User created.源端的$ORACLE_BASE/admin/$SID/udump 下的 ggs_ddl_trace.log,纪录了该 create user ddl 语句: Start of log for DDL sequence [137], v[ $Id://depot/releases/OpenSys/v11.1.1.0/redist/SQLScripts/ddl_setup.sql#2 $ ] trace level [0], owner schema of DDL package [MACLEAN], objtype[USER] name [.GUSER]SESS 4294967295-2010-12-07 22:21:06 : DDLTRACE1 : Before Trigger: point in execution =[1.0], objtype [USER] name [.GUSER]SESS 4294967295-2010-12-07 22:21:06 : DDL : DDL operation [create user guser identifiedby ***** ], sequence [137], DDL type [CREATE] USER, real object type [USER], validity [], object ID [], object [.GUSER], real object [.GUSER], base object schema [],base object name [], logged as [SYS]SESS 4294967295-2010-12-07 22:21:06 : DDL : Start SCN found [45484306]End of log for DDL sequence [137], no DDL history metadata recorded for this DDLoperation目标端同步情况:SQL> select username from dba_users where created>=all(select created from dba_users);
  • USERNAME------------------------------GUSER/* 可以看到 create user 语句复制成功 */SQL> show parameter db_create_file_destNAME TYPE VALUE------------------------------------ ----------- ------------------------------db_create_file_dest string /s01/10gdb/oradataSQL> create tablespace gtb datafile size 10M;Tablespace created.SQL> show parameter db_create_file_destNAME TYPE VALUE------------------------------------ ----------- ------------------------------db_create_file_dest string /s01/oradataSQL> select file_name from dba_data_files where tablespace_name=GTB;FILE_NAME--------------------------------------------------------------------------------/s01/oradata/CLINICB/datafile/o1_mf_gtb_6hxjpstg_.dbf/* 在远端和目标端都启用了 10g 中自动管理数据文件创建的前提下, 创建表空间的 DDL 语句被复制成功*//* 若我们在源端创建某表,且为该表指定一个目标端不存在的表空间时, create table 语句会如何呢?*/SQL> conn sender/senderConnected.SQL> create table rbf (t1 int) tablespace bf;Table created.可以在目标端的 replicat report 中看到以下 4 次尝试,其后三次应为我们之前定义的 MAXRETRIES:2010-12-08 07:37:43 INFO OGG-01407 Setting current schema for DDL operation to[RECEIVER].
  • 2010-12-08 07:37:48 INFO OGG-01407 Setting current schema for DDL operation to[RECEIVER].2010-12-08 07:37:53 INFO OGG-01407 Setting current schema for DDL operation to[RECEIVER].2010-12-08 07:37:58 INFO OGG-01407 Setting current schema for DDL operation to[RECEIVER].2010-12-08 07:37:58 INFO OGG-01408 Restoring current schema for DDL operation to[MACLEAN].GGSCI (rh3.oracle.com) 21> stats replicat rep1Sending STATS request to REPLICAT REP1 ...No active replication mapsDDL replication statistics:*** Total statistics since replicat started *** Operations 4.00 Mapped operations 2.00 Unmapped operations 0.00 Other operations 2.00 Excluded operations 0.00 Errors 8.00 Retried errors 6.00 Discarded errors 0.00 Ignored errors 2.00/* 虽然可以从 stats replicat 的输出中看到 Errors 和 Retried errors 数, 但在 replicat 的 report 和 ggserr 日志中都没有纪录 DDL 同步失败的具体信息,准备提 SR 了!*//* 在源端创建以下简单的存储过程 */SQL> conn sender/senderSQL> create or replace procedure progg as 2 i int; 3 begin 4 select t1 into i from tddl where rownum=1; 5 dbms_output.put_line(i); 6 end; 7 /Procedure created.
  • SQL> conn receiver/receiverConnected.SQL> select t1 from tddl; T1---------- 1 2SQL> set serveroutput on;SQL> exec progg;1PL/SQL procedure successfully completed./* 因为目标端存在该存储过程的依赖条件,所以复制后编译成功; 否则复制可以成功但该对象状态为 INVALID */SQL> drop procedure progg;Procedure dropped.SQL> drop table tddl;Table dropped.在源端再次创建该 procedure 后:SQL> col object_name for a30SQL> select object_name,status from dba_objects where object_name=PROGG;OBJECT_NAME STATUS------------------------------ -------PROGG INVALID/* 在源端创建 profile 配置文件 */SQL> create profile gg_profile limit sessions_per_user 2;Profile created.SQL> select RESOURCE_NAME,LIMIT from dba_profiles where profile=GG_PROFILE and limit!=DEFAULT;RESOURCE_NAME LIMIT-------------------------------- ----------------------------------------SESSIONS_PER_USER 2
  • /*在目标端配置文件信息同步成功 *//* 在源端创建文件夹 directory 对象 */SQL> create directory dgg as /s01/dump;Directory created.SQL> col directory_name for a3SQL> col directory_path for a20SQL> select directory_name,directory_path from dba_directories wheredirectory_name=DGG;DIR DIRECTORY_PATH--- --------------------DGG /s01/dump/*在文件系统上都存在/s01/dump 文件夹的前提下 create directory ddl 同步成功*//*在源端创建 type 为 oracle_datapump 的外部表 */SQL> CREATE TABLE extgg 2 ORGANIZATION EXTERNAL 3 (TYPE oracle_datapump 4 DEFAULT DIRECTORY dgg 5 LOCATION (extgg.dat)) 6 AS 7 select * from dba_objects;Table created.在目标端 replicat 中出现多次 retry 纪录:2010-12-08 08:13:09 INFO OGG-01407 Setting current schema for DDL operation to[RECEIVER].2010-12-08 08:13:14 INFO OGG-01407 Setting current schema for DDL operation to[RECEIVER].2010-12-08 08:13:19 INFO OGG-01407 Setting current schema for DDL operation to[RECEIVER].2010-12-08 08:13:24 INFO OGG-01407 Setting current schema for DDL operation to[RECEIVER].2010-12-08 08:13:24 INFO OGG-01408 Restoring current schema for DDL operation to[MACLEAN]./* 同时 ddl Errors 数目增加 */GGSCI (rh3.oracle.com) 34> stats replicat rep1Sending STATS request to REPLICAT REP1 ...
  • No active replication mapsDDL replication statistics:*** Total statistics since replicat started *** Operations 11.00 Mapped operations 6.00 Unmapped operations 0.00 Other operations 5.00 Excluded operations 0.00 Errors 33.00 Retried errors 24.00 Discarded errors 0.00 Ignored errors 9.00/* 无疑是创建外部表的 DDL 语句复制失败,当因为目前找不到相关的日志所以无法进一步分析了 */在配置 GoldenGate 同步 DDL 语句(2)中我们针对多种 DDL 语句在 GoldenGate 环境中的同步进行了测试,但在默认情况下 replicat 在复制 DDL 语句失败时不会在 replicat report 或者 ggserr.log 等日志文件中产生该 DDL 失败的具体信息,这就会导致我们在发现 DDL 同步有 error 的情况下无法了解失败的原因。之后又去翻官方的文档,在中找到了 DDLOPTIONS 参数:Use the DDLOPTIONS parameter to configure aspects of DDL processing other than filteringand string substitution. You can use multiple DDLOPTIONS statements, but using one isrecommended. If using multiple DDLOPTIONS statements, make each of them unique so thatone does not override the other. Multiple DDLOPTIONS statements are executed in the orderlisted.这个参数可用的选项很多,我们需要用到的是 REPORT 选项:Valid for Extract and Replicat (Oracle and Teradata).Controls whether or not expanded DDL processinginformation is written to the report file. The default ofNOREPORT reports basic DDL statistics. REPORT adds theparameters being used and a step-by-step history of theoperations that were processed
  • 在 replicat 的参数文件中添加上”DDLOPTIONS REPORT”,可以让 replicat 在同步 DDL 语句时若出现问题,将该问题的详细情况记录到该 replicat 的 report 文件中,以便找出 DDL 复制失败的 root cause。GGSCI (rh3.oracle.com) 9> view params rep1replicat rep1userid maclean,password macleanASSUMETARGETDEFSdiscardfile /s01/discard/rep1.log,append,megabytes 10-- Support DDL hereDDL INCLUDE ALLDDLERROR DEFAULT IGNORE RETRYOP MAXRETRIES 3 RETRYDELAY 5DDLOPTIONS REPORTmap sender.* , target receiver.*;GGSCI (rh3.oracle.com) 10> stop replicat rep1Sending STOP request to REPLICAT REP1 ...Request processed.GGSCI (rh3.oracle.com) 11> start replicat rep1Sending START request to MANAGER ...REPLICAT REP1 starting在源端创建一外部表SQL> CREATE TABLE extgg 2 ORGANIZATION EXTERNAL 3 (TYPE oracle_datapump 4 DEFAULT DIRECTORY dgg 5 LOCATION (extgg.dat)) 6 AS 7 select * from dba_objects;Table created.之后检查 replicat 的 report 信息可以发现 DDL 复制失败的详细 SQL 语句等信息:GGSCI (rh3.oracle.com) 12> view report rep1***********************************************************************
  • Oracle GoldenGate Delivery for Oracle Version 11.1.1.0.0 Build 078 Linux, x64, 64bit (optimized), Oracle 10 on Jul 28 2010 15:58:11Copyright (C) 1995, 2010, Oracle and/or its affiliates. All rights reserved. Starting at 2010-12-10 05:54:32***********************************************************************...............2010-12-09 09:10:13 INFO OGG-01408 Restoring current schema for DDL operation to[MACLEAN].2010-12-09 09:10:13 INFO OGG-00482 DDL found, operation [CREATEGLOBAL TEMPORARY TABLE "SENDER"."SYS_TEMP_0FD9D6609_2B3F4ED" ("OWNER" VARCHAR2(30),"OBJECT_NAME" VARCHAR2(128),"SUBOBJECT_NAME" VARCHAR2(30),"OBJECT_ID"NUMBER,"DATA_OBJECT_ID" NUMBER,"OBJECT_TYPE" VARCHAR2(19),"CREATED" DATE,"LAST_DDL_TIME"DATE,"TIMESTAMP" VARCHA R2(19),"STATUS" VARCHAR2(7),"TEMPORARY" VARCHAR2(1),"GENERATED" VARCHAR2(1),"SECONDARY" VARCHAR2(1) ) IN_MEMORY_METADATACURSOR_SPECIFIC_SEGMENT STORAGE (OBJNO 4254950921 ) NOPARALLEL (size 456)].2010-12-09 09:10:13 INFO OGG-00489 DDL is of mapped scope, after mapping newoperation[CREATE GLOBAL TEMPORARY TABLE "RECEIVER"."SYS_TEMP_0FD9D6609_2B3F4ED"("OWNER" VARCHAR2(30),"OBJECT_NAME" VARCHAR2(128),"SUBOBJECT_NAME"VARCHAR2(30),"OBJECT_ID" NUMBER,"DATA_OBJECT_ID" NUMBER,"OBJECT_TYPE"VARCHAR2(19),"CREATED" DATE,"LAST_DDL_TIME" DATE,"TIMESTAMP" VARCHAR2(19),"STATUS" VARCHAR2(7),"TEMPORARY" VARCHAR2(1),"GENERATED" VARCHAR2(1),"SECONDARY" VARCHAR2(1) ) IN_MEMORY_METADATA CURSOR_SPECIFIC_SEGMENT STORAGE (OBJNO 4254950921 ) NOPARALLEL (size 458)].2010-12-09 09:10:13 INFO OGG-00487 DDL operation included [INCLUDE ALL], optype[CREATE],objtype [TABLE], objowner [RECEIVER], objname [SYS_TEMP_0FD9D6609_2B3F4ED].2010-12-09 09:10:13 INFO OGG-01407 Setting current schema for DDL operation to[SYS].2010-12-09 09:10:13 INFO OGG-00484 Executing DDL operation.2010-12-09 09:10:18 INFO OGG-00495 DDL error ignored for next retry: error code[DEFAULT],filter [include all (default)], error text [Error code [900],ORA-00900: invalid SQL statement, SQL CREATE GLOBAL TEMPORARY TABLE"RECEIVER"."SYS_TEMP_0FD9D6609_2B3F4ED"
  • ("OWNER" VARCHAR2(30),"OBJECT_NAME" VARCHAR2(128),"SUBOBJECT_NAME" VARCHAR2(30),"OBJECT_ID" NUMBER,"DATA_OBJECT_ID" NUMBER,"OBJECT], retry [1].2010-12-09 09:10:18 INFO OGG-01407 Setting current schema for DDL operation to[SYS].2010-12-09 09:10:18 INFO OGG-00484 Executing DDL operation trying again due toRETRYOP parameter.2010-12-09 09:10:23 INFO OGG-00495 DDL error ignored for next retry: error code[DEFAULT],filter [include all (default)], error text[Error code [900], ORA-00900: invalid SQL statement, SQL CREATE GLOBAL TEMPORARY TABLE"RECEIVER"."SYS_TEMP_0FD9D6609_2B3F4ED"("OWNER" VARCHAR2(30),"OBJECT_NAME" VARCHAR2(128),"SUBOBJECT_NAME" VARCHAR2(30),"OBJECT_ID" NUMBER,"DATA_OBJECT_ID" NUMBER,"OBJECT], retry [2].2010-12-09 09:10:23 INFO OGG-01407 Setting current schema for DDL operation to[SYS].另外需要注意的是如 create table as select 这样的建表 DDL 语句应该被杜绝使用,因为在 goldengate 复制环境中 create table as select 语句仍会以 DDL 形式被应用,这就导致源端和目标的端的数据不一致,如:/* 源端中 dba_object 视图共有 52046 行数据 */SQL> select count(*) from dba_objects; COUNT(*)---------- 52046SQL> create table ddlproblem as select * from dba_objects;Table created.SQL> select count(*) from ddlproblem; COUNT(*)---------- 52047而在目标端的复制情况:SQL> desc ddlproblem
  • Name Null? Type----------------------------------------- -------- ----------------------------OWNER VARCHAR2(30)OBJECT_NAME VARCHAR2(128)SUBOBJECT_NAME VARCHAR2(30)OBJECT_ID NUMBERDATA_OBJECT_ID NUMBEROBJECT_TYPE VARCHAR2(19)CREATED DATELAST_DDL_TIME DATETIMESTAMP VARCHAR2(19)STATUS VARCHAR2(7)TEMPORARY VARCHAR2(1)GENERATED VARCHAR2(1)SECONDARY VARCHAR2(1)SQL> select count(*) from ddlproblem; COUNT(*)---------- 51008/* 因为 replicat 在目标端仅是简单的执行"create table as select"的建表 DDL 语句, 而源端和目标端中这个被 select 的对象中的数据并不一致,因而 CTAS 操作只会导致 2 端的数据不一致*/© 2010, www.oracledatabase12g.com. 版权所有.文章允许转载,但必须以链接方式注明源地址,否则追求法律责任.