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

GOLDENGATE安装与数据复制流搭建配置_不含DDL抽取版

时间:2015-01-26 00:10:42      阅读:388      评论:0      收藏:0      [点我收藏+]

标签:ogg配置   ogg搭建   ogg安装配置   goldengate搭建配置   

GOLDENGATE安装与数据复制流搭建配置

(源库为实例,支持ASM,不含DDL抽取版)

1、配置场景

技术分享

2、OGG软件安装

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

#mkdir /u01/ogg

#chown –R oracle:oinstall/u01/ogg

#chmod –R 777/u01/ogg

 

2.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 xvf fbo_ggs_Linux_x64_ora11g_64bit.tar

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

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

(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

minvalue1

maxvalue9999999999999999999999999999

startwith1

incrementby1

cache 20;

(3)插入数据

declare

i number:=1;

begin

loop

inser tinto goldengate.OGG_UPGvalues (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、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 ext exttr,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

tranlogoptions altarchivelogdest primary instance orcl /u01/archive

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

gettruncates

--warnlongtrans 2h, checkintervals 3m

exttrail ./dirdat/tr

numfiles 2000

dynamicresolution

TABLEGOLDENGATE.OGG_UPG;

4.4 创建dataPump进程

GGSCI>add extdpetr, exttrailsource ./dirdat/tr

GGSCI>add rmttrail ./dirdat/tr, extdpetr, megabytes 200

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>dblogin userid goldengate, password goldengate

GGSCI>add checkpointtable goldengate.checkpoint_reptr_01

GGSCI>add replicat 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

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> selectdbms_flashback.get_system_change_number from dual;

记录下SCN号:2553440

6.6 导出数据

$expdpsystem/XXX directory=expdp_dir dumpfile=tableXXX.dmp filesize=30G logfile=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

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

commit;

i:=i+1;

exitwhen i=10001;

end loop;

end;

/

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

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

 

  COUNT(*)

----------

     20000

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

 

 

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

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

GOLDENGATE安装与数据复制流搭建配置_不含DDL抽取版

标签:ogg配置   ogg搭建   ogg安装配置   goldengate搭建配置   

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

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