首页 » OGG » GoldenGate 小测试initial load,extract change

GoldenGate 小测试initial load,extract change

模拟一种主库不停机,做个备库并initial load,并同步改变数据

流程
安装配置GOLDEN GATE
源机启用本地Extract 进程抽取变化生成本地trail文件
源机exp
do something (DML)
目标机imp
目标机配置OGG,启用mgr
源机配置Extract data-pump 传trail 到目标机
目标机replicat 应用trail

一,配置OGG环境,安装就是解压

[root@dbsource oracle]# chown oracle.oinstall fbo_ggs_Linux_x86_ora10g_32bit.tar 

[oracle@dbsource u01]$ cd $ORACLE_BASE
[oracle@dbsource oracle]$ mkdir oggsoft
[oracle@dbsource oracle]$ cd oggsoft/
[oracle@dbsource oggsoft]$ ls
[oracle@dbsource oggsoft]$ pwd
/u01/app/oracle/oggsoft
[oracle@dbsource oggsoft]$ echo "export OGG_HOME=/u01/app/oracle/oggsoft" >> ~/.bash_profile
[oracle@dbsource oggsoft]$ . ~/.bash_profile
[oracle@dbsource oggsoft]$ echo $OGG_HOME
/u01/app/oracle/oggsoft
[oracle@dbsource ~]$ tar -xvf fbo_ggs_Linux_x86_ora10g_32bit.tar  -C /u01/app/oracle/oggsoft


note:安装个支持方向键工具
[root@dbsource Server]# rpm -ivh libtermcap-devel-2.0.8-46.1.i386.rpm 
[root@dbsource Server]# rpm -ivh readline-devel-5.1-3.el5.i386.rpm 
[root@dbsource ~]# cd rlwrap-0.37
[root@dbsource rlwrap-0.37]# ./configure
make
make install
[oracle@dbsource oggsoft]$ echo alias ggsci=\"rlwrap \.\/ggsci\" >> ~/.bash_profile
[oracle@dbsource oggsoft]$ echo alias sqlplus=\"rlwrap sqlplus\" >> ~/.bash_profile          
[oracle@dbsource oggsoft]$ echo alias ora=\"sqlplus \/ as sysdba\" >> ~/.bash_profile  
[oracle@dbsource oggsoft]$ . ~/.bash_profile 


--cd $OGG_HOME

切到OGG安装目录开始配置OGG
[oracle@dbsource oggsoft]$ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x86, 32bit (optimized), Oracle 10g on Apr 23 2012 07:06:02

Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.



GGSCI (dbsource) 1> create subdirs

Creating subdirectories under current directory /u01/app/oracle/oggsoft

Parameter files                /u01/app/oracle/oggsoft/dirprm: already exists
Report files                   /u01/app/oracle/oggsoft/dirrpt: created
Checkpoint files               /u01/app/oracle/oggsoft/dirchk: created
Process status files           /u01/app/oracle/oggsoft/dirpcs: created
SQL script files               /u01/app/oracle/oggsoft/dirsql: created
Database definitions files     /u01/app/oracle/oggsoft/dirdef: created
Extract data files             /u01/app/oracle/oggsoft/dirdat: created
Temporary files                /u01/app/oracle/oggsoft/dirtmp: created
Stdout files                   /u01/app/oracle/oggsoft/dirout: created

GGSCI (dbsource) 1> edit params mgr
port 8000

GGSCI (dbsource) 2> start mgr
Manager started.


GGSCI (dbsource) 3> info mgr
Manager is running (IP port dbsource.8000)

也可以直接vi  dirprm目录下的创建文件,开启extract,replicat前必须先启动mgr,负责管理ER


在源库构建一个schema

sqlplus system/oracle
SQL> create user anbob identified by anbob;
SQL> grant connect,resource to anbob;
SQL> create table anbob.obj as select * from dba_objects ;
SQL> create table anbob.tabs as select * from dba_tables ;
SQL> create table anbob.segs as select * from dba_segments ;


增加数据库级附加日志
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

为了区分,我创建了三个表,只有tabs有索引,obj、tabs表有表级日志
conn anbob/anbob
SQL> create unique index un_idx_tabs on tabs(owner,table_name);
Index created.

add table level log logging
GGSCI (dbsource) 1> dblogin userid system password oracle
Successfully logged into database.

