码迷,mamicode.com
首页 > 其他好文 > 详细

ogg 配置复习(dml>ddl>sequnce)

时间:2015-03-17 18:00:22      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:

<strong><span style="color:#ff6666;">dml 配置过程与测试概要</span></strong>

在源端创建专用的表空间、schema、并授权。
create tablespace goldengate datafile 'goldengate01.dbf' size 100m autoextend on;
create user goldengate identified by goldengate default tablespace goldengate temporary tablespace temp;
grant connect to goldengate;
grant alter any table to goldengate;
grant alter session to goldengate;
grant create session to goldengate;
grant flashback any table to goldengate;
grant select any dictionary to goldengate;
grant select any table to goldengate;
grant resource to goldengate;
grant select any transaction to goldengate;

检查源端数据库是否在归档模式,强烈建议在归档模式。
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /arch
Oldest online log sequence     1
Next log sequence to archive   3
Current log sequence           3

端:
添加附加日志来唯一标识一行记录,要在数据库级别打开最小开关。为了减少整个数据库添加附加日志,以及减少归档量,
goldengate建议复制哪些对象,就添加哪些表的附加日志(我们到时候是拿hr用户下的表来实验)。
检查:
SQL> select supplemental_log_data_min from v$database;
SUPPLEME
--------
NO
打开:
SQL> alter database add supplemental log data;
Database altered.
再次查看:
SQL> <span style="color:#ff6666;">select supplemental_log_data_min from v$database;</span>
SUPPLEME
--------
YES
切换日志组,使附加日志开关生效。
SQL> alter system switch logfile;
System altered.
解释:在正常情况下,oracle是用rowid来唯一标示一行记录的,但goldengate这里不够,需要打开附加日志。

