源端:
1、安装ogg工具
2、安装目录下   
3、    GGSCI 1>create subdirs                --- 创建子目录
4、    GGSCI 2>edit params ./GLOBALS          --- 手动指定服务名GGMGR
MGRSERVNAME GGMGR
5、    GGSCI 3>install addservice            --- 添加服务
6、配置oracle数据库
----在源端打开归档模式
SQL> archive log list
SQL> shutdown immediate
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open
----在源端库中打开force logging
SQL> select force_logging from v$database;
FOR
---
NO
SQL> alter database force logging;
Database altered.
SQL> select force_logging from v$database;
FOR
---
YES
----在源端库中打开supplemental log
SQL> select supplemental_log_data_min from v$database;
SUPPLEME
--------
NO
SQL> alter database add supplemental log data;
Database altered.
SQL> alter system switch logfile;      ----切换日志,使更改生效
System altered.
SQL> select supplemental_log_data_min from v$database;
SUPPLEME
--------
YES
----在源端库中关闭回收站
SQL> show parameter recyclebin
NAME          TYPE      VALUE
--------    ----------- ------------------------------
recyclebin    string      on
SQL> alter system set recyclebin=off deferred; 非立即生效
System altered.
注:如果是oracle 10.1版本使用alter system set “_recyclebin=off”;命令
----在源端创建ggs用户
SQL> create user ggs identified by ggs default tablespace users temporary tablespace temp;
grant connect ,resource,unlimited tablespace to ggs;
grant execute on utl_file to ggs;
grant select any dictionary,select any table to ggs;
grant alter any table to ggs;
grant flashback any table to ggs;
grant execute on dbms_flashback to ggs;
grant select any transaction to ggs;
-
---在源端创建测试表
SQL> create table demo(id number primary key,ename varchar2(10));
----在源端添加表级的trandata
GGSCI  4> dblogin userid ggs,password ggs
Successfully logged into database.
GGSCI  5>add trandata scott.demo
Logging of supplemental redo data enabled for table SCOTT.DEMO.
注:表名可以使用通配符,如add trandata scott.*
----在目标端创建测试表
SQL> create table demo(id number primary key,ename varchar2(10));
----在目标端创建ggs用户
SQL> create user ggs identified by ggs default tablespace users temporary tablespace temp;
SQL> grant dba to ggs;
----在目标端添加checkpoint表
GGSCI  6> edit params ./GLOBALS  ----在目标机器上编辑GLO
BALS文件,添加一行,checkpointtable ggs.checkpoint
MGRSERVNAME GGMGR
checkpointtable ggs.checkpoint
GGSCI  7>dblogin userid ggs,password ggs
Successfully logged into database.
GGSCI  8>add checkpointtable ggs.checkpoint
Successfully created checkpoint table GGS.CHECKPOINT.
7、配置goldengate进程组
一般常用的进程组:
在源端:mgr进程,extract(抽取)进程,pump进程
在目标端:mgr进程,replicat(复制)
拓扑图:Configuration elements for replication to one target
8、配置源端MGR管理进程
GGSCI  9> set editor emacs                      ----设置编辑器(可能忽略)
GGSCI  10>edit params mgr                      ----配置参数文件   
--添加以下内容保存退出
port 7500
dynamicportlist 7501-7505
autorestart extract *,waitminutes 2,retries 5
GGSCI  11> start mgr
Starting Manager as service ('GGMGR')...
Service started.
GGSCI  12>view params mgr
port 7500
linux安装oracle 11g
dynamicportlist 7501-7505
autorestart extract *,waitminutes 2,retries 5
9、配置源端Extract抽取进行组
----编辑添加extract进程配置文件
GGSCI  13>edit params eora
GGSCI  14>view params eora
extract eora
dynamicresolution
userid ggs,password ggs
--setenv(ORACLE_SID=ORCL)
exttrail F:\app\product\11.2.0\OraHome_1\dirdat\et
table scott.*;
----添加extract进程
GGSCI  15> add extract eora,tranlog,begin now
EXTRACT added.
----创建本地trail文件,extract进程组负责写这部分文件,pump进程负责读它:
GGSCI  16>add exttrail D:\app\administrator\product\11.2.0\OraHome_1\dirdat\et,extract eora
EXTTRAIL added.
----启动extract进程,使用start eora或start ext eora或start extract eora
GGSCI 17> start eora
10、配置源端pump进程组
----编辑添加pump进程配置文件
GGSCI  18>edit params pump_so
GGSCI  19>view params pump_so
extract Pump_so
Dynamicresolution
Userid ggs,password ggs
rmthost 10.1.5.107, mgrport 7500
--Setenv(ORACLE_SID=ORCL)
rmttrail D:\app\administrator\product\11.2.0\OraHome_1\dirdat\et
Table scott.*;
add extract pump_so,tranlog,begin now
--添加pump进程
GGSCI  20>add extract pump_so,exttrailsource D:\app\Administrator\product\11.2.0\OraHome_1\dirdat\et
EXTTRAIL added.
--添加该rmttrail
GGSCI  21>add rmttrail D:\app\Administrator\product\11.2.0\OraHome_1\dirdat\et,extract pump_so
RMTTRAIL added.
--启动pump进程
GGS
CI  22>start pump_so
Sending START request to MANAGER ('GGMGR') ...
EXTRACT PUMP_SO starting
GGSCI  23>info all
Program    Status      Group      Lag          Time Since Chkpt
MANAGER    RUNNING
EXTRACT    RUNNING    EORA        00:00:00      00:00:06
EXTRACT    RUNNING    PUMP_SO    00:00:00      00:00:07
注意:如果目标端的mgr进程没有启动,此时启动pump进程ggserr.log日志会报如下错误,pump进程也就无法启动。
pture for Oracle, PUMP_SO.prm:  EXTRACT PUMP_SO starting.
2012-04-20 11:21:41  INFO    OGG-00993  Oracle GoldenGate Capture for Oracle, PUMP_SO.prm: 
EXTRACT PUMP_SO started.
2012-04-20 11:21:42  WARNING OGG-01223  Oracle GoldenGate Capture for Oracle, PUMP_SO.prm: 
TCP/IP error 10061 (由于目标计算机积极拒绝,无法连接。).
2012-04-20 11:21:53  WARNING OGG-01223  Oracle GoldenGate Capture for Oracle, PUMP_SO.prm: 
TCP/IP error 10061 (由于目标计算机积极拒绝,无法连接。).
11、配置目标端MGR管理进程
----依据源端的配置,配置目标端mgr进程
GGSCI  24> edit params mgr
GGSCI  25>view params mgr
port 7500
dynamicportlist 7501-7505
autostart er *
autorestart extract *,waitminutes 2,retries 5
lagreporthours 1
laginfominutes 3
lagcriticalminutes 5
purgeoldextracts F:\app\administrator\product\11.2.0\OraHome_1\dirdat\et*,usecheckpoints,minkeepdays 3
12、配置目标端Replicat复制进程组
----编辑添加Replicat进程配置文件
GGSCI  26> view params repl
replicat repl
userid ggs,password ggs
assumetargetdefs
reperror default,discard
discardfile ./dirrpt/repl.dsc,append,megabytes 50
dynamicresolution
MAP scott.*, target scott.*;
----添加replicat进程
GGSCI  27>add replicat repl,exttrail D:\app\administrator\product\11.2.0\OraHome_1\dirdat\et,checkpointtable ggs.checkpoint
REPLICAT added.
GGSCI  28>start repl
Sending START request to MANAGER ...
REPLICAT REPL starting
GGSCI  29> info repl
REPLICAT  REPL      Last Started 2012-04-20 13:24  Status ABENDED
Checkpoint Lag      00:00:00 (updated 00:00:29 ago)
Log Read Checkpoint  File F:\app\product\11.2.0\OraHome_1\dirdat\et000000
First Record  RBA 0
二、配置另一组分发目标进程    --Redhad Linux 4.7 32bit
1、配置源端MGR管理进程
----上面的步骤源端已经配置完成,不需要再配置了。
2、
配置源端Extract抽取进行组
----编辑添加extract进程配置文件
GGSCI  1>edit params eora2
GGSCI  2>view params eora2
extract eora
dynamicresolution
userid ggs,password ggs
--setenv(ORACLE_SID=ORCL)
exttrail c:\gg\dirdat\et
table scott.*;
-
---添加extract进程
GGSCI  4> add extract eora2,tranlog,begin now
EXTRACT added.
----创建本地trail文件,extract进程组负责写这部分文件,pump进程负责读它:
GGSCI  5>add exttrail c:\gg\dirdat\et,extract eora2
EXTTRAIL added.
----启动extract进程,使用start eora或start ext eora或start extract eora
GGSCI  6> start eora
3、配置源端pump进程组
----编辑添加pump进程配置文件
GGSCI  7>edit params pump_so2
GGSCI  8>view params pump_so2
extract Pump_so
Dynamicresolution
Userid ggs,password ggs
rmthost 192.168.1.100, mgrport 7500 –修改ip或hostname
rmttrail /opt/gg/trails/et
Table scott.*;
----添加pump进程
GGSCI  9>add extract pump_so2,exttrailsource c:\gg\dirdat\et
EXTTRAIL added.
----添加该rmttrail
GGSCI  10>add rmttrail /opt/gg/trails/et,extract pump_so2
RMTTRAIL added.
----启动pump进程
GGSCI  11>start pump_so
Sending START request to MANAGER ('GGMGR') ...
EXTRACT PUMP_SO starting
GGSCI  12>info all
Program    Status      Group      Lag          Time Since Chkpt
MANAGER    RUNNING
EXTRACT    RUNNING    EORA        00:00:00      00:00:04
EXTRACT    RUNNING    EORA2      00:00:00      00:00:04
EXTRACT    RUNNING    PUMP_SO    00:00:00      00:00:09
EXTRACT    RUNNING    PUMP_SO2    00:00:00      00:00:09
4、配置目标端MGR管理进程
----依据源端的配置,配置目标端mgr进程
GGSCI  13> edit params mgr
GGSCI  14>view params mgr
DYNAMICPORTLIST 7840-7914
PORT 7500--注意端口和源mgr一致
PURGEOLDEXTRACTS /opt/gg/trails/w1*, USECHECKPOINTS, MINKEEPFILES 10
PURGEOLDEXTRACTS /opt/gg/trails/w2*, USECHECKPOINTS, MINKEEPFILES 10
PURGEOLDEXTRACTS /opt/gg/trails/et*, USECHECKPOINTS, MINKEEPFILES 10
AUTORESTART ER *, RETRIES 3, WAITMINUTES 5
PURGEDDLHISTORY MINKEEPDAYS 3, MAXKEEPDAYS 5, FREQUENCYMINUTES 30
PURGEMARKERHISTORY MINKEEPDAYS 3, MAXKEEPDAYS 5, FREQUENCYMINUTES 30
5、配置目标端Replicat复制进程组
----编辑添加Replicat进程配置文件
GGSCI  15 edit params repl
GGSCI  16>view params repl
REPLICAT repl
ASSUMETARGETDEFS
USERID GOLDENGATE, PASSWORD GOLDENGATE
DISCARDFILE w1repdsc,APPEND,MEGABYTES 5
DDL INCLUDE MAPPED
DDLOPTIONS REPORT
BATCHSQL
DBOPTIONS DEFERREFCONST
DBOPTIONS LOBWRITESIZE 102400
DDLERROR DEFAULT DISCARD RETRYOP MAXRETRIES 5 RETRYDELAY 20
MAP scott.* , TARGET scott.* ;
----添加replicat进程
GGSCI  17>add replicat repl,exttrail /opt/gg/trails/et
REPLICAT added.
GGSCI  18>start repl
Sending START request to MANAGER ...
REPLICAT REPL starting
GGSCI  19> info repl
初始化目标数据
1.如果自源端表创建以来没有,抽取进程没有一直停止,可以在目标端取数据时只导入空表即可;
在复制进程开始后,源端的所有DML操作会自动应用到目标端。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。