DDL操作導致欄位長度變更修復方案

pingdanorcale發表於2023-03-16

第一步:檢視錯誤日誌

odbdbadm01.nxmobile.com:/ogg@db>

view ggserr.log

2021-01-08T07:48:54.967+0800  INFO      OGG-06510  Oracle GoldenGate   Delivery for Oracle, rep_ylxt.prm:  Using the   following key columns for target table SHBX.SHBX.AC01_CX: AAC001, AAE140.

2021-01-08T07:48:55.118+0800  ERROR     OGG-01163  Oracle GoldenGate   Delivery for Oracle, rep_ylxt.prm:  Bad   column length (51) specified for column AAE011 in table SHBX.BC06, maximum   allowable length is 50.

2021-01-08T07:48:55.118+0800  INFO      OGG-02333  Oracle GoldenGate   Delivery for Oracle, rep_ylxt.prm:    Reading /ogg/dirdat/at000004845, current RBA 109,116,398, 832 records,   m_file_seqno = 4,845, m_file_rba = 109,116,808.

2021-01-08T07:48:55.119+0800  ERROR     OGG-01668  Oracle GoldenGate   Delivery for Oracle, rep_ylxt.prm:    PROCESS ABENDING.

 

可以看到, rep_ylxt.prm: 由於欄位長度不一致,引發同步程式異常。

處理總體過程:

1、 修改目標庫欄位長度

2、 重新同步表定義檔案

第二步:檢視程式配置,找到目標庫(如果知道可省略)

REP_YLXT 程式出現問題,就檢視這個程式的情況,找到目標端具體是哪個 cdb 下面的哪個 pdb

GGSCI (odbdbadm01.nxmobile.com) 3> edit param  REP_YLXT

REPLICAT rep_ylxt

setenv (NLS_LANG =   "AMERICAN_AMERICA.AL32UTF8")

SETENV (ORACLE_SID = "rstcdb1")

SETENV (ORACLE_HOME =   "/u01/app/oracle/product/19.0.0.0/dbhome_1")

USERID ogg@shbx,PASSWORD AACAAAAAAAAAAAJAPBZFQEZANIGADEMGKBGGHJNEVBUBABNB,encryptkey   default

reperror default, abend

reportrollover at 00:30

可以看到,是 rstcdb1 這個 cdb 下面,用的 tns shbx tnsping 一下,找到具體的 pdb

檢視目標庫在哪:

odbdbadm01.nxmobile.com:/ogg@db>   tnsping shbx

 

TNS Ping Utility for Linux: Version   19.0.0.0.0 - Production on 08-JAN-2021 09:52:06

 

Copyright (c) 1997, 2020, Oracle.  All rights reserved.

 

Used parameter files:

/u01/app/oracle/product/19.0.0.0/dbhome_1/network/admin/sqlnet.ora

 

 

Used TNSNAMES adapter to resolve the   alias

Attempting to contact (DESCRIPTION =   (ADDRESS = (PROTOCOL = TCP)(HOST = 10.230.160.5)(PORT = 1521)) (CONNECT_DATA   = (SERVER = DEDICATED) ( SERVICE_NAME = SHBX)))

OK (0 msec)

odbdbadm01.nxmobile.com:/ogg@db>

說明在 rstcdb1 SHBX 這個 pdb 是目標庫。

 

第三步:進入pdb ,修改欄位長度

SQL> show pdbs

 

      CON_ID CON_NAME                         OPEN MODE  RESTRICTED

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

           2 PDB$SEED                         READ ONLY  NO

           3 SHBX                             READ WRITE NO

SQL> alter session set container=SHBX;

 

執行:

alter table SHBX.BC06 modify aae011 VARCHAR2 ( 51 );

修改到一致長度。

 

第四步:源端,生成表定義檔案

編輯定義表範圍:

GGSCI (nxsbdb1) 2> edit param defgen

 

DEFSFILE ./dirdef/def_ylxt.defs

