OGG的DDL測試及CONVERTUCS2CLOBS參數

今天測試OGG的DDL和CONVERTUCS2CLOBS參數。之前看的書比較老,上面說如果是clob的話,需要使用參數CONVERTUCS2CLOBS。但是今天測試了下,發現沒有使用CONVERTUCS2CLOBS這個參數。也是可以同步複製數據的。

查了下MOS,Replicating CLOB characters with a UTF8, UTF16, AL32UTF8 Oracle Database (Doc ID 967922.1)。

上面提到該參數在ogg11.2已經被廢棄了。是這麼說的。

1. For Oracle with UTF8 and UTF16 character sets

  • Add TRANLOGOPTIONS option CONVERTUCS2CLOBS to extract parameter file.

    Please make sure you use the above parameter ONLY  when your Oracle Database has UTF charactersets.  Otherwise, it might corrupt your CLOB data, for example, if you use WE8ISO8859P1 as database characterset.

      Option CONVERTUCS2CLOBS is no longer needed in Goldengate version11.1.1.  However, using it incorrectly for single byte database (such as WE8ISO8859P1) may still correct the fetched data  (like xmltype).  Enhancement BUG 13056997 tracks a request to abend the extract in Oracle goldenGate (OGG) release 11 when using this option (the option will be deprecated in OGG release 11.2). The corrupted xml data could cause replicat abend with ora-31011 error, such as:

WARNING OGG-01004 Aborted grouped transaction on 'MESSAGES.TP_XML', Database error 31011 (ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00210: expected '<' instead of '?'
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 0
ORA-06512: at line 1).

 

Further, Option CONVERTUCS2CLOBS ihas been deprecated as of GoldenGate version11.2.1

2. Additional parameter to be used ONLY for Oracle Versions >= 10.2.0.4 but < 11.2 (UTF8 and ALF32UTF8 character sets) and GoldenGate version earlier than v10.0.0.42_004 or any V10.4 that is earlier than  v10.4.0.12_001

       Add "DBOPTIONS _CALCUTF8BYTELENGTH" to extract parameter file. (available in OGG 9.5.1.61 Build 001 and 10.0.0.1 Build 001). This is due to Oracle OCI bug 7253302, that Oracle OCI call can't get the correct LOB length, thus GoldenGate has to use our own workaround to get the correctly length by enabling this parameter.

 

以下是測試過程:

-- 版本信息

c:\ogg>ggsci.exe -v

Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.33 22986205 OGGCORE_11.2.1.0.0OGGBP_PLATFORMS_160502.0200
Windows x64 (optimized), Oracle 11g on May  2 2016 03:45:49

Copyright (C) 1995, 2016, Oracle and/or its affiliates. All rights reserved.



c:\ogg>
GGSCI (dc01) 133> versions
Operating System:

Version 6.1 (Build 7601: Service Pack 1)

Database:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE    11.2.0.4.0      Production
TNS for 64-bit Windows: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

-- 先配置ogg的進程,讓進程抽取apps.*

edit params extdb1 
table apps.*;  

edit params pumdb1 
table apps.*;

edit params repdb1
table apps.*;  

-- TRANLOGOPTIONS CONVERTUCS2CLOBS   -- 沒有設置這個參數,居然也可以同步clob 。查詢MOSDoc ID 967922.1 ,改參數已經在ogg 11.2.1被淘汰了
該參數僅僅適用於oracle數據庫版本>=10.2.0.4 小於11.2 。並且ogg版本遭遇10.0.0.42_004(或者任何早於10.4.0.12_001的10.4版本)

-- 啓用ddl複製,在抽取進程和複製進程中添加

ddl include all

-- 創建測試用的表 apps.t_clob

create table apps.t_clob
(id number primary key,
txt clob)
tablespace users ;

--
GGSCI (dc01) 125> add trandata apps.t_clob

Logging of supplemental redo data enabled for table APPS.T_CLOB.

GGSCI (dc01) 126> info trandata apps.t_clob

Logging of supplemental redo log data is enabled for table APPS.T_CLOB.

Columns supplementally logged for table APPS.T_CLOB: ID.

GGSCI (dc01) 127>

-- 源端插入測試數據

