到官网
https://edelivery.oracle.com/注册账号下载最新的软件。
安装平台:redhat linux x86 32bit
goldengate:Oracle_GoldenGate_V11.1.1.1.0_for_Oracle_10g_on_Linux_x86.zip
oracle版本:10.2.0.1
(建议使用
oracle用户安装goldengate)
解压软件
$unzip Oracle_GoldenGate_V11.1.1.1.0_for_Oracle_10g_on_Linux_x86.zip
$mkdir ogg
$mv fbo_ggs_Linux_x64_ora10g_32bit.tar ogg/
$tar zxf fbo_ggs_Linux_x64_ora10g_32bit.tar -C /oracle/goldengate
设置环境变量
$vim .bash_profile
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export GGATE=/oracle/goldengate
$source .bash_profile
GoldenGate是基于
oracle日志变化的捕获,所以为了完整的捕获到oracle数据库的变化,有必要将归档模式开启。
SQL>alter system set log_archive_dest_1='location=/u01/oracle/oradata/orcl/arch' scope=both;
SQL>shutdown immediate
SQL>startup mount
SQL>alter database archivelog
SQL>alter database open
SQL>archive log list
我们知道,在
oracle中我们可以通过rowid来定位某条记录,但是目标端的数据库和源端数据库的数据库可能完全不一样,所以无法通过rowid来确定源端数据库的逻辑变化,这时附件日志supplemental log便登上了表演的舞台。数据库在开启附加日志功能后,对于源端的修改操作,oracle会同时追加能够唯一标示记录的列到redo log。这样目标端数据库就可以知道源端发生了哪些具体的变化。
SQL>alter database add supplemental log data;
SQL>select supplemental_log_data_min from v$database;
SQL>alter database force logging;
SQL>alter system set recyclebin=off scope=both;
SQL>@marker_setup //用户名为
ogg
SQL>@ddl_setup //用户名为
ogg
SQL>@role_setup //用户名为
ogg
SQL>grant GGS_GGSUSER_ROLE to ogg;
SQL>@ddl_enable
SQL>create tablespace tbs_gguser datafile '/u01/app/oracle/oradata/orcl/gguser.dbf' size 1000M autoextend on;
SQL>create user ogg identified by ufsoft default tablespace tbs_gguser temporary tablespace TEMP quota unlimited on tbs_gguser;
SQL>grant connect,resource to ogg;
SQL>grant create session,alter session to ogg;
SQL>grant select any dictionary,select any table to ogg;
SQL> grant alter any table to ogg;
SQL> grant flashback any table to ogg;
SQL>grant execute on dbms_flashback to ogg;
SQL>alter log_archive_dest_1='location=/u01/oracle/oradata/orcl/arch' scope=both;
SQL>shutdown immediate
SQL>startup mount
SQL>alter database archivelog
SQL>alter database open
SQL>archive log list
SQL>alter database add supplemental log data;
SQL>select supplemental_log_data_min from v$database;
SQL>alter database force logging;
SQL>alter system set recyclebin=off scope=both;
SQL>@marker_setup //用户名为
ogg
SQL>@ddl_setup //用户名为
ogg
SQL>@role_setup //用户名为
ogg
SQL>grant GGS_GGSUSER_ROLE to ogg;
SQL>@ddl_enable
SQL>create tablespace tbs_gguser datafile '/u01/app/oracle/oradata/orcl/gguser.dbf' size 1000M autoextend on;
SQL>create user ogg identified by ufsoft default tablespace tbs_gguser temporary tablespace TEMP quota unlimited on tbs_gguser;
SQL>grant connect,resource to ogg;
SQL>grant create session,alter session to ogg;
SQL>grant select any dictionary,select any table to ogg;
SQL> grant alter any table to ogg;
SQL> grant flashback any table to ogg;
SQL>grant execute on dbms_flashback to ogg;
SQL>grant insert any table to ogg;
SQL>grant delete any table to ogg;
SQL>grant update any table to ogg;
4. 配置源端GoldenGate
1) 安装goldengate
$cd /oracle/goldengate
$./ggsci
> CREATE SUBDIRS
//创建
goldengate安装目录
> exit
至此,
goldengate已安装完成。
./ggsci
>dblogin userid ogg,password ufsoft
>edit params mgr
//编辑管理进程
PORT 7809
>start mgr
>edit params GLOBALS
GGSCHEMA ogg
>add extract eini_1,tranlog,begin now
>add rmttrail /oracle/goldengate/dirdat/ma,megabytes 100,extract eini_1
>edit params eini_1
//编辑抽取进程
EXTRACT EINI_1
dynamicresolution
SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
USERID ogg PASSWORD ufsoft
RMTHOST 192.168.0.4,MGRPORT 7809
//目标数据库地址和端口
TRANLOGOPTIONS EXCLUDEUSER ogg
RMTTRAIL /oracle/goldengate/dirdat/ma //目标端数据库的
trail文件位置
DDL INCLUDE ALL
table scott.*;
//以
scott用户下的表做测试
5. 配置目标端GoldenGate
1) 安装goldengate
$cd /oracle/goldengate
$./ggsci
> CREATE SUBDIRS
> exit
$cd /oracle/goldengate
$./ggsci
> CREATE SUBDIRS
> exit
./ggsci
>dblogin userid ogg,password ufsoft
>edit params mgr
PORT 7809
PURGEOLDEXTRACTS /dirdat,USECHECKPOINTS
>start mgr
>edit params GLOBALS
GGSCHEMA ogg
>add checkpointtable ogg.checkpoint
>add replicat rini_1,exttrail /oracle/goldengate/dirdat/ma,begin now,checkpointtable ogg.checkpoint
>edit params rini_1 //编辑复制进程
REPLICAT RINI_1
SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
ASSUMETARGETDEFS
USERID ogg PASSWORD ufsoft
DISCARDFILE /oracle/goldengate/dirrpt/RINIaa.dsc,PURGE
DDL INCLUDE ALL
DDLERROR DEFAULT IGNORE RETRYOP MAXRETRIES 3 RETRYDELAY 5
DDLERROR DEFAULT DISCARD
DDLERROR DEFAULT IGNORE RETRYOP
MAP scott.* , TARGET scott.*;
>start replicat rini_1
本文转自 baiying 51CTO博客,原文链接:http://blog.51cto.com/baiying/646451,如需转载请自行联系原作者