GoldenGate简单复制环境的搭建

今天试了下搭建GoldenGate,搭建的过程也简单总结了一下。
 目前源数据库是newtest2  目标数据库是dataguru 都是11.2.0.4.0版本
 关于GoldenGate的下载可以到下面的链接下载
Oracle.com/technetwork/middleware/goldengate/downloads/index.html 在11g中,存在一个和GoldenGate有关的参数,默认是false,我们需要在源库,目标库都开启

SQL> show parameter golde
 NAME                                TYPE                  VALUE
 ------------------------------------ ---------------------- ------------------------------
 enable_goldengate_replication        boolean                FALSE

SQL> alter system set enable_goldengate_replication=true;
 alter database

然后查看supplemental log的情况,这个也是需要的设置。
SQL> select SUPPLEMENTAL_LOG_DATA_min from v$database;
 SUPPLEMENTAL_LOG
 ----------------
 YES


alter database add supplemental log data; 做完之后,切换日志使得附加日志生效。

SQL> alter system archive log current;
 System altered.当然我们希望在源端和目标端的数据库都配置一个数据库用户。OGG是宣称不需要触发器,中间表,增量标记和时间戳字段的。

源端的配置数据库用户的脚本如下:

create user ogg_source identified by oracle default tablespace users;
 grant alter session to ogg_source;
 grant create session to ogg_source;
 grant connect to ogg_source;
 grant resource to ogg_source;
 grant select any dictionary to ogg_source;
 grant select any table to ogg_source;
 grant flashback any table to ogg_source;
 grant alter any table to ogg_source;

目标端配置数据库用户的脚本如下:

create user ogg_target identified by oracle default tablespace users;
 grant alter session to ogg_target;
 grant create session to ogg_target;
 grant connect to ogg_target;
 grant resource to ogg_target;
 grant select any dictionary to ogg_target;
 grant select any table to ogg_target;
 grant flashback any table to ogg_target;
 grant alter any table to ogg_target;
 grant insert any table to ogg_target;
 grant update any table to ogg_target;
 grant delete any table to ogg_target;

添加一个表日志:

> EDIT PARAMS ./GLOBALS
GGSCHEMA ogg_source
 CHECKPOINTTABLE ogg_source.CHKPTAB

在源端使用数据库用户登录

1> dblogin userid ogg_source,password oracle
 Successfully logged into database. 为所有要复制的表添加trandata,目前我需要复制的是newtest2这个数据库下的n1用户

2> add trandata n1.*;
 ERROR: No viable tables matched specification.

这个时候就会明显感觉到OGG的格式不大喜欢结尾符,得去掉结尾符才可以。

3> add trandata n1.* 2016-11-11 14:13:05  WARNING OGG-06439  No unique key is defined for table A. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key.
 Logging of supplemental redo data enabled for table N1.A.
 TRANDATA for scheduling columns has been added on table 'N1.A'. 不过抛出来下面的错误,是权限不够,还需要附一个权限。

2016-11-11 14:13:05  WARNING OGG-00706  Failed to add supplemental log group on table N1.A due to ORA-06550: line 1, column 7:
 PLS-00201: identifier 'DBMS_CAPTURE_ADM' must be declared
 ORA-06550: line 1, column 7: PL/SQL: Statement ignored SQL BEGIN DBMS_CAPTURE_ADM.PREPARE_TABLE_INSTANTIATION(table_name => '"N1"."A"', supplemental_logging => 'none'); END; 解决方法:

SQL>  grant execute on sys.DBMS_CAPTURE_ADM to ogg_source;
 Grant succeeded. 再次运行就没有问题了。
 然后连接到数据库,开始配置抽取进程

14>  dblogin userid ogg_source,password oracle
 Successfully logged into database.

配置参数,使用本地的方式。

15> edit params ext_1
 EXTRACT EXT_1
 USERID ogg_source, PASSWORD oracle
 EXTTRAIL /home/oracle/ogg/ogg_work/dirdat/ss
 TABLE N1.*;添加抽取进程,从数据库日志中抓取数据。

>  ADD EXTRACT EXT_1, TRANLOG, BEGIN NOW
 EXTRACT added.

配置本地队列,然后启动

> ADD EXTTRAIL /home/oracle/ogg/ogg_work/dirdat/ss, EXTRACT EXT_1

> start EXT_1
 Sending START request to MANAGER ...
 EXTRACT EXT_1 starting

配置完成之后,就可以查看是否能够正常抽取了,可以看到是没有正常启动。状态现在还是STOPPED

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/99272040ce9782da1b7c64657a5d742d.html