首页 > 代码库 > OGG新增表下发详细步骤及相关注意事项

OGG新增表下发详细步骤及相关注意事项

背景:

        工作任务OGG新增下发表,根据系统架构,数据下发流程为:系统A --> 系统B --> 系统C

        系统A:在与系统B相关的抽取进程(EXTSJXF)的参数文件中新增相关表,在与系统B相关的投递进程(DPDJZSJ1)的参数文件中新增相关表。

        系统B:复制进程(REPDJZ2)的参数文件中新增相关表,进行应用,在与系统C相关的抽取进程(EXTJHXT1)的参数文件中新增下发表,同理,投递进程(DPJHSJ1)亦需要在进程参数文件中新增表 

        系统C:复制进程(REPJHXT1)参数文件新增相关表

        下发表说明:业务问题,系统A用户QAS的数据将导入到系统B的用户QAS_TEST下(remap table),即

        系统A:QAS.T_LOG_TICKET_PROVINCE、QAS.T_LOG_TICKET_TASK_PROVINCE

        系统B:QAS_TEST.T_LOG_TICKET_PROVINCE 、QAS_TEST.T_LOG_TICKET_TASK_PROVINCE

        通过datapump初始化,总体工作流程如下:

 技术分享

一、工作步骤:

1、  系统A --> 系统B

(1)系统A抽取进程EXTSJXF修改参数文件

GGSCI (A)1> stop EXTSJXF  --停止进程进行参数文件修改
GGSCI (A)2> edit param EXTSJXF  ---编辑参数文件新增如下
--20170808 add 
TABLE QAS.*      ;
--登录数据库goldengate用户,打开表级附加日志
GGSCI (A) 3>dblogin userid goldengate password goldengate;
GGSCI (A) 4>ADD TRANDATA QAS.T_LOG_TICKET_PROVINCE
GGSCI (A) 5>ADD TRANDATA QAS.T_LOG_TICKET_TASK_PROVINCE
GGSCI (A) 6> start EXTSJXF

(2)系统A投递进程DPDJZSJ1修改参数文件

GGSCI (A) 7> stop DPDJZSJ1
GGSCI (A) 8> edit param DPDJZSJ1
--20170808 add
TABLE QAS.*  ;

(3)停止系统B复制进程REPDJZ2

GGSCI (B) 1> stop REPDJZ2

(4)系统A基于SCN号抽取数据

  • 预估数据大小
SQL> select sum(BYTES/1024/1024) MB from dba_segments where owner =QAS and SEGMENT_NAME=T_LOG_TICKET_PROVINCE;

        MB
----------
  560.0625

SQL> select sum(BYTES/1024/1024) MB from dba_segments where owner =QAS and SEGMENT_NAME=T_LOG_TICKET_TASK_PROVINCE;

        MB
----------
 1816.0625
  • 定义导出目录
SQL> create directory OGG_EXPDP as /data4/ogg_expdp;

技术分享

  • 查询scn号
SQL> col current_scn for 9999999999999999
SQL> select current_scn from v$database;

      CURRENT_SCN
-----------------
      15585673221354
  • 编辑expdp执行脚本并执行
vi expdp_djz_shiju2_oas_20170808.par
USERID    = "/ as sysdba"
DIRECTORY = OGG_EXPDP
FLASHBACK_SCN= 15585673221354
DUMPFILE  = expdp_djz_shiju2_oas_20170808.dmp
logfile   = expdp_djz_shiju2_oas_20170808.log
tables  =(QAS.T_LOG_TICKET_PROVINCE,    
          QAS.T_LOG_TICKET_TASK_PROVINCE)
--后台执行脚本
nohup expdp parfile=expdp_djz_shiju2_oas_20170808.par > expdp_djz_shiju2_oas_20170808.par.out &
  • scp将dmp文件从系统A传至系统B
$scp expdp_djz_shiju2_oas_20170808.dmp oracle@系统B的IP:传至的目录

(6)系统B导入数据,已有相关的导入目录,使用remap将用户OAS的数据导入导OAS_GZDS下

vi impdp_djz_shiju2_oas_20170808.par
USERID  =/ as sysdba
DIRECTORY = IMPDP
DUMPFILE  = expdp_djz_shiju2_oas_20170808.dmp
logfile   = impdp_djz_shiju2_oas_20170808.log
REMAP_SCHEMA=QAS:QAS_TEST
REMAP_TABLESPACE=USERS:TS_QAS_TEST
TABLE_EXISTS_ACTION=replace
--后台执行脚本
nohup impdp parfile=impdp_djz_shiju2_oas_20170808.par > impdp_djz_shiju2_oas_20170808.par.out &

(7)系统B复制进程REPDJZ2参数文件修改

GGSCI (B) 2> edit param REPDJZ2
--20170808add
MAP QAS.*        , TARGET QAS_TEST.*    ,FILTER(@GETENV("TRANSACTION","CSN")>15585673221354);  --系统A基于SCN号导出,系统B基于CSN号开启应用

