各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的知识,~O(∩_∩)O~: ① OGG的双向实时复制功能 注意:本篇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/ 【OGG的单向复制配置DDL(二OGG的双向复制功能,主要参考网址为:http://ylw6006.blog.51cto.com/all/470441/16 ,非常感谢斩月大师。 在完成ogg的双向复制!双向复制一般用于双业务中心环境下,目前笔者的生产环境中未使用到ogg系列的文章只是从技术上提前做一个准备,因而许多问题的细节未能理清,后续将继续学习研究!在开始之前,请先配置好(include ddl replicat)! 一.3 实验部分 一.3.1 实验目标 实现OGG2的双向复制功能。 一.3.2 配置checkpoint表注意:本文OGG2互为target,因而直接采用OGG2来标识两台数据库服务器 [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> view params ./GLOBALS GGSCHEMA ggusr GGSCI (orcltest) 2> edit params ./GLOBALS GGSCHEMA ggusr checkpointtable ggusr.rep_demo_ckpt ~ ~ ~ ~ 。。。。。。。。。。。。。。。。 ~ ~ ~ ~ ~ "./GLOBALS" 2L, 51C written GGSCI (orcltest) 3> view params ./GLOBALS GGSCHEMA ggusr checkpointtable ggusr.rep_demo_ckpt GGSCI (orcltest) 4> GGSCI (orcltest) 4> dblogin userid ggusr@ogg1,password lhr Successfully logged into database. GGSCI (orcltest) 5> add checkpointtable ggusr.rep_demo_ckpt Successfully created checkpoint table ggusr.rep_demo_ckpt. GGSCI (orcltest) 6> add checkpointtable ggusr.rep_demo_ckpt ERROR: OCI Error ORA-00955: name is already used by an existing object (status = 955). Creating checkpoint table ggusr.rep_demo_ckpt, SQL <CREATE TABLE ggusr.rep_demo_ckpt ( group_name VARCHAR2(8) NOT NULL, group_key NUMBER(19) NOT NULL, seqno NUMBER(10), rba NUMBER(19) NOT NULL, audit_ts VARCHAR2(29), create_ts DATE NOT NULL, last_update_ts DATE NOT NULL, current_dir VARCHAR2(255) NOT NULL, log_csn VARCHAR2(129), log_xid VARCHAR2(129), log_cmplt_csn VARCHAR2(129), log_cmplt_xids VARCHAR2(2000), version NUMBER(3), PRIMARY KEY (group_name, group_key))>. GGSCI (orcltest) 7> 一.3.3 配置DDL的复制[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> view params ./GLOBALS checkpointtable ggusr.rep_demo_ckpt GGSCI (rhel6_lhr) 2> edit params ./GLOBALS GGSCI (rhel6_lhr) 3> view params ./GLOBALS GGSCHEMA ggusr checkpointtable ggusr.rep_demo_ckpt GGSCI (rhel6_lhr) 4> [oracle@orcltest ~]$ cd $OGG_HOME [oracle@orcltest gg11]$ sqlplus sys/lhr@ogg2 as sysdba SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 10 17:10: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> select name,SUPPLEMENTAL_LOG_DATA_MIN, FORCE_LOGGING from v$database; NAME SUPPLEME FOR --------- -------- --- OGG2 NO NO SQL> alter database add supplemental log data ; Database altered. SQL> archive log list; Database log mode Archive Mode Automatic archival Enabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 7 Next log sequence to archive 9 Current log sequence 9 SQL> SQL> grant execute on utl_file to ggusr; Grant succeeded. 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 ------------------------------------------------------------------------------------------------------------------------ /u01/app/oracle/diag/rdbms/ogg2/ogg2/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> 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> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options [oracle@orcltest gg11]$ 一.3.4 OGG2上配置pump进程[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> dblogin userid ggusr@ogg2,password lhr Successfully logged into database. GGSCI (rhel6_lhr) 2> add trandata hr.* Logging of supplemental redo data enabled for table HR.COUNTRIES. Logging of supplemental redo data enabled for table HR.DEPARTMENTS. Logging of supplemental redo data enabled for table HR.EMPLOYEES. Logging of supplemental redo data enabled for table HR.JOBS. Logging of supplemental redo data enabled for table HR.JOB_HISTORY. Logging of supplemental redo data enabled for table HR.LOCATIONS. Logging of supplemental redo data enabled for table HR.REGIONS. Logging of supplemental redo data enabled for table HR.T1. Logging of supplemental redo data enabled for table HR.T2. 2015-06-10 03:11:40 WARNING OGG-00869 No unique key is defined for table 'T3'. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key. Logging of supplemental redo data enabled for table HR.T3. GGSCI (rhel6_lhr) 3> edit params eora_hr2 GGSCI (rhel6_lhr) 4> view params eora_hr2 extract eora_hr2 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 userid ggusr,password lhr tranlogoptions excludeuser ggusr //避免出现死循环复制,db1上的extract进程也需要进行此项设置 exttrail ./dirdat/ab table hr.*; GGSCI (rhel6_lhr) 4> add extract eora_hr2,tranlog,begin now EXTRACT added. GGSCI (rhel6_lhr) 5> add exttrail ./dirdat/ab,extract eora_hr2,megabytes 100 EXTTRAIL added. GGSCI (rhel6_lhr) 6> start extract eora_hr2 Sending START request to MANAGER ... EXTRACT EORA_HR2 starting GGSCI (rhel6_lhr) 7> edit params pora_hr2 GGSCI (rhel6_lhr) 8> view params pora_hr2 extract pora_hr2 setenv (ORACLE_SID=ogg2) setenv (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1) setenv (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK) passthru rmthost 192.168.59.129,mgrport 7809 rmttrail ./dirdat/pb table hr.*; GGSCI (rhel6_lhr) 9> add extract pora_hr2,exttrailsource ./dirdat/ab EXTRACT added. GGSCI (rhel6_lhr) 10> add rmttrail ./dirdat/pb extract pora_hr2,megabytes 100 RMTTRAIL added. GGSCI (rhel6_lhr) 11> start extract pora_hr2 Sending START request to MANAGER ... EXTRACT PORA_HR2 starting GGSCI (rhel6_lhr) 12> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING EXTRACT RUNNING EORA_HR2 00:00:00 00:04:16 EXTRACT RUNNING PORA_HR2 00:00:00 00:00:00 REPLICAT RUNNING RORA_HR 00:00:00 00:00:01 GGSCI (rhel6_lhr) 13> OGG1上设置抽取进程参数,添加replicat进程[/title3] [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> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING EXTRACT RUNNING EORA_HR 00:00:00 00:00:10 EXTRACT RUNNING PORA_HR 00:00:00 00:00:05 GGSCI (orcltest) 2> view params rora_hr2 ERROR: PARAMS file RORA_HR2 does not exist. GGSCI (orcltest) 3> edit params rora_hr2 replicat rora_hr2 setenv (ORACLE_SID=ogg1) setenv (ORACLE_HOME=/u02/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_hr2.dsc,purge map hr.* ,target hr.*; ~ ~ ~ ~ 。。。。。。。。。。。。。。。 ~ ~ ~ ~ ~ "dirprm/rora_hr2.prm" [New] 11L, 345C written GGSCI (orcltest) 4> view params rora_hr2 replicat rora_hr2 setenv (ORACLE_SID=ogg1) setenv (ORACLE_HOME=/u02/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 DDLOPTIONS REPORT userid ggusr,password lhr handlecollisions assumetargetdefs discardfile ./dirrpt/rora_hr2.dsc,purge map hr.* ,target hr.*; GGSCI (orcltest) 5> add replicat rora_hr2,exttrail ./dirdat/pb REPLICAT added. GGSCI (orcltest) 6> start replicat rora_hr2 Sending START request to MANAGER ... REPLICAT RORA_HR2 starting GGSCI (orcltest) 7> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING EXTRACT RUNNING EORA_HR 00:00:00 00:00:00 EXTRACT RUNNING PORA_HR 00:00:00 00:00:09 REPLICAT RUNNING RORA_HR2 00:00:00 00:00:04 GGSCI (orcltest) 8> 一.3.6 测试一.3.6.1 ddl测试[oracle@orcltest gg11]$ sqlplus hr/hr@ogg1 SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 10 18:07:48 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 t5 as select * from dual; Table created. SQL> conn hr/hr@ogg2 Connected. SQL> select count(1) from t5; COUNT(1) ---------- 1 SQL> alter table t5 add name varchar2(255); Table altered. SQL> conn hr/hr@ogg1 Connected. SQL> desc t5 Name Null? Type ----------------------------------------- -------- ---------------------------- DUMMY VARCHAR2(1) NAME VARCHAR2(255) DDL测试注意查看/u01/app/oracle/diag/rdbms/ogg2/ogg2/trace/ggs_ddl_trace.log): SESS 470002-2015-06-10 18:11:50 : DDL : ************************* Start of log for DDL sequence [1508], 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.T5] SESS 470002-2015-06-10 18:11:50 : DDLTRACE1 : Before Trigger: point in execution = [1.0], objtype name [HR.T5] SESS 470002-2015-06-10 18:11:50 : DDL : DDL operation [ create table t5 as select * from dual ], sequence [1508], DDL type [CREATE] TABLE, real object type , validity [], object ID [], object [HR.T5], real object [HR.T5], base object schema [], base object name [], logged as [HR] SESS 470002-2015-06-10 18:11:50 : DDL : Start SCN found [1112052] SESS 470002-2015-06-10 18:11:50 : DDL : ------------------------- End of log for DDL sequence [1508] SESS 450003-2015-06-10 18:12:38 : DDL : ************************* Start of log for DDL sequence [1509], 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.T5] SESS 450003-2015-06-10 18:12:38 : DDLTRACE1 : Before Trigger: point in execution = [1.0], objtype name [HR.T5] SESS 450003-2015-06-10 18:12:38 : DDL : DDL operation [alter table hr."T5" add name varchar2(255) /* GOLDENGATE_DDL_REPLICATION */ ], sequence [1509], DDL type [ALTER] TABLE, real object type , validity [VALID], object ID [76900], object [HR.T5], real object [HR.T5], base object schema [], base object name [], logged as [GGUSR] SESS 450003-2015-06-10 18:12:38 : DDL : Start SCN found [1112101] SESS 450003-2015-06-10 18:12:40 : DDL : ------------------------- End of log for DDL sequence [1509] OGG1上的日志(
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理
|