ogg脱敏复制


实验情况是源端与目标端的表结构不同:




源端:


1.配置defgen参数

GGSCI (test1) 23> edit params defgen
DEFSFILE ./dirdef/product.def
userid scofy,password scofy
table pdg.products;                      ////结构不同的表


2.生成product.def文件

[n@test1 ~]$ ./defgen paramfile ./dirprm/defgen.prm

***********************************************************************
        Oracle GoldenGate Table Definition Generator for Oracle
      Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230
   Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 05:08:19
 
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.

                    Starting at 2015-12-09 16:17:22
***********************************************************************
Operating System Version:
Linux
Version #1 SMP Sun Nov 10 22:19:54 EST 2013, Release 2.6.32-431.el6.x86_64
Node: test1
Machine: x86_64
                         soft limit   hard limit
Address Space Size   :    unlimited    unlimited
Heap Size            :    unlimited    unlimited
File Size            :    unlimited    unlimited

CPU Time             :    unlimited    unlimited


Process id: 3852

***********************************************************************
**            Running with the following parameters                  **
***********************************************************************
DEFSFILE ./dirdef/product.def
userid scofy,password *****
table pdg.products;
Retrieving definition for PDG.PRODUCTS

Definitions generated for 1 table in ./dirdef/product.def



3.把生成的./dirdef/product.def,ftp到目标端/home/n/dirdef/:


[n@test1 dirdef]$ scp product.def [email protected]:/home/n/dirdef/


4.进程参数修改:
GGSCI (test1) 1> view param ext_dp

EXTRACT ext_dp
USERID scofy, PASSWORD scofy
RMTHOST 10.80.18.250, MGRPORT 7839
RMTTRAIL ./dirdat/rt
table pdg.vendors;
table pdg.products;


GGSCI (test1) 3> view param ext_pdg

EXTRACT ext_pdg
USERID scofy, PASSWORD scofy
EXTTRAIL ./dirdat/it
table pdg.vendors;
table pdg.products;



目标端:


1.目标端的表结构:

CREATE TABLE products2

  ( name   VARCHAR2(50)
   , qty_oh NUMBER(6) 
  ); 


2.修改目标端进程参数:

GGSCI (test3) 18> edit param rep_pdg

REPLICAT  rep_pdg
ASSUMETARGETDEFS
setenv (ORACLE_SID="target2")
USERID ogg, PASSWORD ogg
sourcedefs /home/n/dirdef/product.def
map pdg.products  ,target hc.products2, colmap (NAME=NAME, QTY_OH=QTY_OH);
map pdg.vendors   ,target hc.vendors1;


主库插入一条语句:
SQL> INSERT INTO products VALUES (1254,'scofy3', 0.55,  29, 200);

1 row created.

SQL> commit;
Commit complete.

备库查询:
SQL> select * from pRODUCTS2;


NAME                                                   QTY_OH
-------------------------------------------------- ----------
scofy3                                                     29



MAP语法介绍和实验:
MAP  table_name1
, TARGET  table_name2,COLMAP ([USEDEFAULTS, ] 目标端列=源端列 );          
///目标端一定要写在左边,其他相同列就可以用usedefaults代替。
我这里在目标端使用COLMAP
解释一下:
USEDEFAULTS:源端的列名与目标端的列名相同,使用USEDEFAULTS
target column:目标列
source expression:源端表达式或列


GGSCI (test3) 23> edit param rep_pdg
REPLICAT rep_pdg
ASSUMETARGETDEFS
setenv (ORACLE_SID="target2")
USERID ogg, PASSWORD ogg
sourcedefs /home/n/dirdef/product.def
map pdg.products  ,target hc.products2, colmap (usedefaults);
map pdg.vendors   ,target hc.vendors1;


SQL> INSERT INTO products VALUES (1254,'scofy3', 0.55, 49, 200);


SQL> select * from pRODUCTS2;


NAME                                                   QTY_OH
-------------------------------------------------- ----------
scofy3                                                     29
scofy3                                                     49

你可能感兴趣的:(ogg)