当前位置:操作系统 > Unix/Linux >>

GoldenGate系列一:快速搭建单向同步GoldenGate环境

GoldenGate系列一:快速搭建单向同步GoldenGate环境
 
1、环境准备
(1)下载安装包并解压至ORACLE_BASE
 
(2)修改环境变更
 
[plain] 
[oracle@irms156ogg]$ vi ~/.bashrc  
exportPATH=$ORACLE_HOME/bin:/u01/app/ogg:$PATH  
 
(3)创建子目录
 
[plain] 
[oracle@irms157 ogg]$ ggsci  
   
GGSCI (irms157) 1> create subdirs  
   
Creating subdirectories under currentdirectory /u01/app/ogg  
   
Parameter files                /u01/app/ogg/dirprm: alreadyexists  
Report files                   /u01/app/ogg/dirrpt: created  
Checkpoint files               /u01/app/ogg/dirchk: created  
Process status files           /u01/app/ogg/dirpcs: created  
SQL script files               /u01/app/ogg/dirsql: created  
Database definitions files     /u01/app/ogg/dirdef: created  
Extract data files             /u01/app/ogg/dirdat: created  
Temporary files                /u01/app/ogg/dirtmp: created  
Stdout files                   /u01/app/ogg/dirout: created  
 
注:建议所有Goldengate操作均在Goldengate安装目录下进行。
 
2、开启管理进程
(1)创建管理进程参数文件
 
[plain] 
GGSCI (irms156) 1> edit params mgr  
port 7809  
 
(2)启动管理器
 
[plain] 
GGSCI(irms156) 2> start mgr   
Managerstarted.   
   
GGSCI(irms156) 3> info mgr   
Manager isrunning (IP port irms156.7809).   
   
GGSCI(irms156) 4> info all   
Program     Status     Group       Lag at Chkpt  Time Since Chkpt   
MANAGER     RUNNING    
 
3、在源端开启补充日志
 
(1)Oracle-specificinstallation steps
 
Thefollowing steps are only required when GoldenGate will be capturing data fromthe server. Therefore it is only needed when you are installing GoldenGate forOracle as your<source> environment.
 
[sql] 
[oracle@irms157 ogg]$ sqlplus /nolog  
   
SQL> conn / as sysdba  
Connected.  
SQL> alter database add supplementallog data;  
   
Database altered.  
   
SQL> alter system switch logfile;  
   
System altered.  
 
(2)为具体模式对象开启补充日志(Add supplemental logging)
 
[sql] 
GGSCI (irms156) 9> dblogin useridsystem, password Lu123456;  
Successfully logged into database.  
   
GGSCI (irms156) 10> add trandatascott.emp;  
ERROR: No viable tables matchedspecification.(注意不要有分号)  
   
GGSCI (irms156) 11> add trandatascott.emp  
   
Logging of supplemental redo dataenabled for table SCOTT.EMP.  
   
GGSCI (irms156) 13> add trandata scott.salgrade  
   
2013-05-14 14:29:47  WARNING OGG-00869  No unique key is defined for table'SALGRADE'. All viable columns will be used to represent the key, but may notguarantee uniqueness.  KEYCOLS may beused to define the key.  
   
Logging of supplemental redo dataenabled for table SCOTT.SALGRADE.  
   
GGSCI (irms156) 14> add trandatascott.bonus  
   
2013-05-14 14:30:12  WARNING OGG-00869  No unique key is defined for table 'BONUS'.All viable columns will be used to represent the key, but may not guaranteeuniqueness.  KEYCOLS may be used todefine the key.  
   
Logging of supplemental redo dataenabled for table SCOTT.BONUS.  
   
GGSCI (irms156) 15> add trandatascott.dept  
   
Logging of supplemental redo dataenabled for table SCOTT.DEPT.  
   
GGSCI(irms156) 16> info trandata scott.emp   
   
Logging ofsupplemental redo log data is enabled for table SCOTT.EMP.  
   
Columnssupplementally logged for table SCOTT.EMP: EMPNO.  
 
3、数据准备
(1)在目标端创建与源端一样的表
 
(2)把源端的初始数据导入至目标端
 
由于本实验采用scott模式,在每个oracle数据库均已默认安装,因此不再需要准备。第2步可使用datapump,goldengatedirect load, sql*loader等方法。
 
4、配置源端提取
(1)增加抽取组
 
[sql] 
GGSCI (irms156) 1> add extracteoragd, tranlog, begin now, threads 1  
EXTRACT added.  
   
GGSCI (irms156) 2> info extracteoragd  
   
EXTRACT    EORAGD   Initialized   2013-05-1414:58   Status STOPPED  
Checkpoint Lag       00:00:00 (updated 00:00:13 ago)  
Log Read Checkpoint  Oracle Redo Logs  
                     2013-05-14 14:58:05  Thread 1, Seqno 0, RBA 0  
                     SCN 0.0 (0)  
Log Read Checkpoint  Oracle Redo Logs  
                     2013-05-14 14:58:05  Thread 2, Seqno 0, RBA 0  
                     SCN 0.0 (0)  
 
(2)创建抽取进程参数文件
 
[sql] 
GGSCI (irms156) 3> edit params eoragd  
   
EXTRACT EORAGD  
USERID system, PASSWORD Lu123456  
RMTHOST 10.252.48.155, MGRPORT 7809  
RMTTRAIL ./dirdat/gd  
TABLE scott.emp;  
TABLE scott.dept;  
TABLE scott.salgrade;  
TABLE scott.bonus;  
(3)Define the GoldenGate trail  
add thetrail that will store the changes on the target.  
GGSCI (irms156) 8> add RMTTRAIL./dirdat/gd, EXTRACT EORAGD  
RMTTRAIL added.  
GGSCI(irms156) 9> info rmttrail *  
   
       Extract Trail: ./dir/gd  
             Extract: EORAGD  
              &
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,