安装与配置
GGSCI (gg2) 2><span style="color:#ff6666;"> create subdirs</span>
GGSCI (oratest) 80> view params mgr
port 7839 
DYNAMICPORTLIST 7840-7850
AUTOSTART EXTRACT *
AUTORESTART EXTRACT *
PURGEOLDEXTRACTS ./dirdat/*,usecheckpoints, minkeepdays 7
LAGREPORTHOURS 1
LAGINFOMINUTES 30
LAGCRITICALMINUTES 45

启动配置的管理进程
GGSCI (gg2) 4> start mgr
Manager started.

select owner||'.'||table_name table_name,logging                
from dba_tables
where owner='SENDER';

SQL> alter table SENDER.A1 logging;

源端:
配置hr下面表的表级附加日志。配置登陆用户。并检查日志是否添加成功。
以goldengate这个schema登陆数据库。
GGSCI (gg1) 10><span style="color:#ff6666;"> dblogin userid goldengate, password goldengate</span>
Successfully logged into database.

查看:
GGSCI (gg1) 11> info trandata hr.*
add extract ext_demo, tranlog, begin now, threads 1

参数分析:
tranlog:表示数据抓取的来源是数据库的redo数据。
begin now:表示我们在启动这个抓取进程的就去抓取数据。
threads 1:表示我们数据库有多少个redo threads,单实例基本上是1或者不设,rac就自己设置了,配置过RAC的基本都了解

添加源端的队列文件。
GGSCI (gg1) 15> <span style="color:#3333ff;">add extract ext_demo,<span style="background-color: rgb(102, 102, 204);">tranlog</span>, begin now, threads 1</span>
GGSCI (gg1) 15> <span style="color:#ff0000;">add EXTTRAIL ./dirdat/r1, extract ext_demo,megabytes 100</span>
EXTTRAIL added

./dirdat:表示trail文件的目录
r1:trail文件的前缀
extract ext_demo:值指定给那个进程用的(ext_demo)。
megabytes 100:文件大小是100m

编辑我们刚刚在源端配置的抓取进程的参数:
GGSCI (gg1) 16><span style="color:#ff6666;"> edit param ext_demo</span>
EXTRACT EXT_DEMO
userid goldengate,password goldengate
REPORTCOUNT EVERY 1 MINUTES, RATE
numfiles 5000
DISCARDFILE ./dirrpt/ext_demo.dsc,APPEND,MEGABYTES 1000
DISCARDROLLOVER AT 3:00
exttrail ./dirdat/r1,megabytes 100
dynamicresolution
TRANLOGOPTIONS EXCLUDEUSER goldengate
TRANLOGOPTIONS convertucs2clobs  
TRANLOGOPTIONS DBLOGREADER
TABLE SENDER.*;

setenv (ORACLE_SID=ogg):指定oracle的sid,单机环境下可以不设或者bashprofile文件中设置了默认的,也可以不设,但是集群环境就要指定了,这里我们强烈建议指定。
setenv (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK):源端数据库的字符集,一定要跟数据库中匹配。
userid goldengate,password goldengate:告诉抓取进程是通过这个用户登陆数据库的。
exttrail ./dirdat/r1,megabytes 100:与我们上面配置抓取进程的设置要一致,路径和大小嘛。
TABLE HR.*:最重要的,告诉抓取进程抓取的是哪些用户哪些表的数据


配置datapump进程,将抓取数据传到目标主机。负责TCPIP通讯。
GGSCI (gg1) 31> <span style="color:#ff0000;">add extract dpe_demo, exttrailsource ./dirdat/r1</span>
EXTRACT added.

输出:目标主机怎么写,也是定义datapumo进程的输出。
GGSCI (gg1) 33><span style="color:#ff6666;"> add rmttrail ./dirdat/t1,EXTRACT dpe_demo,MEGABYTES 100</span>
RMTTRAIL added.

分析:
exttrailsource:抓取进程的来源,因为这个进程不否则到数据库中取抓取,所以抓取的来源
是通过抓取进程已经生成好的trail文件中的内容。

17、
配置datapump进程参数:
GGSCI (oratest) 83> <span style="color:#ff0000;">view params dpe_demo</span>
extract dpe_demo
dynamicresolution
passthru
rmthost 192.168.175.139, mgrport 7840, compress
rmttrail ./dirdat/t1
numfiles 5000
TABLE SENDER.*;

GGSCI (oratest) 84> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                           
EXTRACT     RUNNING     DPE_DEMO    00:00:00      00:00:00    
EXTRACT     RUNNING     EXT_DEMO    00:00:00      00:00:06    
GGSCI (oratest) 85> 

passthru:上面已经说过不需要连接数据库,所以用这个指令。
rmthost:目标主机的IP地址,就是说我们的rmttrail进程发送到的主机。
mgrport:目标主机管理进程的端口号,我们上面已经配置了。
compress:在传输的过程中启用压缩。
rmttrail:路径和文件与上面配置的一致。
TABLE SENDER.*:上面说过,哪些表的redo信息传输。

目标端:
创建golengate软件使用的schema,并授权一些必要的特殊权限,注意与源端有所区别,保证我们能DML。
create tablespace goldengate datafile 'goldengate01.dbf' size 100m autoextend on;
create user goldengate identified by goldengate default tablespace goldengate temporary tablespace temp;
grant connect to goldengate;
grant alter any table to goldengate;
grant alter session to goldengate;
grant create session to goldengate;
grant flashback any table to goldengate;
grant select any dictionary to goldengate;
grant select any table to goldengate;
grant resource to goldengate;
grant insert any table to goldengate;
grant update any table to goldengate;
grant delete any table to goldengate;
grant create any index to goldengate;
grant select any transaction to goldengate;

目标端:
为replicat进程创建checkpoint表:
GGSCI (gg2) 1> <span style="color:#ff0000;">dblogin userid goldengate,password goldengate</span>
Successfully logged into database.

GGSCI (gg2) 2> <span style="color:#ff0000;">add checkpointtable goldengate.rep_demo_ckpt</span>
Successfully created checkpoint table goldengate.rep_demo_ckpt.

21、
配置目标端replicate进程:
GGSCI (gg2) 3> <span style="color:#ff6666;">add replicat rep_demo,exttrail ./dirdat/t1,checkpointtable goldengate.rep_demo_ckpt</span>
REPLICAT added.

分析:
exttrail:表示这个进程获取数据的来源是什么地方,是我们源端rmttrail所设置过的。

22、
配置目标端replicate参数:
GGSCI (oratest) 13> <span style="color:#ff6666;">view params rep_demo</span>
REPLICAT rep_demo
USERID goldengate,PASSWORD goldengate
REPORTCOUNT EVERY 30 MINUTES, RATE
REPERROR DEFAULT, ABEND
numfiles 5000
--HANDLECOLLISIONS
assumetargetdefs
DISCARDFILE ./dirrpt/rep_demo.dsc, APPEND, MEGABYTES 1000
ALLOWNOOPUPDATES
MAP SENDER.*,TARGET SENDER.*;

分析:重要的地方与上面基本一致,有兴趣可以查查其他参数的信息。
MAP:源端和目标端的对应。

添加表格的时候 先在目标添加,再元端,数据库可以自动同步!

<strong><span style="color:#ff6666;">1.4 启用DDL</span></strong>
SQL>@marker_setup.sql    --提示输入目标schema
SQL>@ddl_setup.sql       --提示输入目标schema,输入initialsetup最后输入yes
SQL>@role_setup.sql
SQL>grant GGS_GGSUSER_ROLE to ddw; --不进行该步赋权后面起进程会报错
SQL>@ddl_enable.sql                --使触发器生效

1.5 清除DDL 同步设置
如果因为DDL 同步出现很多问题,最简单的方法就是卸载之后重建。安装目录下只提供了清除对象的脚本,可以如下操作:
首先要求把所有的GG进程停掉,包括mgr进程

SQL>@ddl_disable.sql  --首先使DDL触发器失效
SQL>@ddl_remove.sql
SQL>@marker_remove.sql

alter table OGG1.A1 logging;
info trandata OGG1.*
add extract ext2,tranlog, begin now, threads 1
add EXTTRAIL ./dirdat/r3, extract ext2,megabytes 100

EXTRACT ext2
userid goldengate,password goldengate
REPORTCOUNT EVERY 1 MINUTES, RATE
numfiles 5000
DISCARDFILE ./dirrpt/ext_demo1.dsc,APPEND,MEGABYTES 1000
DISCARDROLLOVER AT 3:00
exttrail ./dirdat/r2,megabytes 100
ddl include all
TABLE OGG1.*;

add extract dpe_ext2, exttrailsource ./dirdat/r3
add rmttrail ./dirdat/t3,EXTRACT dpe_ext2,MEGABYTES 100

extract dpe_ext2
dynamicresolution
passthru
rmthost 192.168.175.139, mgrport 7840, compress
rmttrail ./dirdat/t3
numfiles 5000
TABLE OGG1.*;

add replicat rep_ext2,exttrail ./dirdat/t3,checkpointtable goldengate.rep_demo_ckpt

REPLICAT rep_ext2
USERID goldengate,PASSWORD goldengate
REPORTCOUNT EVERY 30 MINUTES, RATE
REPERROR DEFAULT, ABEND
numfiles 5000
--HANDLECOLLISIONS
assumetargetdefs
DISCARDFILE ./dirrpt/rep_rep2.dsc, APPEND, MEGABYTES 1000
ALLOWNOOPUPDATES
MAP OGG1.*,TARGET OGG1.*;
<strong><span style="color:#ff6666;">启用序列:</span><span style="color:#ff6666;">目标端:</span></strong>
SQL> @sequence.sql
Please enter the name of a schema for the GoldenGate database objects:
goldengate
Setting schema name to GOLDENGATE
UPDATE_SEQUENCE STATUS:
Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors
GETSEQFLUSH
Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors
SEQTRACE
Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors
REPLICATE_SEQUENCE STATUS:
Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors
STATUS OF SEQUENCE SUPPORT
--------------------------------------------------------------
SUCCESSFUL installation of Oracle Sequence Replication support
SQL> GRANT EXECUTE on goldengate.replicateSequence to ogg1;
Grant succeeded.
SQL> 

目标端:
SQL> @sequence.sql
Please enter the name of a schema for the GoldenGate database objects:
goldengate
Setting schema name to GOLDENGATE
UPDATE_SEQUENCE STATUS:
Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors
GETSEQFLUSH
Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors
SEQTRACE
Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors
REPLICATE_SEQUENCE STATUS:
Line/pos   Error
---------- -----------------------------------------------------------------
No errors  No errors
STATUS OF SEQUENCE SUPPORT
--------------------------------------------------------------
SUCCESSFUL installation of Oracle Sequence Replication support
SQL> GRANT EXECUTE on goldengate.replicateSequence to ogg1;
Grant succeeded.
SQL> 

复制进程:

传输进程:
GGSCI (oratest) 41> edit params DPE_EXT2

extract dpe_ext2
dynamicresolution
passthru
rmthost 192.168.175.139, mgrport 7840, compress
rmttrail ./dirdat/t3
numfiles 5000
TABLE OGG1.*;
SEQUENCE OGG1.*;
~
"dirprm/dpe_ext2.prm" 8L, 158C written

GGSCI (oratest) 42> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     RUNNING     DPE_DEMO    00:00:00      00:00:00    
EXTRACT     RUNNING     DPE_EXT2    00:00:00      00:00:04    
EXTRACT     RUNNING     EXT1        00:00:00      00:00:09    
EXTRACT     RUNNING     EXT2        00:00:00      00:00:06    
EXTRACT     RUNNING     EXT_DEMO    00:00:00      00:00:09    

GGSCI (oratest) 43> stop DPE_EXT2

Sending STOP request to EXTRACT DPE_EXT2 ...
Request processed.

GGSCI (oratest) 44> start DPE_EXT2

Sending START request to MANAGER ...
EXTRACT DPE_EXT2 starting
GGSCI (oratest) 45> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                           
EXTRACT     RUNNING     DPE_DEMO    00:00:00      00:00:00    
EXTRACT     RUNNING     DPE_EXT2    00:00:00      00:00:05    
EXTRACT     RUNNING     EXT1        00:00:00      00:00:00    
EXTRACT     RUNNING     EXT2        00:00:00      00:00:03    
EXTRACT     RUNNING     EXT_DEMO    00:00:00      00:00:09    

GGSCI (oratest) 46> 

抽取进程:
GGSCI (oratest) 48> edit params EXT2

EXTRACT ext2
userid goldengate,password goldengate
REPORTCOUNT EVERY 1 MINUTES, RATE
numfiles 5000
DISCARDFILE ./dirrpt/ext2.dsc,APPEND,MEGABYTES 1000
DISCARDROLLOVER AT 3:00
exttrail ./dirdat/r3,megabytes 100
ddl include all
TRANLOGOPTIONS DBLOGREADER
TABLE OGG1.*;
SEQUENCE OGG1.*;
~
"dirprm/ext2.prm" 11L, 284C written

GGSCI (oratest) 49> stop ext2

Sending STOP request to EXTRACT EXT2 ...
Request processed.

GGSCI (oratest) 50> start ext2

Sending START request to MANAGER ...
EXTRACT EXT2 starting

GGSCI (oratest) 51> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                           
EXTRACT     RUNNING     DPE_DEMO    00:00:00      00:00:07    
EXTRACT     RUNNING     DPE_EXT2    00:00:00      00:00:02    
EXTRACT     RUNNING     EXT1        00:00:00      00:00:06    
EXTRACT     RUNNING     EXT2        00:00:03      00:00:07    
EXTRACT     RUNNING     EXT_DEMO    00:00:00      00:00:05    

GGSCI (oratest) 52> 

提前修改该文件:
修改文件:
GGSCI (oratest) 79> EDIT PARAMS ./GLOBALS
GGSCHEMA goldengate
~
FLUSH SEQUENCE ogg1.*
<strong><span style="color:#ff0000;">重启更加有效果!</span></strong>


ogg 配置复习(dml>ddl>sequnce)

标签:

原文地址:http://blog.csdn.net/itdba/article/details/44344271

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!