insert into apps.t_clob values(1,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');

[email protected]/test>create table apps.t_clob
  2  (id number primary key,
  3  txt clob)
  4  tablespace users ;

Table created.

[email protected]/test>insert into apps.t_clob values(1,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');

1 row created.

[email protected]/test>commit;

Commit complete.

[email protected]/test>

-- 因爲配製了ddl 所以在目標端可以看到表已經複製過來了

SYS@testogg>desc apps.t_clob
 名稱                                      是否爲空? 類型
 ----------------------------------------- -------- -------------------------

 ID                                        NOT NULL NUMBER
 TXT                                                CLOB

SYS@testogg>

-- 將庫的 enable_ddl_logging 設置爲true,方便後面查看ddl的記錄

SYS@testogg>alter system set enable_ddl_logging=true;

系統已更改。

SYS@testogg>

-- 目標端查看同步情況,已經同步過來了

GGSCI (WIN-846KA82M3MG) 223> stats repdb1 ,daily ,table apps.t_clob

Sending STATS request to REPLICAT REPDB1 ...

Start of Statistics at 2019-12-31 09:13:26.

DDL replication statistics:

*** Total statistics since replicat started     ***
        Operations                                         0.00
        Mapped operations                                  0.00
        Unmapped operations                                0.00
        Other operations                                   0.00
        Excluded operations                                0.00
        Errors                                             0.00
        Retried errors                                     0.00
        Discarded errors                                   0.00
        Ignored errors                                     0.00

Replicating from APPS.T_CLOB to APPS.T_CLOB:

*** Daily statistics since 2019-12-31 08:49:14 ***
        Total inserts                                      1.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   1.00

End of Statistics.


GGSCI (WIN-846KA82M3MG) 224>

SYS@testogg>select * from apps.t_clob;

        ID
----------
TXT
--------------------------------------------------------------------------------

         1
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa


SYS@testogg>

-- truncate表 ,目標已經truncate

[email protected]/test>truncate table apps.t_clob;

Table truncated.

[email protected]/test>

SYS@testogg>select * from apps.t_clob;

未選定行

SYS@testogg>

-- 查看ggs_ddl_trace

SESS 570064-2019-12-31 09:39:05 : DDL : ************************* Start of log for DDL sequence [8022], v[ $Id: ddl_setup.sql /st_oggcore_11.2.1/38 2015/05/18 05:12:21 sijenki Exp $ ] trace level [0], owner schema of DDL package [GGS], objtype [TABLE] name [APPS.T_CLOB]
SESS 570064-2019-12-31 09:39:05 : DDLTRACE1 : Before Trigger: point in execution = [1.0], objtype [TABLE] name [APPS.T_CLOB]
SESS 570064-2019-12-31 09:39:05 : DDL : DDL operation [truncate table apps.t_clob  /* GOLDENGATE_DDL_REPLICATION */ ], sequence [8022], DDL type [TRUNCATE] TABLE, real object type [TABLE], validity [VALID], object ID [88547], object [APPS.T_CLOB], real object [APPS.T_CLOB], base object schema [], base object name [], logged as [GGS]
SESS 570064-2019-12-31 09:39:05 : DDL : Start SCN found [15209645]
SESS 570064-2019-12-31 09:39:05 : DDL : ------------------------- End of log for DDL sequence [8022], no DDL history metadata recorded for this DDL operation

-- 測試在源端drop掉該表,目標端查詢發現表不存在

[email protected]/test>drop table apps.t_clob;

Table dropped.

[email protected]/test>

SYS@testogg>select * from apps.t_clob;
select * from apps.t_clob
                   *
第 1 行出現錯誤:
ORA-00942: 表或視圖不存在


SYS@testogg>

源端和目標端的ddl記錄

SESS 4294967295-2019-12-31 09:52:55 : DDL : ************************* Start of log for DDL sequence [8013], v[ $Id: ddl_setup.sql /st_oggcore_11.2.1/38 2015/05/18 05:12:21 sijenki Exp $ ] trace level [0], owner schema of DDL package [GGS], objtype [TABLE] name [APPS.T_CLOB]
SESS 4294967295-2019-12-31 09:52:55 : DDLTRACE1 : Before Trigger: point in execution = [1.0], objtype [TABLE] name [APPS.T_CLOB]
SESS 4294967295-2019-12-31 09:52:55 : DDL : DDL operation [drop table apps.t_clob ], sequence [8013], DDL type [DROP] TABLE, real object type [TABLE], validity [VALID], object ID [90706], object [APPS.T_CLOB], real object [APPS.T_CLOB], base object schema [], base object name [], logged as [SYS]
SESS 4294967295-2019-12-31 09:52:55 : DDL : Start SCN found [24080720]
SESS 4294967295-2019-12-31 09:52:55 : DDL : ------------------------- End of log for DDL sequence [8013]
SESS 570064-2019-12-31 09:53:04 : DDL : ************************* Start of log for DDL sequence [8025], v[ $Id: ddl_setup.sql /st_oggcore_11.2.1/38 2015/05/18 05:12:21 sijenki Exp $ ] trace level [0], owner schema of DDL package [GGS], objtype [TABLE] name [APPS.T_CLOB]
SESS 570064-2019-12-31 09:53:04 : DDLTRACE1 : Before Trigger: point in execution = [1.0], objtype [TABLE] name [APPS.T_CLOB]
SESS 570064-2019-12-31 09:53:04 : DDL : DDL operation [drop table apps.t_clob  /* GOLDENGATE_DDL_REPLICATION */ ], sequence [8025], DDL type [DROP] TABLE, real object type [TABLE], validity [], object ID [], object [APPS.T_CLOB], real object [APPS.T_CLOB], base object schema [], base object name [], logged as [GGS]
SESS 570064-2019-12-31 09:53:04 : DDL : Start SCN found [15210402]
SESS 570064-2019-12-31 09:53:04 : DDL : ------------------------- End of log for DDL sequence [8025]

END

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章