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

GOLDENGATE安装配置与复制流搭建_DG端抽取支持DDL版

时间:2015-02-09 21:43:28      阅读:299      评论:0      收藏:0      [点我收藏+]

标签:goldengate安装配置与复制流搭建   ogg抽取ddl配置   ogg ddl   

GOLDENGATE安装配置与复制流搭建_DG端抽取支持DDL版

1、配置场景

 技术分享   

    OGG版本11.2.1.0.1

2、OGG软件安装

2.1 源端和目标端创建OGG安装目录与授权

#mkdir /u01/ogg

#chown –R oracle:oinstall /u01/ogg

#chmod –R 777 /u01/ogg

2.2 源端和目标端OS层参数调整与配置环境变量

(1)OS参数调整

#vi /etc/sysctl.conf

net.core.rmem_max=8388608

net.core.wmem_default=8388608

net.core.wmem_max=8388608

#sysctl -p

 

(2)设置环境变量

#su – oracle

[oracle@server1~]$ vi .bash_profile

添加以下内容:

export OGG=/u01/ogg

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/u01/ogg

[oracle@server1~]$ source .bash_profile

2.3 源端和目标端安装OGG软件

(1)   将ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip软件复制到/u01/ogg目录内

(2)   解压缩软件

[oracle@server1 ~]$unzip ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip

[oracle@server1 ~]$tar xvffbo_ggs_Linux_x64_ora11g_64bit.tar

2.4 源端和目标端数据库内创建OGG专用表空间及用户

SQL>create tablespace goldengate datafile ‘/dba/oracle/oradata/single/goldengate_01.dbf‘ size1G;

SQL>create user goldengate identified by goldengate default tablespace goldengate;

SQL>grant dba to goldengate;

2.5源端数据库创建测试表与插入测试数据

(如果是生产环境,此步可以跳过)

(1)   创建测试表TABLE GOLDENGATE.OGG_UPG

create table GOLDENGATE.OGG_UPG

(

pr_id       NUMBER(10)notnull,

t_name      VARCHAR2(20),

sal         NUMBER(10),

insert_time DATE primary key

)

tablespace GOLDENGATE

(2)   创建测试用的sequence

create sequence GOLDENGATE.SEQ_OGG_T01

minvalue 1

maxvalue 9999999999999999999999999999

start with1

increment by 1

cache 20;

(3)插入数据

declare

i number:=1;

begin

loop

insert into goldengate.OGG_UPG values(goldengate.seq_ogg_t01.nextval,‘ogg_test1‘,i,sysdate);

commit;

i:=i+1;

exit when i=10001;

end loop;

end;

/

3、源端数据库与表配置修改

3.1 开启数据库最小级别追加日志

SQL>alter database add supplemental log data;

SQL>altersystem switch logfile;

SQL>exit

3.2 开启需要同步表的表级追加日志

[oracle@server1~]$./ggsci

GGSCI>dbloginuserid goldengate, password goldengate

GGSCI>addtrandata goldengate.ogg_upg

4、配置goldengate支持DDL

如果是ORACLE 10g,需要关闭ORACLE数据库的recycle bin,11G以上不需要关闭

$cd$OGG

$sqlplus“/as sysdba”

SQL>@marker_setup.sql

SQL>@ddl_setup.sql

SQL>@role_setup.sql

SQL>grant ggs_ggsuser_role to goldengate

SQL>@ddl_enable.sql

SQL>@ddl_pin goldengate

4、OGG源端配置

4.1 创建subdirs

GGSCI>create subdirs

4.2 创建MGR

GGSCI>editparams mgr

Port 7809

dynamicportlist 7800-8000

--autorestart extract *,waitminutes 30,resetminutes 5

lagreporthours 1

laginfominutes 20

lagcriticalminutes 60

purgeoldextracts ./dirdat/tr*,usecheckpoints,minkeepdays 10

GGSCI>start mgr

4.3 创建extract进程

GGSCI>add extexttr, tranlog, begin now

GGSCI>addexttrail ./dirdat/tr, ext exttr, megabytes 200

GGSCI>editparams exttr

extract exttr

setenv (NLS_LANG = AMERICAN_AMERICA.AL32UTF8)

userid goldengate, password goldengate

REPORT AT 01:59

reportrollover at 02:00

TRANLOGOPTIONS CONVERTUCS2CLOBS

THREADOPTIONS MAXCOMMITPROPAGATIONDELAY 90000 IOLATENCY 100000

tranlogoptions dblogreader   --此条为支持从ASM中读取redo log

tranlogoptions altarchivelogdest primary instance orcl1 /u01/archive, altarchivelogdest instance orcl2 /u01/archive

discardfile ./dirrpt/exttr.dsc, append, megabytes 1000

gettruncates

--warnlongtrans 2h, checkintervals 3m

DDL INCLUDE OBJNAME "goldengate.*" EXCLUDE INSTRCOMMENTS ‘ggh_notsync‘

exttrail ./dirdat/tr

numfiles 2000

dynamicresolution

TABLEGOLDENGATE.OGG_UPG;

 

特别知识点说明:

EXCLUDE INSTRCOMMENTS ‘ggh_notsync‘说明:表示,语句带 “ggh_notsync”关键字的语句排除不抽取,如altertableb_rangedroppartition q1 /*ggh_notsync */;  由于该语句中带有ggh_notsync,所以排除不抽取。

   这种应用场景非常实用,如有一张分区表,源端只想保留两个分区,历史的数据分区在目标端都保留,那么,就可以在源端drop分区的语句上加上排除的标识,在源端删除分区的动作就不会同步到目标端了。