(8)开启系统A的投递进程DPDJZSJ1

GGSCI (A) 11> start DPDJZSJ1

(9)开启系统B的应用进程REPDJZ2

GGSCI (B) 3> start REPDJZ2

(10)数据对比

  • ./ggsci  下查看相关统计数据
GGSCI (A) 11> stats DPDJZSJ1,daily
GGSCI (B) 4> stats REPDJZ2,daily
  • 在数据库中查询数据量
--系统A:
SQL> select count(1) from QAS.T_LOG_TICKET_TASK_PROVINCE;

  COUNT(1)
----------
  16919333

SQL> select count(1) from QAS.T_LOG_TICKET_PROVINCE;

  COUNT(1)
----------
   4618927
---系统B:
SQL> select count(1) from QAS_GZDS.T_LOG_TICKET_TASK_PROVINCE;

  COUNT(1)
----------
  16919333

SQL> select count(1) from QAS_GZDS.T_LOG_TICKET_PROVINCE;

  COUNT(1)
----------
   4618927

2、  系统B --> 系统C

(1)系统B抽取进程EXTJHXT1新增下发表

GGSCI (B) 13> stop EXTJHXT1
GGSCI (B) 14> edit param EXTJHXT1
--20170808 add 2tbs
TABLE QAS_TEST.T_LOG_TICKET_PROVINCE       ;
TABLE QAS_TEST.T_LOG_TICKET_TASK_PROVINCE  ;
GGSCI (B)
15> dblogin userid goldengate password goldengate; GGSCI (B) 16> ADD TRANDATA QAS_GZDS.T_LOG_TICKET_PROVINCE Logging of supplemental redo data enabled for table QAS_GZDS.T_LOG_TICKET_PROVINCE. GGSCI (B) 18> info trandata QAS_GZDS.T_LOG_TICKET_PROVINCE Logging of supplemental redo log data is enabled for table QAS_GZDS.T_LOG_TICKET_PROVINCE. Columns supplementally logged for table QAS_GZDS.T_LOG_TICKET_PROVINCE: TICKET_ID. GGSCI (B) 19> ADD TRANDATA QAS_GZDS.T_LOG_TICKET_TASK_PROVINCE Logging of supplemental redo data enabled for table QAS_GZDS.T_LOG_TICKET_TASK_PROVINCE. GGSCI (B) 20> info TRANDATA QAS_GZDS.T_LOG_TICKET_TASK_PROVINCE Logging of supplemental redo log data is enabled for table QAS_GZDS.T_LOG_TICKET_TASK_PROVINCE. Columns supplementally logged for table QAS_GZDS.T_LOG_TICKET_TASK_PROVINCE: TASK_ID. GGSCI (B) 21> start EXTJHXT1 --开启抽取进程EXTJHXT1

(2)系统B投递进程DPJHSJ1新增表及停止

GGSCI (B) 22> stop DPJHSJ1
GGSCI (B) 23> edit param DPJHSJ1
--20170808 add 2tbs
TABLE QAS_TEST.T_LOG_TICKET_PROVINCE       ;
TABLE QAS_TEST.T_LOG_TICKET_TASK_PROVINCE  ;

(3)系统C复制进程REPJHXT1停止

GGSCI (A) 22> stop REPJHXT1

(4)系统B基于SCN号抽取数据

  • 查询系统B的scn号
SQL> col current_scn for 9999999999999999
SQL> select current_scn from v$database;

      CURRENT_SCN
-----------------
      15389350836731
  • 编辑expdp执行脚本并执行
vi expdp_sj2_sj1_2tb_20170808.par
USERID=/ as sysdba
DIRECTORY=IMPDP
LOGFILE=expdp_sj2_sj1_2tb_20170808.log
FLASHBACK_SCN=15389350836731
DUMPFILE=expdp_sj2_sj1_2tb_20170808.dmp
tables=(QAS_GZDS.T_LOG_TICKET_PROVINCE,
QAS_GZDS.T_LOG_TICKET_TASK_PROVINCE)
--后台执行脚本
nohup expdp parfile=expdp_sj2_sj1_2tb_20170808.par > expdp_sj2_sj1_2tb_20170808.par.out &

(5)scp将dmp文件从系统B传至系统C

$scp expdp_sj2_sj1_2tb_20170808.dmp oracle@系统C的IP:传至的目录

(6)系统C导入数据

vi impdp_sj2_sj1_2tb_20170808.par
USERID=/ as sysdba
DIRECTORY=IMPDP
LOGFILE=impdp_sj2_sj1_2tb_20170808.log
DUMPFILE=expdp_sj2_sj1_2tb_20170808.dmp
TABLE_EXISTS_ACTION=replace
--后台执行脚本
nohup impdp parfile=impdp_sj2_sj1_2tb_20170808.par > impdp_sj2_sj1_2tb_20170808.par.out &

(7)系统C复制进程REPDJZ2参数文件修改

