1、背景介绍
1.1、Extract两种抽取模式
1)Classic:基于在线日志或归档日志进行抽取。对数据库版本无特殊要求
2)Integrated:OGG 11.2.1及以上版本提供,其中Logmining
server负责以LCR格式从数据库日志中捕获数据变化,extract进程再将这些数据存入trail文件。
本地部署:源库和log mining
server数据库是同一个数据库(源库和集成抽取进程在同一台主机)
Downstream部署:源库和log mining
server数据库是不同的数据库(源库将归档日志传送downstream数据库)(源库和集成抽取进程不在同一台主机)
--Integrated模式的好处 *兼容性上支持更多的数据类型(IOT、compression、XML、LOB) *无需为RAC、ASM、TDE、RMAN做额外的配置 *多线程抽取(producer thread: capture redo;consumer thread:process redo),并发处理过程的性能提升 *OGG12c对oracle 12c 多租户的捕获(必须集成抽取模式才能支持) *DDL无需trigger(OGG12c、DB11204) OGG12新特性在Integrated模式DDL无需trigger
1.2、基于triggerDDL的复制 --需要考虑的问题:性能下降 1.3、replicat的三种复制模式
--集成replicat模式(replicat mode)可以支持的复制模式: *Classic capture (oracle和非oracle)-> Classic Replicat *Classic capture (oracle和非oracle)-> integrated Replicat *Integrated capture -> Classic Replicat *Integrated capture -> integrated Replicat 2、实验环境:源端与目标端都基于Integrated模式的OGG12搭建 源端: database version:12.1.2.0.0 goldengate version: 12.1.2.0.0 OS version:redhat 6.4 ip:192.168.3.7 目标端: database version:12.1.2.0 goldengate version: 12.1.2.0.0 OS version:redhat 6.4 ip:192.168.3.6
2.1、数据库相关设置 >sqlplus / nolog SQL>conn / as sysdba; --针对全库添加附加日志 SQL> alter database force logging; SQL>alter database add supplemental log data; SQL> alter system switch logfile; --创建 goldengate 管理用户和对应的表空间 datafile SQL>create tablespace ogg datafile '/u01/app/oracle/oradata/orcl/ogg01.dbf' size 4G autoextend on next 100M; SQL>create user ogg identified by ogg123 default tablespace ogg; SQL>create user test identified by oracle; --赋予相关权限给goldengate 管理用户 SQL>grant connect,resource,dba to ogg; SQL>GRANT EXECUTE ON UTL_FILE TO ogg; SQL> grant create table,create sequence to ogg; SQL>EXEC DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE(grantee => 'ogg', privilege_type => 'capture'); SQL> alter system set streams_pool_size=512M scope=both; 2.2、OGG12c的安装 1)创建 ogg 安装目录: #cd /u01 #mkdir ogg #chmod 777 ogg #chown -R oracle:oinstall /u01/ogg 2)以oracle 账号登录, 将ogg 介质通过ftp 传送到/u01/ogg 目录下并解压: #su –oracle $cd /u01/ogg $unzip *.zip 3)环境变量的配置: [oracle@oracle ~]$ vim .bash_profile ".bash_profile" 16L, 356C# .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then fi # User specific environment and startup programs PATH=/u01/ogg:$ORACLE_HOME/bin:$PATH:$HOME/bin export PATH export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/12.1.0/dbhome_1 export ORACLE_SID=orcl export LD_LIBRARY_PATH=/u01/ogg:$ORACLE_HOME/lib:/usr/lib 4)goldengate软件的安装 将下载的软件zip安装包拷贝到数据库服务器上,使用unzip命令解压。 --使用Oracle Universal Installer(OUI)安装goldengate: --在UNIX环境下,由于一般系统没有默认配置对图形化工具的支持,所以我们可以象安装oracle数据库一样,使用slient方式安装,这里唯一要做的就是事先准备好response文件。 INSTALL_OPTION=ORA11c SOFTWARE_LOCATION=/u01/ogg/goldengate START_MANAGER=false MANAGER_PORT=7809 DATABASE_LOCATION=/u01/app/oracle/product/12.1.0/dbhome_1 INVENTORY_LOCATION=/u01/app//oracle/oraInventory UNIX_GROUP_NAME=oinstall [oracle@oracle
response]$ vim oggcore.rsp ################################################################################ ## Oracle
GoldenGate installation option and details #------------------------------------------------------------------------------- # Specify the installation option. # Specify ORA12c for installing Oracle GoldenGate for Oracle Database 12c and # ORA11g for installing Oracle GoldenGate for Oracle Database 11g #-------------------------------------------------------------------------------INSTALL_OPTION=ORA12c #------------------------------------------------------------------------------- # Specify a location to install Oracle GoldenGate #-------------------------------------------------------------------------------SOFTWARE_LOCATION=/u01/ogg/goldengate #------------------------------------------------------------------------------- # Specify true to start the manager after installation. #-------------------------------------------------------------------------------START_MANAGER=false #------------------------------------------------------------------------------- # Specify a free port within the valid range for the manager process. # Required only if START_MANAGER is true. #------------------------------------------------------------------------------- MANAGER_PORT=7809 #------------------------------------------------------------------------------- # Specify the location of the Oracle Database. # Required only if START_MANAGER is true. #-------------------------------------------------------------------------------DATABASE_LOCATION=/u01/app/oracle/product/12.1.0/dbhome_1 ################################################################################ ## Specify details
to Create inventory for Oracle installs ## Required only
for the first Oracle product install on a system.
################################################################################ #------------------------------------------------------------------------------- # Specify the location which holds the install inventory files. # This is an optional parameter if installing on # Windows based Operating System. #------------------------------------------------------------------------------- INVENTORY_LOCATION=/u01/app/oracle/oraInventory #------------------------------------------------------------------------------- # Unix group to be set for the inventory directory. # This parameter is not applicable if installing on # Windows based Operating System. #-------------------------------------------------------------------------------UNIX_GROUP_NAME=oinstall [oracle@oracle Disk1]$ ./runInstaller -silent -responseFile /u01/ogg/fbo_ggs_Linux_x64_shiphome/Disk1/response/oggcore.rsp 2.2 OGG相关参数的配置(源端) #cd /u01/ogg >./ggsci --创建子目录: GGSCI>create subdirs --编辑 MGR 进程参数 GGSCI> edit params mgr port 7809 DYNAMICPORTLIST 7840-7850 AUTORESTART EXTRACT *, RETRIES 3, WAITMINUTES 5, RESETMINUTES 60 PURGEOLDEXTRACTS /u01/ogg/dirdat/aa*,usecheckpoints, minkeepdays 7 LAGREPORTHOURS 1 LAGINFOMINUTES 30 LAGCRITICALMINUTES 45 --启动 MGR 进程 GGSCI> start mgr --查看 MGR 进程 --GGSCI> info all --对需要同步的表进行表级附加日志的添加,即add trandata 操作。 GGSCI > dblogin userid ogg,password ogg123 GGSCI
>ADD EXTRACT intext, INTEGRATED TRANLOG, BEGIN NOW
GGSCI >ADD EXTTRAIL /u01/ogg/dirdat/aa, EXTRACT intext GGSCI>edit params intext EXTRACT intext EXTTRAIL /u01/ogg/dirdat/aa SETENV (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1) SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK) USERID ogg, PASSWORD ogg123 WILDCARDRESOLVE DYNAMIC LOGALLSUPCOLS UPDATERECORDFORMAT compact DYNAMICRESOLUTION DDL include all TABLE test.*; GGSCI>ADD EXTRACT intdp EXTTRAILSOURCE /u01/ogg/dirdat/aa GGSCI>ADD RMTTRAIL
/u01/ogg/dirdat/aa, EXTRACT intdp, MEGABYTES 100
GGSCI>>edit params intdp EXTRACT intdp USERID ogg, PASSWORD ogg123 RMTHOST 192.168.3.6, MGRPORT 7809 RMTTRAIL /u01/ogg/dirdat/aa Dynamicresolution TABLE test.*;
2.3 OGG相关参数的配置(目标端) #cd /u01/ogg >./ggsci --创建子目录: GGSCI>create subdirs --编辑 MGR 进程参数 GGSCI> edit params mgr port 7809 DYNAMICPORTLIST 7840-7850 AUTORESTART EXTRACT *, RETRIES 3, WAITMINUTES 5, RESETMINUTES 60 PURGEOLDEXTRACTS /u01/ogg/dirdat/aa*,usecheckpoints, minkeepdays 7 LAGREPORTHOURS 1 LAGINFOMINUTES 30 LAGCRITICALMINUTES 45 --启动 MGR 进程 GGSCI> start mgr --查看 MGR 进程 GGSCI> info all --集成模式: GGSCI>add replicat intrep integrated exttrail /u01/ogg/dirdat/aa GGSCI>edit params intrep REPLICAT intrep setenv (NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK) USERID ogg, PASSWORD ogg123 REPERROR DEFAULT, ABEND ASSUMETARGETDEFS DISCARDFILE /u01/ogg/dirrpt/intrep.dsc, APPEND, MEGABYTES 100 WILDCARDRESOLVE DYNAMIC Dynamicresolution DDL include mapped MAP test.*, TARGET test.*; 2.4、启动各个进程 源: GGSCI>start intext GGSCI>start intdp 目标: GGSCI>start 2.5 验证: 源端:在test用户下创建 一个表t $sqlplus / as sysdba >create table t(id number); --看有没有捕获到 目标端:
|
|