标签:goldengate安装配置与复制流搭建 ogg抽取ddl配置 ogg ddl
GOLDENGATE安装配置与复制流搭建_DG端抽取支持DDL版
OGG版本11.2.1.0.1
2、OGG软件安装
#mkdir /u01/ogg
#chown –R oracle:oinstall /u01/ogg
#chmod –R 777 /u01/ogg
(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
(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
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;
(如果是生产环境,此步可以跳过)
(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)插入数据
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; / |
SQL>alter database add supplemental log data;
SQL>altersystem switch logfile;
SQL>exit
[oracle@server1~]$./ggsci
GGSCI>dbloginuserid goldengate, password goldengate
GGSCI>addtrandata goldengate.ogg_upg
如果是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
GGSCI>create subdirs
GGSCI>editparams mgr
dynamicportlist 7800-8000 --autorestart extract *,waitminutes 30,resetminutes 5 lagreporthours 1 laginfominutes 20 lagcriticalminutes 60 purgeoldextracts ./dirdat/tr*,usecheckpoints,minkeepdays 10 |
GGSCI>start mgr
GGSCI>add extexttr, tranlog, begin now
GGSCI>addexttrail ./dirdat/tr, ext exttr, megabytes 200
GGSCI>editparams 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 --warnlongtrans 2h, checkintervals 3m DDL INCLUDE OBJNAME "goldengate.*" EXCLUDE INSTRCOMMENTS ‘ggh_notsync‘ exttrail ./dirdat/tr numfiles 2000 dynamicresolution |
特别知识点说明:
EXCLUDE INSTRCOMMENTS ‘ggh_notsync‘说明:表示,语句带 “ggh_notsync”关键字的语句排除不抽取,如altertableb_rangedroppartition q1 /*ggh_notsync */; 由于该语句中带有ggh_notsync,所以排除不抽取。
这种应用场景非常实用,如有一张分区表,源端只想保留两个分区,历史的数据分区在目标端都保留,那么,就可以在源端drop分区的语句上加上排除的标识,在源端删除分区的动作就不会同步到目标端了。
GGSCI>add ext dpetr,exttrailsource ./dirdat/tr
GGSCI>add rmttrail ./dirdat/tr, ext dpetr, megabytes200
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
GGSCI>create subdirs
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
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
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 dynamicresolution numfiles 2000 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进程后,千万不要启动
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 |
GGSCI>startreptr,aftercsn 2553440
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