--20170808 add 2tbs
MAP QAS_GZDS.T_LOG_TICKET_PROVINCE       ,TARGET QAS_GZDS.T_LOG_TICKET_PROVINCE      ,FILTER(@GETENV("TRANSACTION","CSN")>15389350836731);
MAP QAS_GZDS.T_LOG_TICKET_TASK_PROVINCE  ,TARGET QAS_GZDS.T_LOG_TICKET_TASK_PROVINCE ,FILTER(@GETENV("TRANSACTION","CSN")>15389350836731);  
--系统B基于SCN号导出,系统C基于CSN号开启复制进程应用

(8)开启系统B的投递进程DPJHSJ1

GGSCI (B) 11> sart DPJHSJ1

(9)开启系统C的应用进程REPJHXT1

GGSCI (C) 3> start REPJHXT1

(10)数据对比

  •   ./ggsci  下查看相关统计数据
GGSCI (B) 11> stats DPJHSJ1,daily
GGSCI (C) 4> stats REPJHXT1,daily
  •   在数据库中查询数据量
--系统B:
SQL> select count(1) from QAS_GZDS.T_LOG_TICKET_TASK_PROVINCE;

  COUNT(1)
----------
  16919333

SQL> select count(1) from QAS_GZDS.T_LOG_TICKET_PROVINCE;

  COUNT(1)
----------
   4618927
---系统C:
SQL> select count(1) from QAS_GZDS.T_LOG_TICKET_TASK_PROVINCE;

  COUNT(1)
----------
  16919333

SQL> select count(1) from QAS_GZDS.T_LOG_TICKET_PROVINCE;

  COUNT(1)
----------
   4618927

三、其他说明:

1、打开表级附加日志时无唯一索引处理

系统A数据在导入系统B时索引已存在,由于系统B需抽取此部分数据投递至系统C,在附加表级日志时最好有唯一索引作为唯一key以保障数据的唯一性。所以在系统B中重命名原先的索引。此处解决方案考虑结合了系统的业务情况。无唯一索引附加表级日志出现以下告警:

GGSCI (B) 10> ADD TRANDATA QAS_TEST.T_LOG_TICKET_PROVINCE
2017-08-08 15:21:19  WARNING OGG-00869  No unique key is defined for table T_LOG_TICKET_PROVINCE. All viable columns will be used to represent the key, but may not guarantee uniqueness.  KEYCOLS may be used to define the key.
Logging of supplemental redo data enabled for table QAS_TEST.T_LOG_TICKET_PROVINCE.

(1)      在dmp文件中提取出sql语句

vi impdp_djz_sj2_oas_sql_2017080.par
USERID  =/ as sysdba
DIRECTORY = IMPDP
DUMPFILE  = expdp_djz_shiju2_oas_20170808.dmp
LOGFILE=impdp_djz_sj2_oas_sql_20170808.log
SQLFILE=impdp_djz_sj2_oas_sql_20170808.sql
INCLUDE=INDEX,CONSTRAINT
nohup impdp parfile=impdp_djz_sj2_oas_sql_2017080.par > impdp_djz_sj2_oas_sql_2017080.par.out &

(2)      在impdp_djz_shiju2_oas_sql_20170808.sql中找到相关sql语句,修改后在系统B中执行:

CREATE UNIQUE INDEX QAS_TEST.PK_T_LOG_TICKET_PROVINCE ON QAS_TEST.T_LOG_TICKET_PROVINCE (TICKET_ID)
  PCTFREE 10 INITRANS 2 MAXTRANS 255 
  STORAGE(INITIAL 8388608 NEXT 8388608 MINEXTENTS 1 MAXEXTENTS 2147483645  
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1  
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE DB_SBFDB_DATA3;

 
CREATE UNIQUE INDEX QAS_TEST.PK_T_LOG_TICKET_TASK_PROVINCE ON QAS_TEST.T_LOG_TICKET_TASK_PROVINCE (TASK_ID) 
  PCTFREE 10 INITRANS 2 MAXTRANS 255 
  STORAGE(INITIAL 8388608 NEXT 8388608 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE DB_SBFDB_DATA3;

2、系统A的数据导入系统B时报错,用户不存在报错可忽略,本次为数据下发,非数据库重建。索引已存在是由于业务问题造成,可按照上文重命名并新建索引。

ORA-39083: Object type OBJECT_GRANT failed to create with error:
ORA-01917: user or role DB_DSYY does not exist
Failing sql is:
GRANT UPDATE ON "QAS_TEST"."T_LOG_TICKET_TASK_PROVINCE" TO "DB_DSYY"
 
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
ORA-31684: Object type INDEX:"QAS_TEST"."PK_T_LOG_TICKET" already exists
ORA-31684: Object type INDEX:"QAS_TEST"."PK_T_LOG_TICKET_TASK" already exists

3、文章说明

OGG新增下发表时,需注意各个进程启动顺序,以保障数据的一致性,OGG工作顺序:源端抽取——>源端投递——>目标端应用。

OGG新增表下发详细步骤及相关注意事项