OGG单向DDL复制操作
实验目的:在两台虚机模拟实现简单的单向的DDL复制.说明:因《OGG单机安装与配置,并实验单向DML复制操作》中已配置过单向的dml操作,所以本次配置内容在前一篇的基础之上。环境解释:在《OGG单机安装与配置,并实验单向DML复制操作》中hostname:slient,db_name:test作为源库,而hostname:one,db_name:onemore作为目标库,本次只需要配置一次反向的操作即可:即slient为源端, onemo为目标端.实验步骤:1.源端关闭回收站注明:在oracle11g 中, recyclebin参数的 System Modifiable为DEFERRED,意思是要修改系统级的话,就要加deferred参数,对当前已经连接的sesion没有影响,但新连接的session将受到影响。(可以查询视图selectname,isses_modifiable,issys_modifiable from v$parameter wherename='recyclebin';)SQL> set lines 200SQL> col name for a30SQL> select name,isses_modifiable,issys_modifiable from v$parameter where name='recyclebin';NAME ISSES ISSYS_MOD------------------------------ ----- ---------recyclebin TRUE DEFERREDSQL> alter system set recyclebin=off DEFERRED; System altered.SQL> select name,isses_modifiable,issys_modifiable from v$parameter where name='recyclebin';NAME ISSES ISSYS_MOD------------------------------ ----- ---------recyclebin TRUE DEFERRED2.源端配置./GLOBALS(修改全局配置文件添加ggschema参数)GGSCI (slient as ogg@test) 14> edit params ./GLOBALS ggschema ogg~"./GLOBALS" [New] 1L, 13C writtenGGSCI (slient as ogg@test) 15>GGSCI (slient as ogg@test) 16> view param ./GLOBALS ggschema oggGGSCI (slient as ogg@test) 17>3.源库运行相关的sql脚本[oracle@slient ogg_home]$ pwd/opt/ogg/ogg_home[oracle@slient ogg_home]$[oracle@slient ogg_home]$ ls mark*marker_remove.sql marker_setup.sql marker_status.sql[oracle@slient ogg_home]$[oracle@slient ogg_home]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Mon Oct 30 21:52:30 2017Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options--执行marker_setup.sql脚本:SQL> @/opt/ogg/ogg_home/marker_setup.sqlMarker setup scriptYou will be prompted for the name of a schema for the Oracle GoldenGate database objects.NOTE: The schema must be created prior to running this script.NOTE: Stop all DDL replication before starting this installation.Enter Oracle GoldenGate schema name:oggMarker setup table script complete, running verification script...Please enter the name of a schema for the GoldenGate database objects:Setting schema name to OGGMARKER TABLE-------------------------------OKMARKER SEQUENCE-------------------------------OKScript complete.SQL>--执行ddl_setup.sql脚本SQL> !ls ddl_setup*ddl_setup.sqlSQL>@/opt/ogg/ogg_home/ddl_setup.sqlOracle GoldenGate DDL Replication setup scriptVerifying that current user has privileges to install DDL Replication...You will be prompted for the name of a schema for the Oracle GoldenGate database objects.NOTE: For an Oracle 10g source, the system recycle bin must be disabled. For Oracle 11g and later, it can be enabled.NOTE: The schema must be created prior to running this script.NOTE: Stop all DDL replication before starting this installation.Enter Oracle GoldenGate schema name:oggWorking, please wait ...Spooling to file ddl_setup_spool.txtChecking for sessions that are holding locks on Oracle Golden Gate metadata tables ...Check complete.Using OGG as a Oracle GoldenGate schema name.Working, please wait ...DDL replication setup script complete, running verification script...Please enter the name of a schema for the GoldenGate database objects:Setting schema name to OGGCLEAR_TRACE STATUS:Line/pos Error-------------------- -----------------------------------------------------------------No errors No errorsCREATE_TRACE STATUS:Line/pos Error-------------------- -----------------------------------------------------------------No errors No errorsTRACE_PUT_LINE STATUS:Line/pos Error-------------------- -----------------------------------------------------------------No errors No errorsINITIAL_SETUP STATUS:Line/pos Error-------------------- -----------------------------------------------------------------No errors No errorsDDLVERSIONSPECIFIC PACKAGE STATUS:Line/pos Error-------------------- -----------------------------------------------------------------No errors No errorsDDLREPLICATION PACKAGE STATUS:Line/pos Error-------------------- -----------------------------------------------------------------No errors No errorsDDLREPLICATION PACKAGE BODY STATUS:Line/pos Error-------------------- -----------------------------------------------------------------No errors No errorsDDL IGNORE TABLE-----------------------------------OKDDL IGNORE LOG TABLE-----------------------------------OKDDLAUX PACKAGE STATUS:Line/pos Error-------------------- -----------------------------------------------------------------No errors No errorsDDLAUX PACKAGE BODY STATUS:Line/pos Error-------------------- -----------------------------------------------------------------No errors No errorsSYS.DDLCTXINFO PACKAGE STATUS:Line/pos Error-------------------- -----------------------------------------------------------------No errors No errorsSYS.DDLCTXINFO PACKAGE BODY STATUS:Line/pos Error-------------------- -----------------------------------------------------------------No errors No errorsDDL HISTORY TABLE-----------------------------------OKDDL HISTORY TABLE(1)-----------------------------------OKDDL DUMP TABLES-----------------------------------OKDDL DUMP COLUMNS-----------------------------------OKDDL DUMP LOG GROUPS-----------------------------------OKDDL DUMP PARTITIONS-----------------------------------OKDDL DUMP PRIMARY KEYS-----------------------------------OKDDL SEQUENCE-----------------------------------OKGGS_TEMP_COLS-----------------------------------OKGGS_TEMP_UK-----------------------------------OKDDL TRIGGER CODE STATUS:Line/pos Error-------------------- -----------------------------------------------------------------No errors No errorsDDL TRIGGER INSTALL STATUS-----------------------------------OKDDL TRIGGER RUNNING STATUS----------------------------------------------------------------------ENABLEDSTAYMETADATA IN TRIGGER----------------------------------------------------------------------OFFDDL TRIGGER SQL TRACING----------------------------------------------------------------------0DDL TRIGGER TRACE LEVEL----------------------------------------------------------------------NONELOCATION OF DDL TRACE FILE------------------------------------------------------------------------------------------------------------------------/u01/app/oracle/diag/rdbms/test/test/trace/ggs_ddl_trace.logAnalyzing installation status...VERSION OF DDL REPLICATION------------------------------------------------------------------------------------------------------------------------OGGCORE_12.2.0.1.0_PLATFORMS_151211.1401STATUS OF DDL REPLICATION------------------------------------------------------------------------------------------------------------------------SUCCESSFUL installation of DDL Replication software componentsScript complete.SQL>--执行role_setup.sql脚本SQL> !pwd/opt/ogg/ogg_homeSQL> @role_setup.sqlGGS Role setup scriptThis script will drop and recreate the role GGS_GGSUSER_ROLETo use a different role name, quit this script and then edit the params.sql script to change the gg_role parameter to the preferred name. (Do not run the script.)You will be prompted for the name of a schema for the GoldenGate database objects.NOTE: The schema must be created prior to running this script.NOTE: Stop all DDL replication before starting this installation.Enter GoldenGate schema name:oggSP2-0606: Cannot create SPOOL file "role_setup_spool.txt"SP2-0606: Cannot create STORE file "role_setup_set.txt"PL/SQL procedure successfully completed.Role setup script completeGrant this role to each user assigned to the Extract, GGSCI, and Manager processes, by using the following SQL command:GRANT GGS_GGSUSER_ROLE TO where is the user assigned to the GoldenGate processes.SQL>--根据上述提示执行授权:SQL> GRANT GGS_GGSUSER_ROLE TO ogg;Grant succeeded.SQL>--执行ddl_enable.sql 脚本:SQL> @ddl_enable.sql Trigger altered.SQL>
--执行dbmspool.sql
SQL> @?/rdbms/admin/dbmspool.sql Package created.Grant succeeded.--执行ddl_pin.sqlSQL> @ddl_pin.sql Enter value for 1: oggPL/SQL procedure successfully completed.Enter value for 1: oggPL/SQL procedure successfully completed.PL/SQL procedure successfully completed.SQL>4.源库修改extract进程的params文件,添加"ddl include all"参数,重启extract进程GGSCI (slient as ogg@test) 19> edit param extaEXTRACT extasetenv (ORACLE_SID=test)setenv (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)userid ogg,password oggddl include allexttrail /opt/ogg/ogg_home/dirdat/r1dynamicresolutionTABLE scott.*;~"dirprm/exta.prm" 8L, 203C writtenGGSCI (slient as ogg@test) 20>--重启extract进程:GGSCI (slient as ogg@test) 20> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNING EXTRACT RUNNING DPEA 00:00:00 00:00:05 EXTRACT RUNNING EXTA 00:00:00 00:00:10 REPLICAT STOPPED REP_REV 00:00:00 01:16:00 GGSCI (slient as ogg@test) 21>GGSCI (slient as ogg@test) 21>GGSCI (slient as ogg@test) 21> stop extaSending STOP request to EXTRACT EXTA ...Request processed.GGSCI (slient as ogg@test) 22> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNING EXTRACT RUNNING DPEA 00:00:00 00:00:07 EXTRACT STOPPED EXTA 00:00:00 00:00:20 REPLICAT STOPPED REP_REV 00:00:00 01:16:32 GGSCI (slient as ogg@test) 23> start EXTASending START request to MANAGER ...EXTRACT EXTA startingGGSCI (slient as ogg@test) 24> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNING EXTRACT RUNNING DPEA 00:00:00 00:00:07 EXTRACT RUNNING EXTA 00:00:00 00:00:03 REPLICAT STOPPED REP_REV 00:00:00 01:16:42 GGSCI (slient as ogg@test) 25> info extract EXTAEXTRACT EXTA Last Started 2017-10-30 22:30 Status RUNNINGCheckpoint Lag 00:00:00 (updated 00:00:08 ago)Process ID 21542Log Read Checkpoint Oracle Redo Logs 2017-10-30 22:30:38 Thread 1, Seqno 336, RBA 7193088 SCN 0.21418576 (21418576)GGSCI (slient as ogg@test) 26> 5.目标库修改replicat进程的params文件,添加"ddl include all"和"ddlerrordefault ignore retryop maxretries 3 retrydelay 5" 参数,重启replicat进程GGSCI (one as ogg@onemo) 67> edit param rep_demoreplicat rep_demosetenv (oracle_sid=onemo)setenv (nls_lang ="american_america.zhs16gbk")userid ogg,password oggddl include allddlerror default ignore retryop maxretries 3 retrydelay 5--report at 01:59--reportrollover at 02:00reperror default,abenddiscardfile /u01/app/oracle/ogg/dirrpt/repa.dsc,append, megabytes 10assumetargetdefs--allownoopupdatesdynamicresolution--insertallrecordsmap scott.*,target scott.*;~~"dirprm/rep_demo.prm" 15L, 431C writtenGGSCI (one as ogg@onemo) 68>GGSCI (one as ogg@onemo) 68> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNING EXTRACT STOPPED DPE_REV 00:00:00 01:24:21 EXTRACT STOPPED EXT_REV 00:00:00 01:24:27 REPLICAT STOPPED REP_DEMO 00:00:00 00:04:09 --重启replicat进程GGSCI (one as ogg@onemo) 69> start REP_DEMOSending START request to MANAGER ...REPLICAT REP_DEMO startingGGSCI (one as ogg@onemo) 70> info allProgram Status Group Lag at Chkpt Time Since ChkptMANAGER RUNNING EXTRACT STOPPED DPE_REV 00:00:00 01:24:28 EXTRACT STOPPED EXT_REV 00:00:00 01:24:34 REPLICAT RUNNING REP_DEMO 00:00:00 00:00:01 GGSCI (one as ogg@onemo) 71>GGSCI (one as ogg@onemo) 71> info REPLICAT REP_DEMOREPLICAT REP_DEMO Last Started 2017-10-27 08:45 Status RUNNINGCheckpoint Lag 00:00:00 (updated 00:00:05 ago)Process ID 11591Log Read Checkpoint File /u01/app/oracle/ogg/dirdat/ra000000000 2017-10-30 21:11:03.153747 RBA 5075GGSCI (one as ogg@onemo) 72>6.测试源端和目标端的数据--先检查源库和目标库:源库:SQL> conn scott/tiger;Connected.SQL> select * from tab;TNAME TABTYPE CLUSTERID------------------------------ ------- ----------BONUS TABLEDEPT TABLEEMP TABLESALGRADE TABLETB_PT TABLETREE_VIEW VIEW6 rows selected.目标库:SQL> conn scott/tiger;Connected.SQL>SQL> select * from tab;TNAME TABTYPE CLUSTERID------------------------------ ------- ----------BONUS TABLEDEPT TABLEEMP TABLESALGRADE TABLESQL>--开始测试:源库:SQL> create table t5(a int);Table created.SQL> insert into t5 values(111); 1 row created.SQL> commit;Commit complete.SQL> select * from tab;TNAME TABTYPE CLUSTERID------------------------------ ------- ----------BONUS TABLEDEPT TABLEEMP TABLESALGRADE TABLET5 TABLETB_PT TABLETEST TABLETREE_VIEW VIEW8 rows selected.SQL>检查目标库:SQL> select * from tab;TNAME TABTYPE CLUSTERID------------------------------ ------- ----------BONUS TABLEDEPT TABLEEMP TABLESALGRADE TABLET5 TABLETEST TABLE6 rows selected.SQL> select * from t5; A---------- 111SQL> 测试数据同步成功,实现了单向DDL复制!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
文章标题:OGG单向DDL复制操作
当前地址:
http://njwzjz.com/article/ijhjej.html