4.4 创建dataPump进程

GGSCI>add ext dpetr,exttrailsource ./dirdat/tr

GGSCI>add rmttrail ./dirdat/tr, ext dpetr, megabytes200

GGSCI>edit param dpetr

extract dpetr

setenv (NLS_LANG = AMERICAN_AMERICA.AL32UTF8)

userid goldengate, password goldengate

REPORT AT 01:59

reportrollover at 02:00

rmthost 192.168.1.220, mgrport 7809, compress

rmttrail ./dirdat/tr

dynamicresolution

numfiles 2000

gettruncates

TABLE GOLDENGATE.OGG_UPG;

GGSCI>start param dpetr

5、目标端OGG配置

5.1 创建subdirs

GGSCI>create subdirs

5.2 创建MGR

GGSCI> edit params mgr

Port 7809

dynamicportlist 7800-8000

autorestart replicat *,waitminutes 5,resetminutes 5

lagreporthours 1

laginfominutes 20

lagcriticalminutes 60

purgeoldextracts ./dirdat/tr*,usecheckpoints,minkeepdays 10

GGSCI>start mgr

5.3 创建replicat进程

GGSCI>dbloginuserid goldengate, password goldengate

GGSCI>addcheckpointtable goldengate.checkpoint_reptr_01

GGSCI>addreplicat reptr, exttrail ./dirdat/tr, checkpointtablegoldengate.checkpoint_reptr_01

GGSCI>edit params reptr

replicat reptr

setenv (NLS_LANG = AMERICAN_AMERICA.AL32UTF8)

userid goldengate, password goldengate

sqlexec "Alter session set constraints=deferred"

REPORT AT 01:59

reportrollover at 02:00

discardrollover on friday

--handlecollisions

reperror default,abend

discardfile ./dirrpt/reptr.dsc,append, megabytes 1000

assumetargetdefs

checksequencevalue

allownoopupdates

dynamicresolution

numfiles 2000

GETTRUNCATES

batchsql BATCHESPERQUEUE 100, OPSPERBATCH 8000

grouptransops 10000

maxtransops 10000

DDL INCLUDE ALL EXCLUDE INSTRCOMMENTS ‘ggh_notsync‘

ddlerror default ignore retryop maxretries 3 retrydelay 5

ddloptions report

MAP GOLDENGATE.OGG_UPG, TARGET GOLDENGATE.OGG_UPG;

创建完replicat进程后,千万不要启动

6、数据初始化

6.1 停用源端数据库的JOB

Sql>alter system set job_queue_processes=0 scope=both;

--先关闭job队列,防止后续的job再启动.

Sql>alter system set aq_tm_processes=0 scope=both;

--关闭高级队列

Sql>select count(*) from dba_jobs_running;

--查看系统是否存在有job正在执行,如果还有JOB在运行,则进行Kill操作

 

6.2停止前端系统应用

(防止有事务启动后,在取SCN时还未结束,由于GOLDENGATE抽取进程,只会抽取在extract进程启动之后开始的事务,该点很重要。)

6.3杀掉所有事务

(1)查询还在执行的事务

   select * from gv$transaction;

(2)kill 当前正在执行的事务的session

6.4停掉listener

 $lsnrctl stop

(防止新的连接连上来创建新事务操作表数据)

6.5查询源端数据库的当前SCN号

SQL>select dbms_flashback.get_system_change_number from dual;

记录下SCN号:2553440

6.6导出数据

$expdpsystem/XXX directory=expdp_dir dumpfile=tableXXX.dmp filesize=30Glogfile=expdp_XXXX.log flashback_scn=2553440 tables=GOLDENGATE.OGG_UPG

6.7恢复源端数据库的JOB参数

Sql>alter system set job_queue_processes=20 scope=both;

--根据实际值进行恢复.

Sql>alter system set aq_tm_processes=1 scope=both;

6.8目标端数据库导入数据

$imppdp system/XXX directory=expdp_dir dumpfile=tableXXX.dmp logfile=impdp_XXXX.log

7、启动目标端的replicat进程

GGSCI>startreptr,aftercsn 2553440

8、验证OGG能正常同步数据

8.1 在目标数据库中查询GOLDENGATE.OGG_UPG表数据量

SQL> select count(*) from goldengate.ogg_upg;

 

  COUNT(*)

----------

     10000

8.2 在源端数据库上的GOLDENGATE.OGG_UPG表中再插入一万行数据

declare

i number:=1;

begin

loop

insert into goldengate.OGG_UPGvalues(goldengate.seq_ogg_t01.nextval,‘ogg_test1‘,i,sysdate);

commit;

i:=i+1;

exit when i=10001;

end loop;

end;

/

8.2 在目标数据库上查GOLDENGATE.OGG_UPG表数据是否增长

SQL> select count(*)  from goldengate.ogg_upg;

 

  COUNT(*)

----------

     20000

配置成功,并可以正常同步。

 

 

本文作者:黎俊杰(网名:踩点),从事”系统架构、操作系统、存储设备、数据库、中间件、应用程序“六个层面系统性的性能优化工作

欢迎加入 系统性能优化专业群,共同探讨性能优化技术。群号:258187244

 

GOLDENGATE安装配置与复制流搭建_DG端抽取支持DDL版

标签:goldengate安装配置与复制流搭建   ogg抽取ddl配置   ogg ddl   

原文地址:http://blog.csdn.net/ljunjie82/article/details/43675829

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