USERID    ogg,password AACAAAAAAAAAAAJAPBZFQEZANIGADEMGKBGGHJNEVBUBABNB,encryptkey   default

TABLE SHBX.BC06

TABLE SHBX.BC06 這個表錯誤,先放這個表

 

執行如下命令,生成定義檔案:

./defgen paramfile ./dirprm/defgen.prm

生成日誌,注意觀察錯誤:

[nxsbdb1:oracle:/ogg/$]./defgen paramfile   ./dirprm/defgen.prm

 

***********************************************************************

          Oracle GoldenGate Table Definition Generator for Oracle

        Version 19.1.0.0.4 OGGCORE_19.1.0.0.0_PLATFORMS_191017.1054

     AIX 6, ppc, 64bit (optimized), Oracle 11g on Oct 17 2019 22:38:18

 

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

 

                    Starting at 2021-01-08   10:13:30

***********************************************************************

 

Operating System Version:

AIX

Version 7, Release 1

Node: nxsbdb1

Machine: 00FB3A5A4C00

                         soft limit   hard limit

Address Space Size   :      unlimited    unlimited

Heap Size            :    unlimited    unlimited

File Size            :    unlimited    unlimited

CPU Time             :    unlimited    unlimited

 

Process id: 54788238

 

***********************************************************************

**            Running with the following   parameters                  **

***********************************************************************

DEFSFILE ./dirdef/def_ylxt.defs

USERID    ogg,password ***,encryptkey default

TABLE SHBX.BC06;

Retrieving definition for SHBX.BC06.

 

 

Definitions generated for 1 table in   ./dirdef/def_ylxt.defs.

 

[nxsbdb1:oracle:/ogg/$] more ./dirdef/def_ylxt.defs

值看到這個表的定義檔案。

 

./dirdef/def_ylxt.defs 複製到目標端:

scp def_ylxt.defs 

 

第五步:編輯目標端複製程式

加入複製定義表:

Ggsci 進去:

Edit parameter REP_YLXT

REPLICAT rep_ylxt

setenv (NLS_LANG =   "AMERICAN_AMERICA.AL32UTF8")

SETENV (ORACLE_SID = "rstcdb1")

SETENV (ORACLE_HOME =   "/u01/app/oracle/product/19.0.0.0/dbhome_1")

USERID ogg@shbx,PASSWORD   AACAAAAAAAAAAAJAPBZFQEZANIGADEMGKBGGHJNEVBUBABNB,encryptkey default

reperror default, abend

reportrollover at 00:30

discardrollover at 00:00

DISCARDFILE   ./dirrpt/rep_ylxt.dec,APPEND,MEGABYTES 1024

sourcedefs /ogg/dirdef/def_ylxt.defs OVERRIDE

APPLYNOOPUPDATES

reportcount every 1 minutes, rate

把紅色這一塊: SOURCEDEFS ./dirdef/ def_ylxt.defs OVERRIDE 加入

第六步:啟動複製程式

GGSCI (odbdbadm01.nxmobile.com) 7>   start replicat REP_YLXT

 

Sending START request to MANAGER ...

REPLICAT REP_YLXT starting

 

 

GGSCI (odbdbadm01.nxmobile.com) 8>

 

GGSCI (odbdbadm01.nxmobile.com) 8>   info

ERROR: Invalid command.

 

GGSCI (odbdbadm01.nxmobile.com) 9>   info all

 

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

 

MANAGER     RUNNING                                          

REPLICAT    RUNNING     REP_JGB     00:00:00      43:37:12   

REPLICAT    RUNNING       REP_SHBX    00:00:05      00:00:03   

REPLICAT    RUNNING     REP_YLXT    22:18:18      00:00:01   

第七步:檢視一段時間錯誤日誌

tail -100f /ogg/ggserr.log


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10201716/viewspace-2939955/,如需轉載,請註明出處,否則將追究法律責任。

相關文章