第一步:查看错误日志
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