Oracle GoldenGate系統之----相關引數說明

abin1703發表於2015-10-15

一、配置檔案存放位置
[oracle@dg ~]$ cd /u01/app/ogg/dirprm/

[oracle@dg dirprm]$ ls
dgrac.prm  extb.prm  extdg.prm  jagent.prm  mgr.prm  rep1.prm

二、 管理程式mgr配置檔案
[oracle@dg dirprm]$ more mgr.prm
PORT 7801                                --  監聽埠PORT
DYNAMICPORTLIST 7802-7820    -- 開啟其他程式使用埠(數量決定最大程式數)
AUTOSTART ER *                       -- 開啟管理程式後,自動啟動所有的EXTRACT及REPLICAT程式
AUTORESTART ER *,RETRIES 3,WAITMINUTES 2,RESETMINUTES 60  -- 自動重啟異常中止的程式,重試3次,每次等2分鐘,一小時後重試
STARTUPVALIDATIONDELAY 5    -- 啟動時延遲5秒校驗
PURGEOLDEXTRACTS ./dirdat/*,USECHECKPOINTS,MINKEEPDAYS 7    -- 自動清理EXTRACT目錄檔案,保留7天


三、 抽取程式,程式名不超過8個字元

[oracle@dg dirprm]$ more extdg.prm
#定義extract ,引數名和組名一致
extract extdg
#程式環境設定
setenv(NLS_LANG="AMERICAN_AMERICA.ZHS16GBK")
setenv(ORACLE_SID="wailon")
#使用者登入資訊,userid username@dbname,password userpwd
  userid scott,password tiger
#排除以下使用者的相關資訊
--tranlogoptions excludeuser scott
#生成EXTRACT TRAIL檔案位置,2個字元開頭,其他自動生成
exttrail /u01/app/ogg/dirdat/dg
#動態分析表結構
dynamicresolution
#捕捉TRUNCATE操作
  gettruncates
#定義需要同步的表,可使用萬用字元*
  table scott.*;
 
四、 PUMP傳送程式,extract程式的一種,把生成的EXTRACT TRAIL檔案傳送到遠端伺服器
[oracle@dg dirprm]$ more dgrac.prm
extract dgrac
setenv(NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
userid tiger

#遠端伺服器配置資訊
rmthost 192.168.56.131,mgrport 7801

#遠端伺服器生成的TRAIL檔案
rmttrail /u01/app/ogg/dirdat/dg

#直通模式或普通模式,兩邊表名及列名一樣用直通,否則用普通配置自定義對映
--NOPASSTHRU
PASSTHRU
gettruncates
table scott.*;
 

五、 應用程式replicat,程式名不超過8個字元
[oracle@dg dirprm]$ more rep1.prm
#定義replicat組名
replicat rep1
setenv(NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
userid , password tiger
#兩邊資料庫型別及結構一致時用ASSUMETARGETDEFS;否則使用SOURCEDEFS資料結構定義檔案,實現不同資料庫間同步
--assumetargetdefs
sourcedefs /u01/app/ogg/dirdef/emp.def

#應用資料出錯,預設丟棄

reperror default,discard

#丟棄的資料儲存檔案
discardfile /u01/app/ogg/dirout/rep1.dsc,append,megabytes 100
gettruncates
batchsql

#源物件和目標物件對映關係,列名不一樣時用colmap,列名用雙引號引用,列名與“=”之間有空格
map scott.b, target scott.b, &
colmap(usedefaults, "OWNER" = "USERNAME");

#表對映關係,注意target前有一個空格
  map scott.emp, target scott.emp;
map scott.dept, target scott.dept;
 
六、 初始化載入
1、源端

[oracle@dg dirprm]$ more extb.prm
extract extb
setenv(NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
userid , password tiger
rmthost 192.168.56.131, mgrport 7801
rmttask replicat, group repb
table scott.b;
 
2、目標
[oracle@dgrac dirprm]$ more repb.prm
replicat repb
assumetargetdefs
userid , password tiger
reperror default,discard
discardfile /u01/app/ogg/dirtmp/repb.dsc,append,megabytes 100
#INSERTAPPEND 直接路徑載入,提高載入速度
--INSERTAPPEND
#當目標端存在相同資料時,忽略重複資料錯誤
HANDLECOLLISIONS
map scott.b, target scott.b;

[oracle@dgrac dirprm]$ -- 資料定義檔案引數檔案
[oracle@dgrac dirprm]$ more defgen.prm
defsfile /u01/app/ogg/dirdef/emp.def
userid tiger
table scott.emp;
table scott.dept;
table scott.b;

[oracle@dgrac dirprm]$ cd ..
[oracle@dgrac ogg]$ -- 根據引數檔案生成資料定義檔案
[oracle@dgrac ogg]$ ./defgen paramfile dirprm/defgen.prm

[oracle@dg ogg]$ cd dirdef/
[oracle@dg dirdef]$ -- 資料定義檔案目錄
[oracle@dg dirdef]$ ls
emp.def
[oracle@dg dirdef]$ -- 資料定義檔案格式
[oracle@dg dirdef]$ more emp.def
*+- Defgen version 2.0, Encoding US-ASCII
*
* Definitions created/modified  2013-09-25 23:16
*
*  Field descriptions for each column entry:
*
*     1    Name
*     2    Data Type
*     3    External Length
*     4    Fetch Offset
*     5    Scale
*     6    Level
*     7    Null
*     8    Bump if Odd
*     9    Internal Length
*    10    Binary Length
*    11    Table Length
*    12    Most Significant DT
*    13    Least Significant DT
*    14    High Precision
*    15    Low Precision
*    16    Elementary Item
*    17    Occurs
*    18    Key Column
*    19    Sub Data Type
*
Database type: ORACLE
Character set ID: windows-936
National character set ID: UTF-16
Locale: neutral
Case sensitivity: 14 14 14 14 14 14 14 14 14 14 14 14 11 14 14 14
*
Definition for table SCOTT.EMP
Record length: 112
Syskey: 0
Columns: 8
EMPNO     134      8        0  0  0 1 0      8      8      8 0 0 0 0 1    0 1 3
ENAME      64     10       12  0  0 1 0     10     10      0 0 0 0 0 1    0 0 0
JOB        64      9       28  0  0 1 0      9      9      0 0 0 0 0 1    0 0 0
MGR       134      8       42  0  0 1 0      8      8      8 0 0 0 0 1    0 0 3
HIREDATE  192     19       54  0  0 1 0     19     19     19 0 5 0 0 1    0 0 0
SAL       134      9       76  2  0 1 0      8      8      8 0 0 0 0 1    0 0 3
COMM      134      9       88  2  0 1 0      8      8      8 0 0 0 0 1    0 0 3
DEPTNO    134      8      100  0  0 1 0      8      8      8 0 0 0 0 1    0 0 3
End of definition
*
Definition for table SCOTT.DEPT
Record length: 50
Syskey: 0
Columns: 3
DEPTNO  134      8        0  0  0 1 0      8      8      8 0 0 0 0 1    0 1 3
DNAME    64     14       12  0  0 1 0     14     14      0 0 0 0 0 1    0 0 0
LOC      64     13       32  0  0 1 0     13     13      0 0 0 0 0 1    0 0 0
End of definition
*
Definition for table SCOTT.B
Record length: 532
Syskey: 0
Columns: 15
USERNAME         64     30        0  0  0 1 0     30     30      0 0 0 0 0 1    0 0 0
OBJECT_NAME      64    128       36  0  0 1 0    128    128      0 0 0 0 0 1    0 0 0
SUBOBJECT_NAME   64     30      170  0  0 1 0     30     30      0 0 0 0 0 1    0 0 0
OBJECT_ID        64     50      206  0  0 1 0     50     50     50 0 0 0 0 1    0 1 2
DATA_OBJECT_ID   64     50      262  0  0 1 0     50     50     50 0 0 0 0 1    0 0 2
OBJECT_TYPE      64     19      318  0  0 1 0     19     19      0 0 0 0 0 1    0 0 0
CREATED         192     19      342  0  0 1 0     19     19     19 0 5 0 0 1    0 0 0
LAST_DDL_TIME   192     19      364  0  0 1 0     19     19     19 0 5 0 0 1    0 0 0
TIMESTAMP        64     19      386  0  0 1 0     19     19      0 0 0 0 0 1    0 0 0
STATUS           64      7      410  0  0 1 0      7      7      0 0 0 0 0 1    0 0 0
TEMPORARY        64      1      422  0  0 1 0      1      1      0 0 0 0 0 1    0 0 0
GENERATED        64      1      428  0  0 1 0      1      1      0 0 0 0 0 1    0 0 0
SECONDARY        64      1      434  0  0 1 0      1      1      0 0 0 0 0 1    0 0 0
NAMESPACE        64     50      440  0  0 1 0     50     50     50 0 0 0 0 1    0 0 2
EDITION_NAME     64     30      496  0  0 1 0     30     30      0 0 0 0 0 1    0 0 0
End of definition

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

相關文章