使用資料泵進行Oracle-Oracle的單向複製。

xchui702發表於2014-11-17
2.       使用資料泵進行Oracle-Oracle的單向複製。
把docrac1 上golden 資料庫裡ggs 使用者下的表資料,透過data pump 的形式複製到 docrac2 上的golden 資料庫的ggt使用者下。
2.1    源端的配置
2.1.1          資料庫的配置
a.)     建立使用者ogg/oracle, 並grand dba 許可權。
b.)     Verify the GG can work
GGSCI (docrac1) 1> dblogin userid ogg,password oracle
Successfully logged into database.
c.)     Create sub directory
GGSCI (docrac1) 2> create subdirs
Creating subdirectories under current directory /backup/ggsrc
Parameter files                /backup/ggsrc/dirprm: already exists
Report files                   /backup/ggsrc/dirrpt: created
Checkpoint files               /backup/ggsrc/dirchk: created
Process status files           /backup/ggsrc/dirpcs: created
SQL script files               /backup/ggsrc/dirsql: created
Database definitions files     /backup/ggsrc/dirdef: created
Extract data files             /backup/ggsrc/dirdat: created
Temporary files                /backup/ggsrc/dirtmp: created
Stdout files                   /backup/ggsrc/dirout: created
d.)     修改資料庫的為歸檔模式,並且啟用附加log.
SQL> alter database add supplemental log data;
Database altered.
SQL> select supplemental_log_data_min from v$database;
SUPPLEME
--------
YES
e.)     建立源表所屬的使用者ggs: 
Create user ggs identified by ggs;
Grant connect, resource to ggs;
Grant select any table to ggs;
Grant select any dictionary to ggs;
2.1.2          Mgr 的配置
GGSCI (docrac1) 31> edit param mgr
port 7777
dynamicportlist 7808~7920
purgeoldextracts /backup/ggsrc/dirdat/*
2.1.3          extract 程式的配置
2.1.3.1    配置extract引數
GGSCI (docrac1) 32> edit param ext1
extract ext1
--------------------------------------------------------------------
--Local extract for table david
--create date: 2014/11/08
--------------------------------------------------------------------
setenv (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
--setenv (NLS_LANG=en_US.UTF-8)
USERID ogg@golden,password oracle
exttrail /backup/ggsrc/dirdat/sp
table ggs.*;
2.1.3.2    建立extract程式
GGSCI (docrac1) 2> add extract ext1, tranlog, begin now;
EXTRACT added.
GGSCI (docrac1) 4> add exttrail /backup/ggsrc/dirdat/sp, extract ext1, megabytes 100
EXTTRAIL added.
2.1.4          data pump 的配置
2.1.4.1    引數配置
GGSCI (docrac1) 34> edit param dp1
extract dp1
----------------------------------------
--Data Pump extract for ggs.*
--create data: 11/06
--author: david
----------------------------------------
PassThru
setenv (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
--setenv (NLS_LANG=en_US.UTF-8)
--USERID ggt,password ggt
RmtHost docrac2,MgrPort 7777
RmtTrail /backup/ggsrc/dirdat/rp
Table ggs.*;
2.1.4.2    建立dp程式
GGSCI (docrac1) 48> add extract dp1, exttrailsource /backup/ggsrc/dirdat/sp
EXTRACT added.
GGSCI (docrac1) 49> add rmttrail /backup/ggsrc/dirdat/rp, extract dp1, megabytes 100
RMTTRAIL added.
2.1.4.3   
2.2    目標端的配置
2.2.1          建立使用者ogg/oracle, 並grand dba 許可權。
2.2.2          資料庫建立使用者ggt, 目標表放置的位置
Create user ggt identified by ggt;
Grant connect, resource to ggt;
Grant select any table to ggt;
Grant select any dictionary to ggt;
2.2.3          建立golden gate 的目錄
GGSCI (docrac2) 2> create subdirs
2.2.4          Mgr的配置
port 7777
purgeoldextracts /backup/ggsrc/dirdat/*
2.2.5          Rp的配置
2.2.5.1    配置rp引數
replicat rp1
setenv (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
--setenv (NLS_LANG=en_US.UTF-8)
USERID ogg@golden,password oracle
HandleCollisions
AssumeTargetDefs
Map ggs.*, Target ggt.*
2.2.5.2    建立replicat 程式
GGSCI (docrac2) 4> add replicat rp1,exttrail /backup/dirdat/rp
REPLICAT added.
2.3    在目標端啟動mgr
2.4    在源端啟動mgr
2.5    在源端啟動extract
2.5.1          啟動Extract程式
GGSCI (docrac1) 5> start extract ext1
Sending START request to MANAGER ...
EXTRACT EXT1 starting
2.6    在源端啟動 dp
2.6.1          啟動data pump 程式
GGSCI (docrac1) 3> start extract dp1
Sending START request to MANAGER ...
EXTRACT DP1 starting
2.7    在目標端啟動rp
2.7.1          啟動replicat 程式
GGSCI (20130831-1006) 5> start replicat rp1
Sending START request to MANAGER ...
REPLICAT RP1 starting
2.8    資料複製驗證
2.8.1          當前源和目標資料庫建立相同的表,並且在源端insert/delete 資料,都能保證源端和目標端同步。
2.8.2          檢查ext1 的狀態
GGSCI (docrac1) 68> info ext1 detail
EXTRACT    EXT1      Last Started 2014-11-16 18:21   Status RUNNING
Checkpoint Lag       00:00:00 (updated 00:00:03 ago)
Log Read Checkpoint  Oracle Redo Logs
                     2014-11-16 19:43:48  Seqno 116, RBA 81920
                     SCN 0.935181 (935181)
  Target Extract Trails:
Remote Trail Name                                Seqno        RBA     Max MB
  /backup/ggsrc/dirdat/sp                              0       1761        100
  Extract Source                          Begin             End
  /backup/oracle/oradata/GOLDEN/onlinelog/o1_mf_2_b5orn8tc_.log  2014-11-16 18:21  2014-11-16 19:43
  Not Available                           * Initialized *   2014-11-16 18:21
Current directory    /backup/ggsrc
Report file          /backup/ggsrc/dirrpt/EXT1.rpt
Parameter file       /backup/ggsrc/dirprm/ext1.prm
Checkpoint file      /backup/ggsrc/dirchk/EXT1.cpe
Process file         /backup/ggsrc/dirpcs/EXT1.pce
Stdout file          /backup/ggsrc/dirout/EXT1.out
Error log            /backup/ggsrc/ggserr.log
2.8.3          檢查dp1的狀態
GGSCI (docrac1) 70> info dp1 detail
EXTRACT    DP1       Last Started 2014-11-16 18:33   Status RUNNING
Checkpoint Lag       00:00:00 (updated 00:00:07 ago)
Log Read Checkpoint  File /backup/ggsrc/dirdat/sp000000
                     2014-11-16 19:24:25.000000  RBA 1761
  Target Extract Trails:
Remote Trail Name                       Seqno   RBA     Max MB
  /backup/ggsrc/dirdat/rp                   0       1796        100
  Extract Source                          Begin             End
  /backup/ggsrc/dirdat/sp000000           * Initialized *   2014-11-16 19:24
  /backup/ggsrc/dirdat/sp000000           * Initialized *   First Record
Current directory    /backup/ggsrc
Report file          /backup/ggsrc/dirrpt/DP1.rpt
Parameter file       /backup/ggsrc/dirprm/dp1.prm
Checkpoint file      /backup/ggsrc/dirchk/DP1.cpe
Process file         /backup/ggsrc/dirpcs/DP1.pce
Stdout file          /backup/ggsrc/dirout/DP1.out
Error log            /backup/ggsrc/ggserr.log
2.8.4          檢查rp1的狀態
GGSCI (docrac2) 14> info rp1 detail
REPLICAT   RP1       Last Started 2014-11-16 19:22   Status RUNNING
Checkpoint Lag       00:00:00 (updated 00:00:01 ago)
Log Read Checkpoint  File dirdat/rp000000
                     2014-11-16 19:24:24.986241  RBA 1796
  Extract Source                          Begin             End
  dirdat/rp000000                         * Initialized *   2014-11-16 19:24
  dirdat/rp000000                         * Initialized *   First Record
  dirdat/rp000000                         * Initialized *   First Record
  dirdat/rp000000                         * Initialized *   First Record
  dirdat/rp000000                         * Initialized *   First Record
Current directory    /backup/ggsrc
Report file          /backup/ggsrc/dirrpt/RP1.rpt
Parameter file       /backup/ggsrc/dirprm/rp1.prm
Checkpoint file      /backup/ggsrc/dirchk/RP1.cpr
Checkpoint table     ogg.chkpt
Process file         /backup/ggsrc/dirpcs/RP1.pcr
Stdout file          /backup/ggsrc/dirout/RP1.out
Error log            /backup/ggsrc/ggserr.log

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

相關文章