GGSCI (dbsource) 2> add trandata anbob.obj
2012-07-22 22:21:33  WARNING OGG-00869  No unique key is defined for table 'OBJ'. 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 ANBOB.OBJ.

GGSCI (dbsource) 3> add trandata anbob.tabs

Logging of supplemental redo data enabled for table ANBOB.TABS.

查看表级日志

SQL> select * from dba_log_groups;

OWNER      LOG_GROUP_NAME                 TABLE_NAME LOG_GROUP_TYPE      ALWAYS      GENERATED
---------- ------------------------------ ---------- ------------------- ----------- --------------
ANBOB      GGS_51353                      OBJ        USER LOG GROUP      ALWAYS      USER NAME
ANBOB      GGS_51354                      TABS       USER LOG GROUP      ALWAYS      USER NAME


开始配置抽取进程eanbob1,对用户密码加密
GGSCI (dbsource) 5> encrypt password oracle encryptkey default
Using default key...

Encrypted password:  AACAAAAAAAAAAAGAIFAAUDVHCFUGFIYF
Algorithm used:  BLOWFISH


GGSCI (dbsource) 4> edit params eanbob1
extract eanbob1
--------------------------------
-- local extract for anbob schema
---------------------------------
setenv (NLS_LANG = AMERICAN_AMERICA.ZHS16GBK )
userid system, password "AACAAAAAAAAAAAGAIFAAUDVHCFUGFIYF", encryptkey default

ReportCount Every 30 Minutes, Rate
Report at 01:00
ReportRollover at 01:15
DiscardFile dirrpt/eanbob1.dsc, Append
DiscardRollover at 02:00 ON SUNDAY
exttrail dirdat/l1
---note: two-character local Extract trail-file name
table anbob.*;
---note: table parameter must end with ';'

OGG参数名字意图很明显,比如ReportRollover,DiscardRollover就是防止报告文件和未应用记录文件太大而定时分卷。


GGSCI (dbsource) 5> add extract eanbob1, tranlog, begin now
EXTRACT added.

配置extract进程应用上面的配置文件,从现在起捕捉变化


GGSCI (dbsource) 7> add exttrail dirdat/l1, extract eanbob1, megabytes 100
EXTTRAIL added.

指派eanbob1进程在本地生成trail文件,限制大小为100mb,默认10M,取决于事务大小频繁生成新文件会影响性能

GGSCI (dbsource) 8> start extract eanbob1
Sending START request to MANAGER ...
EXTRACT EANBOB1 starting

启动本地extract进程 
GGSCI (dbsource) 10> info eanbob1

EXTRACT    EANBOB1   Last Started 2012-07-30 22:08   Status RUNNING
Checkpoint Lag       00:01:16 (updated 00:00:02 ago)
Log Read Checkpoint  Oracle Redo Logs
                     2012-07-30 22:06:57  Seqno 11, RBA 8688640
                     SCN 0.0 (0)



用ORACLE自己的工具做INITIAL LOAD,比如EXP,EXPDP 等,也可以用OGG做INITIAL LOAD,这里用EXP
[oracle@dbsource ~]$ exp anbob/anbob file=expanbob.dmp           
Export: Release 10.2.0.1.0 - Production on Mon Jul 30 22:16:47 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. exporting pre-schema procedural objects and actions
. exporting foreign function library names for user ANBOB 
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user ANBOB 
About to export ANBOB's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
. about to export ANBOB's tables via Conventional Path ...
. . exporting table                            OBJ      49745 rows exported
. . exporting table                           SEGS       4116 rows exported
. . exporting table                           TABS       1522 rows exported
. exporting synonyms
...

[oracle@dbsource ~]$ scp expanbob.dmp dbtarget:~
oracle@dbtarget's password: 
expanbob.dmp                                   100% 6264KB   6.1MB/s   00:01  


[oracle@dbtarget ~]$ export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
[oracle@dbtarget ~]$ imp anbob/anbob file=expanbob.dmp        

Import: Release 10.2.0.1.0 - Production on Mon Jul 30 22:53:30 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

Export file created by EXPORT:V10.02.01 via conventional path
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing ANBOB's objects into ANBOB
. . importing table                          "OBJ"      49745 rows imported
. . importing table                         "SEGS"       4116 rows imported
. . importing table                         "TABS"       1522 rows imported
Import terminated successfully without warnings.

