各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的知识,~O(∩_∩)O~: ① OGG的单向DDL实时复制功能 注意:本篇thread 1的最大归档日志号为thread 2的最大归档日志号为IP地址:
OS版本及2.6.32-504.16.2.el6.x86_64 | RHEL6.5 64位,OGG】OGG】DML复制配置):http://blog.itpub.net/26736162/viewspace-1696020/ 一.2.4 本文简介 本文基于DML复制功能,加上OGG配置,包括双向复制,还有2台服务器,搭建hr用户下的数据DML复制功能。
一.3.2 先验证之前的配置不支持DDL复制,这里在target端!DML操作可以成功复制。 [oracle@orcltest ~]$ sqlplus hr/hr@ogg1 SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 10 16:18:03 2015 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> create table t2 (id number primary key,name varchar2(20)); Table created. SQL> conn hr/hr@ogg2 Connected. SQL> select tname from tab where tname='T2'; no rows selected SQL> create table t2 (id number primary key,name varchar2(20)); Table created. SQL> conn hr/hr@ogg1 Connected. SQL> insert into t2 values (1,'one'); 1 row created. SQL> commit; Commit complete. SQL> conn hr/hr@ogg2 Connected. SQL> select * from t2; ID NAME ---------- -------------------- 1 one SQL> 此时OGG支持(在) 一.3.3.1 赋予ggusr用户相应的权限,修改全局配置文件添加ggschema参数[oracle@orcltest ~]$ sqlplus sys/lhr@ogg1 as sysdba SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 10 16:27:05 2015 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> grant execute on utl_file to ggusr; Grant succeeded. SQL> [oracle@orcltest gg11]$ ggsci Oracle GoldenGate Command Interpreter for Oracle Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14 Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved. GGSCI (orcltest) 1> edit param ./GLOBALS GGSCHEMA ggusr ~ ~ ~ ~ 。。。。。。。。。。。。。。。 ~ ~ ~ ~ "./GLOBALS" 1L, 15C written GGSCI (orcltest) 2> view param ./GLOBALS GGSCHEMA ggusr GGSCI (orcltest) 3> 一.3.3.2 运行相关的sql脚本如果想使用DDL的相关脚本。 1.@marker_setup.sql 2.@ddl_setup.sql 3.@role_setup.sql 4.GRANT GGS_GGSUSER_ROLE TO gguser 5.@ddl_enable.sql 6.@?/rdbms/admin/dbmspool.sql 7.@ddl_pin.sql ggusr [oracle@orcltest gg11]$ sqlplus sys/lhr@ogg1 as sysdba SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 10 16:30:45 2015 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> @marker_setup.sql Marker setup script You 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:ggusr Marker setup table script complete, running verification script... Please enter the name of a schema for the GoldenGate database objects: Setting schema name to GGUSR MARKER TABLE ------------------------------- OK MARKER SEQUENCE ------------------------------- OK Script complete. SQL> @ddl_setup.sql Oracle GoldenGate DDL Replication setup script Verifying 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:ggusr Working, please wait ... Spooling to file ddl_setup_spool.txt Checking for sessions that are holding locks on Oracle Golden Gate metadata tables ... Check complete. Using GGUSR 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 GGUSR CLEAR_TRACE STATUS: Line/pos Error -------------------- ----------------------------------------------------------------- No errors No errors CREATE_TRACE STATUS: Line/pos Error -------------------- ----------------------------------------------------------------- No errors No errors TRACE_PUT_LINE STATUS: Line/pos Error -------------------- ----------------------------------------------------------------- No errors No errors INITIAL_SETUP STATUS: Line/pos Error -------------------- ----------------------------------------------------------------- No errors No errors DDLVERSIONSPECIFIC PACKAGE STATUS: Line/pos Error -------------------- ----------------------------------------------------------------- No errors No errors DDLREPLICATION PACKAGE STATUS: Line/pos Error -------------------- ----------------------------------------------------------------- No errors No errors DDLREPLICATION PACKAGE BODY STATUS: Line/pos Error -------------------- ----------------------------------------------------------------- No errors No errors DDL IGNORE TABLE ----------------------------------- OK DDL IGNORE LOG TABLE ----------------------------------- OK DDLAUX PACKAGE STATUS: Line/pos Error -------------------- ----------------------------------------------------------------- No errors No errors DDLAUX PACKAGE BODY STATUS: Line/pos Error -------------------- ----------------------------------------------------------------- No errors No errors SYS.DDLCTXINFO PACKAGE STATUS: Line/pos Error -------------------- ----------------------------------------------------------------- No errors No errors SYS.DDLCTXINFO PACKAGE BODY STATUS: Line/pos Error -------------------- ----------------------------------------------------------------- No errors No errors DDL HISTORY TABLE ----------------------------------- OK DDL HISTORY TABLE(1) ----------------------------------- OK DDL DUMP TABLES ----------------------------------- OK DDL DUMP COLUMNS ----------------------------------- OK DDL DUMP LOG GROUPS ----------------------------------- OK DDL DUMP PARTITIONS ----------------------------------- OK DDL DUMP PRIMARY KEYS ----------------------------------- OK DDL SEQUENCE ----------------------------------- OK GGS_TEMP_COLS ----------------------------------- OK GGS_TEMP_UK ----------------------------------- OK DDL TRIGGER CODE STATUS: Line/pos Error -------------------- ----------------------------------------------------------------- No errors No errors DDL TRIGGER INSTALL STATUS ----------------------------------- OK DDL TRIGGER RUNNING STATUS ---------------------------------------------------------------------- ENABLED STAYMETADATA IN TRIGGER ---------------------------------------------------------------------- OFF DDL TRIGGER SQL TRACING ---------------------------------------------------------------------- 0 DDL TRIGGER TRACE LEVEL ---------------------------------------------------------------------- 0 LOCATION OF DDL TRACE FILE ------------------------------------------------------------------------------------------------------------------------ /u02/app/oracle/diag/rdbms/ogg1/ogg1/trace/ggs_ddl_trace.log Analyzing installation status... STATUS OF DDL REPLICATION ------------------------------------------------------------------------------------------------------------------------ SUCCESSFUL installation of DDL Replication software components Script complete. SQL> @role_setup.sql GGS Role setup script This script will drop and recreate the role GGS_GGSUSER_ROLE To 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:ggusr Wrote file role_setup_set.txt PL/SQL procedure successfully completed. Role setup script complete Grant this role to each user assigned to the Extract, GGSCI, and Manager processes, by using the following SQL command: GRANT GGS_GGSUSER_ROLE TO <loggedUser> where <loggedUser> is the user assigned to the GoldenGate processes. SQL> grant ggs_ggsuser_role to ggusr; Grant succeeded. SQL> @ddl_enable.sql Trigger altered. SQL> @?/rdbms/admin/dbmspool.sql Package created. Grant succeeded. SQL> @ddl_pin.sql ggusr PL/SQL procedure successfully completed. PL/SQL procedure successfully completed. PL/SQL procedure successfully completed. SQL> /u02/app/oracle/diag/rdbms/ogg1/ogg1/trace/ggs_ddl_trace.log 为extract进程的"ddl include all"参数,重启replicat进程的"ddl include all"和replicat进程[/title3] [oracle@rhel6_lhr gg11]$ ggsci Oracle GoldenGate Command Interpreter for Oracle Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14 Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved. GGSCI (rhel6_lhr) 1> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING REPLICAT RUNNING RORA_HR 00:00:00 00:00:07 GGSCI (rhel6_lhr) 2> edit params rora_hr GGSCI (rhel6_lhr) 3> view params rora_hr replicat rora_hr setenv (ORACLE_SID=ogg2) setenv (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1) setenv (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK) ddl include all ddlerror default ignore retryop maxretries 3 retrydelay 5 userid ggusr,password lhr handlecollisions assumetargetdefs discardfile ./dirrpt/rora_hr.dsc,purge map hr.* ,target hr.*; GGSCI (rhel6_lhr) 4> stop rora_hr Sending STOP request to REPLICAT RORA_HR ... Request processed. GGSCI (rhel6_lhr) 5> start rora_hr Sending START request to MANAGER ... REPLICAT RORA_HR starting GGSCI (rhel6_lhr) 6> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING REPLICAT RUNNING RORA_HR 00:00:00 00:00:06 GGSCI (rhel6_lhr) 7> GGSCI (rhel6_lhr) 7> info replicat rora_hr REPLICAT RORA_HR Last Started 2015-06-10 02:39 Status RUNNING Checkpoint Lag 00:00:00 (updated 00:00:08 ago) Log Read Checkpoint File ./dirdat/pa000000 First Record RBA 7200161 GGSCI (rhel6_lhr) 8> 一.3.6 测试 [oracle@orcltest ~]$ sqlplus hr/hr@ogg1 SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 10 16:47:12 2015 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> alter table t2 add location varchar2(200); Table altered. SQL> conn hr/hr@ogg2 Connected. SQL> desc t2 Name Null? Type ----------------------------------------- -------- ---------------------------- ID NOT NULL NUMBER NAME VARCHAR2(20) LOCATION VARCHAR2(200) SQL> conn hr/hr@ogg1 Connected. SQL> create table t3 as select object_id,object_name from dba_objects; Table created. SQL> select count(1) from t3; COUNT(1) ---------- 75262 SQL> conn hr/hr@ogg2 Connected. SQL> select tname from tab where tname='T3'; TNAME ------------------------------ T3 SQL> select count(1) from t3; COUNT(1) ---------- 75217 可以看到DDL语句的日志: SESS 380011-2015-06-10 16:47:19 : DDL : ************************* Start of log for DDL sequence [14], v[ $Id: ddl_setup.sql /st_oggcore_11.2.1/8 2012/04/02 11:11:33 smijatov Exp $ ] trace level [0], owner schema of DDL package [GGUSR], objtype name [HR.T2] SESS 380011-2015-06-10 16:47:19 : DDLTRACE1 : Before Trigger: point in execution = [1.0], objtype name [HR.T2] SESS 380011-2015-06-10 16:47:19 : DDL : DDL operation [alter table t2 add location varchar2(200) ], sequence [14], DDL type [ALTER] TABLE, real object type , validity [VALID], object ID [76836], object [HR.T2], real object [HR.T2], base object schema [], base object name [], logged as [HR] SESS 380011-2015-06-10 16:47:19 : DDL : Start SCN found [1107605] SESS 380011-2015-06-10 16:47:20 : DDL : ------------------------- End of log for DDL sequence [14] SESS 390002-2015-06-10 16:48:14 : DDL : ************************* Start of log for DDL sequence [501], v[ $Id: ddl_setup.sql /st_oggcore_11.2.1/8 2012/04/02 11:11:33 smijatov Exp $ ] trace level [0], owner schema of DDL package [GGUSR], objtype name [HR.T3] SESS 390002-2015-06-10 16:48:14 : DDLTRACE1 : Before Trigger: point in execution = [1.0], objtype name [HR.T3] SESS 390002-2015-06-10 16:48:14 : DDL : DDL operation [create table t3 as select object_id,object_name from dba_objects ], sequence [501], DDL type [CREATE] TABLE, real object type , validity [], object ID [], object [HR.T3], real object [HR.T3], base object schema [], base object name [], logged as [HR] SESS 390002-2015-06-10 16:48:14 : DDL : Start SCN found [1107994] SESS 390002-2015-06-10 16:48:14 : DDL : ------------------------- End of log for DDL sequence [501] 一.3.7 实验总结 DDL复制,我们可以从日志看出其执行的DML配置熟悉的话,
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理
|