三 ,在initial load的过程中源库并未关闭,我们是为了减少down机时间,但这样就会有可能在源库中发生DML 事务
SQL> select object_name from obj where object_id=10;
OBJECT_NAME
--------------------------------------------------------------------------------
c_user#

SQL> update obj set object_name='c_user' where object_id=10;
1 row updated.
SQL> commit;

SQL> insert into tabs (owner,table_name,tablespace_name) values('anbob','ggtest','users');
1 row created.

SQL> commit;

SQL> delete from segs where owner='SYSMAN';
760 rows deleted.

SQL> commit;

GGSCI (dbsource) 3> stats ext eanbob1

Sending STATS request to EXTRACT EANBOB1 ...

Start of Statistics at 2012-07-30 23:01:49.

Output to dirdat/l1:

Extracting from ANBOB.OBJ to ANBOB.OBJ:

*** Total statistics since 2012-07-30 22:56:33 ***
        Total inserts                                      0.00
        Total updates                                      1.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   1.00

*** Daily statistics since 2012-07-30 22:56:33 ***
        Total inserts                                      0.00
        Total updates                                      1.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   1.00

*** Hourly statistics since 2012-07-30 23:00:00 ***

        No database operations have been performed.

*** Latest statistics since 2012-07-30 22:56:33 ***
        Total inserts                                      0.00
        Total updates                                      1.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   1.00

Extracting from ANBOB.TABS to ANBOB.TABS:

*** Total statistics since 2012-07-30 22:56:33 ***
        Total inserts                                      1.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   1.00

*** Daily statistics since 2012-07-30 22:56:33 ***
        Total inserts                                      1.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   1.00

*** Hourly statistics since 2012-07-30 23:00:00 ***
        Total inserts                                      1.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   1.00

*** Latest statistics since 2012-07-30 22:56:33 ***
        Total inserts                                      1.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   1.00

Extracting from ANBOB.SEGS to ANBOB.SEGS:

*** Total statistics since 2012-07-30 22:56:33 ***
        Total inserts                                      0.00
        Total updates                                      0.00
        Total deletes                                    760.00
        Total discards                                     0.00
        Total operations                                 760.00

*** Daily statistics since 2012-07-30 22:56:33 ***
        Total inserts                                      0.00
        Total updates                                      0.00
        Total deletes                                    760.00
        Total discards                                     0.00
        Total operations                                 760.00

*** Hourly statistics since 2012-07-30 23:00:00 ***
        Total inserts                                      0.00
        Total updates                                      0.00
        Total deletes                                    760.00
        Total discards                                     0.00
        Total operations                                 760.00

*** Latest statistics since 2012-07-30 22:56:33 ***
        Total inserts                                      0.00
        Total updates                                      0.00
        Total deletes                                    760.00
        Total discards                                     0.00
        Total operations                                 760.00

End of Statistics.
GGSCI (dbsource) 4> view report eanbob1

注意没有索引时会用表中的所有列
Wildcard TABLE resolved (entry anbob.*):
  table "ANBOB"."OBJ";

2012-07-30 22:56:33  WARNING OGG-00869  No unique key is defined for table 'OBJ'. All viable columns will be used to represent the key, but
 may not guarantee uniqueness.  KEYCOLS may be used to define the key.
Using the following key columns for source table ANBOB.OBJ: OWNER, OBJECT_NAME, SUBOBJECT_NAME, OBJECT_ID, DATA_OBJECT_ID, OBJECT_TYPE, CRE
ATED, LAST_DDL_TIME, TIMESTAMP, STATUS, TEMPORARY, GENERATED, SECONDARY.

Wildcard TABLE resolved (entry anbob.*):
  table "ANBOB"."TABS";
Using the following key columns for source table ANBOB.TABS: OWNER, TABLE_NAME.

[oracle@dbsource oggsoft]$ ll dirdat
total 244
-rw-rw-rw- 1 oracle oinstall 242082 Jul 30 23:00 l1000000

目标机配置mgr进程
GGSCI (dbtarget) 1> edit params mgr
port 8000
purgeoldextracts dirdat/*, usecheckpoints, minkeepdays 2

这里有个要说明的地方,最后一行就是为了防止trail文件无限增加,而自动清理已应用的trail文件,最小保留已应用后的两天

GGSCI (dbtarget) 1> start mgr
GGSCI (dbtarget) 1> info mgr
Manager is running (IP port dbtarget.8000).



源机配置data-pump extract 开始传送TRAIL文件
GGSCI (dbsource) 2> edit params pbanbob1
extract pbanbob1
--------------------------------------
-- data pump extract for anbob schema
--------------------------------------
passthru

rmtHost dbtarget, mgrport 8000
rmtTrail dirdat/l2
table anbob.*;

GGSCI (dbsource) 3> add extract pbanbob1, exttrailsource dirdat/l1
EXTRACT added.

GGSCI (dbsource) 4> add rmttrail dirdat/l2, extract pbanbob1, megabytes 100
RMTTRAIL added.


GGSCI (dbsource) 2> start ext pbanbob1

Sending START request to MANAGER ...
EXTRACT PBANBOB1 starting


GGSCI (dbsource) 3> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     RUNNING     EANBOB1     00:00:00      00:00:00    
EXTRACT     RUNNING     PBANBOB1    00:00:00      00:18:38    


开始发现pbanbob1并没有传送,没关系,可以重新传送
GGSCI (dbsource) 42>stop ext pbanbob1

GGSCI (dbsource) 42> alter extract pbanbob1, exttrailsource dirdat/l1,begin 2012-07-30 22:06
EXTRACT altered.

GGSCI (dbsource) 43> start ext pbanbob1

Sending START request to MANAGER ...
EXTRACT PBANBOB1 starting   

GGSCI (dbsource) 46> stats ext pbanbob1

Sending STATS request to EXTRACT PBANBOB1 ...

Start of Statistics at 2012-07-31 22:17:24.

Output to dirdat/l2:

Extracting from ANBOB.OBJ to ANBOB.OBJ:

*** Total statistics since 2012-07-31 22:17:12 ***
        Total inserts                                      0.00
        Total updates                                      2.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   2.00

*** Daily statistics since 2012-07-31 22:17:12 ***
        Total inserts                                      0.00
        Total updates                                      2.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   2.00

*** Hourly statistics since 2012-07-31 22:17:12 ***
        Total inserts                                      0.00
        Total updates                                      2.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   2.00

*** Latest statistics since 2012-07-31 22:17:12 ***
        Total inserts                                      0.00
        Total updates                                      2.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   2.00

Extracting from ANBOB.TABS to ANBOB.TABS:

*** Total statistics since 2012-07-31 22:17:12 ***
        Total inserts                                      1.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   1.00

*** Daily statistics since 2012-07-31 22:17:12 ***
        Total inserts                                      1.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   1.00

*** Hourly statistics since 2012-07-31 22:17:12 ***
        Total inserts                                      1.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   1.00

*** Latest statistics since 2012-07-31 22:17:12 ***
        Total inserts                                      1.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   1.00

Extracting from ANBOB.SEGS to ANBOB.SEGS:

*** Total statistics since 2012-07-31 22:17:12 ***
        Total inserts                                      0.00
        Total updates                                      0.00
        Total deletes                                    760.00
        Total discards                                     0.00
        Total operations                                 760.00

*** Daily statistics since 2012-07-31 22:17:12 ***
        Total inserts                                      0.00
        Total updates                                      0.00
        Total deletes                                    760.00
        Total discards                                     0.00
        Total operations                                 760.00

*** Hourly statistics since 2012-07-31 22:17:12 ***
        Total inserts                                      0.00
        Total updates                                      0.00
        Total deletes                                    760.00
        Total discards                                     0.00
        Total operations                                 760.00

*** Latest statistics since 2012-07-31 22:17:12 ***
        Total inserts                                      0.00
        Total updates                                      0.00
        Total deletes                                    760.00
        Total discards                                     0.00
        Total operations                                 760.00

End of Statistics.

GGSCI (dbsource) 9> view report pbanbob1
 
...

2012-07-31 22:17:12  INFO    OGG-01055  Recovery initialization completed for target file dirdat/l2000002, at RBA 1192.

2012-07-31 22:17:12  INFO    OGG-01478  Output file dirdat/l2 is using format RELEASE 11.2.

2012-07-31 22:17:12  INFO    OGG-01026  Rolling over remote file dirdat/l2000003.

2012-07-31 22:17:12  INFO    OGG-01053  Recovery completed for target file dirdat/l2000003, at RBA 1171.

2012-07-31 22:17:12  INFO    OGG-01057  Recovery completed for all targets.
....


去目标机器上验证一下文件
[oracle@dbtarget ogg11]$ ll dirdat
total 256
-rw-rw-rw- 1 oracle oinstall   1107 Jul 31 22:12 l2000000
-rw-rw-rw- 1 oracle oinstall   1212 Jul 31 22:14 l2000001
-rw-rw-rw- 1 oracle oinstall   1192 Jul 31 22:17 l2000002
-rw-rw-rw- 1 oracle oinstall 242854 Jul 31 22:17 l2000003


已成功传到目标机器dbatrget,也可以用strings OS Utilities 查看一下文件内容,前提是没有加密的话,trail文件可以加密,方法是抽取extract参数文件加ENCRYPTTRAIL,传送extract参数加

DECRYPTTRAIL,ENCRYPTTRAIL,应用replicat进程加DECRYPTTRAIL

五,配置replicat开始应用trail文件

GGSCI (dbtarget) 1> edit params ranbob1

replicat ranbob1
--------------------------------
-- replicat for anbob schema
-------------------------------
SETENV (NLS_LANG = AMERICAN_AMERICA.ZHS16GBK)
userid system, password "AACAAAAAAAAAAAGAIFAAUDVHCFUGFIYF", encryptkey default

handlecollisions
AssumeTargetDefs
ReportCount Every 30 Minutes, Rate
Report at 01:00
ReportRollover at 01:15
DiscardFile dirrpt/ranbob1.dsc, Append
DiscardRollover at 02:00 ON SUNDAY
Map anbob.*, Target anbob.* ;

应用trail参数handlecollisions,表时让OGG自动处理冲突的记录,当update,delete的记录不存在时忽略,insert数据已存在时update



GGSCI (dbtarget) 10> add replicat ranbob1, exttrail dirdat/l2  CHECKPOINTTABLE system.chkpt
REPLICAT added.

GGSCI (dbtarget) 13> dblogin userid system password oracle
Successfully logged into database.

GGSCI (dbtarget) 15> add checkpointtable system.chkpt

Successfully created checkpoint table system.chkpt.


GGSCI (dbtarget) 5> info checkpointtable system.chkpt

Checkpoint table system.chkpt created 2012-07-31 00:07:03.

SQL> desc system.chkpt
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 GROUP_NAME                                NOT NULL VARCHAR2(8)
 GROUP_KEY                                 NOT NULL NUMBER(19)
 SEQNO                                              NUMBER(10)
 RBA                                       NOT NULL NUMBER(19)
 AUDIT_TS                                           VARCHAR2(29)
 CREATE_TS                                 NOT NULL DATE
 LAST_UPDATE_TS                            NOT NULL DATE
 CURRENT_DIR                               NOT NULL VARCHAR2(255)
 LOG_CSN                                            VARCHAR2(129)
 LOG_XID                                            VARCHAR2(129)
 LOG_CMPLT_CSN                                      VARCHAR2(129)
 LOG_CMPLT_XIDS                                     VARCHAR2(2000)
 VERSION                                            NUMBER(3)

SQL> select * from system.chkpt;

no rows selected

GGSCI (dbtarget) 2> start replicat ranbob1

Sending START request to MANAGER ...
REPLICAT RANBOB1 starting

GGSCI (dbtarget) 4> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
REPLICAT    RUNNING     RANBOB1     00:00:00      00:00:06    

sys@ANBOBS> select group_name,seqno,rba,last_update_ts,log_csn,log_cmplt_csn,current_dir from system.chkpt;

GROUP_NA      SEQNO        RBA LAST_UPDATE_TS      LOG_CSN    LOG_CMPLT_CSN        CURRENT_DIR
-------- ---------- ---------- ------------------- ---------- -------------------- ------------------------------
RANBOB1           3     242854 2012-07-31 22:49:50 564765     564765               /u01/app/oracle/ogg11

GGSCI (dbtarget) 1> stats replicat ranbob1

Sending STATS request to REPLICAT RANBOB1 ...

Start of Statistics at 2012-07-31 23:12:07.

Replicating from ANBOB.OBJ to ANBOB.OBJ:

*** Total statistics since 2012-07-31 22:49:48 ***
        Total inserts                                      0.00
        Total updates                                      2.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   2.00

*** Daily statistics since 2012-07-31 22:49:48 ***
        Total inserts                                      0.00
        Total updates                                      2.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   2.00

*** Hourly statistics since 2012-07-31 23:00:00 ***

        No database operations have been performed.

*** Latest statistics since 2012-07-31 22:49:48 ***
        Total inserts                                      0.00
        Total updates                                      2.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   2.00

Replicating from ANBOB.TABS to ANBOB.TABS:

*** Total statistics since 2012-07-31 22:49:48 ***
        Total inserts                                      1.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   1.00

*** Daily statistics since 2012-07-31 22:49:48 ***
        Total inserts                                      1.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   1.00

*** Hourly statistics since 2012-07-31 23:00:00 ***

        No database operations have been performed.

*** Latest statistics since 2012-07-31 22:49:48 ***
        Total inserts                                      1.00
        Total updates                                      0.00
        Total deletes                                      0.00
        Total discards                                     0.00
        Total operations                                   1.00

Replicating from ANBOB.SEGS to ANBOB.SEGS:

*** Total statistics since 2012-07-31 22:49:48 ***
        Total inserts                                      0.00
        Total updates                                      0.00
        Total deletes                                    760.00
        Total discards                                     0.00
        Total operations                                 760.00

*** Daily statistics since 2012-07-31 22:49:48 ***
        Total inserts                                      0.00
        Total updates                                      0.00
        Total deletes                                    760.00
        Total discards                                     0.00
        Total operations                                 760.00

*** Hourly statistics since 2012-07-31 23:00:00 ***

        No database operations have been performed.

*** Latest statistics since 2012-07-31 22:49:48 ***
        Total inserts                                      0.00
        Total updates                                      0.00
        Total deletes                                    760.00
        Total discards                                     0.00
        Total operations                                 760.00

End of Statistics.

GGSCI (dbtarget) 3> info replicat ranbob1, detail

REPLICAT   RANBOB1   Last Started 2012-07-31 22:49   Status RUNNING
Checkpoint Lag       00:00:00 (updated 00:00:07 ago)
Log Read Checkpoint  File dirdat/l2000003
                     2012-07-31 22:03:09.902105  RBA 242854

  Extract Source                          Begin             End             

  dirdat/l2000003                         * Initialized *   2012-07-31 22:03
  dirdat/l2000000                         * Initialized *   First Record    
  dirdat/l2000000                         * Initialized *   First Record    


Current directory    /u01/app/oracle/ogg11

Report file          /u01/app/oracle/ogg11/dirrpt/RANBOB1.rpt
Parameter file       /u01/app/oracle/ogg11/dirprm/ranbob1.prm
Checkpoint file      /u01/app/oracle/ogg11/dirchk/RANBOB1.cpr
Checkpoint table     system.chkpt
Process file         /u01/app/oracle/ogg11/dirpcs/RANBOB1.pcr
Stdout file          /u01/app/oracle/ogg11/dirout/RANBOB1.out
Error log            /u01/app/oracle/ogg11/ggserr.log

在源端验证一下数据库记录
anbob@ANBOBS> select object_name from obj where object_id=10
  2  ;

OBJECT_NAME
-------------------------------------------------------------
c_user

anbob@ANBOBS> select owner,tablespace_name from tabs where table_name='ggtest';

OWNER                          TABLESPACE_NAME
------------------------------ ------------------------------
anbob                          users

anbob@ANBOBS> select count(*) from  segs where owner='SYSMAN'
  2  ;

  COUNT(*)
----------
         0

应用没有问题,已同步了exp后发生的变化

测试一下适时应用会有多长时间的延时
23:26:32 anbob@prod>update obj set object_name='anbob'||10 where owner='SCOTT';

6 rows updated.

Elapsed: 00:00:00.02
23:27:24 anbob@prod>COMMIT;

Commit complete.

Elapsed: 00:00:00.00
23:27:27 anbob@prod>


23:27:32 anbob@ANBOBS> SELECT OBJECT_NAME FROM OBJ WHERE owner='SCOTT';

OBJECT_NAME
-------------------------------
anbob10
anbob10
anbob10
anbob10
anbob10
anbob10

6 rows selected.

23:27:34 anbob@ANBOBS> 

看到 23:27:27 在源库做的提交有6条数据,在目标库23:27:34秒同步成功,用了有6秒时间,OGG是以CSN为顺序,也就是COMMIT 的事务,当然优化的余地要不然OGG就不说是压秒级了。

打赏

对不起,这篇文章暂时关闭评论。