ORACLE 之间的OGG配置

OGG source和target环境:

souce

source端:
操作系统版本:Linux  2.6.9-89.EL x86_64
hostname:dg1

数据库版本:10.2.0.1 64bit

ogg版本:fbo_ggs_Linux_x64_ora10g_64bit.tar
rac数据库名:WENDING

IP:192.168.1.1

target端:

操作系统版本:Linux  2.6.9-89.EL x86_64
hostname:dg2

数据库版本:10.2.0.1 64bit

ogg版本:fbo_ggs_Linux_x64_ora10g_64bit.tar
rac数据库名:PHYSTDBY

IP:192.168.1.2



一、安装OGG软件(source和target同样操作)

[root@dg1 oracle]# pwd
/home/oracle
[root@dg1 oracle]# ls -l
total 8
drwxr-xr-x  2 oracle oinstall 4096 Oct  6  2012 Desktop
-rw-r--r--  1 oracle oinstall 1386 Oct  3  2012 sqlnet.log
[root@dg1 oracle]# mkdir gg_install
[root@dg1 oracle]# pwd
/home/oracle
[root@dg1 oracle]# cd gg_install/
[root@dg1 gg_install]# pwd
/home/oracle/gg_install
[root@dg1 gg_install]# ls
ogg112101_fbo_ggs_Linux_x64_ora10g_64bit.zip
[root@dg1 gg_install]# ll
total 86820
-rw-r--r--  1 root root 88807353 Nov  5 15:54 ogg112101_fbo_ggs_Linux_x64_ora10g_64bit.zip
[root@dg1 gg_install]# cd ..
[root@dg1 oracle]# ls
Desktop  gg_install  sqlnet.log
[root@dg1 oracle]# ls -l
total 12
drwxr-xr-x  2 oracle oinstall 4096 Oct  6  2012 Desktop
drwxr-xr-x  2 root   root     4096 Nov  5 15:53 gg_install
-rw-r--r--  1 oracle oinstall 1386 Oct  3  2012 sqlnet.log
[root@dg1 oracle]# chown -R oracleinstall gg_install/
[root@dg1 oracle]# ll
total 12
drwxr-xr-x  2 oracle oinstall 4096 Oct  6  2012 Desktop
drwxr-xr-x  2 oracle oinstall 4096 Nov  5 15:53 gg_install
-rw-r--r--  1 oracle oinstall 1386 Oct  3  2012 sqlnet.log
[root@dg1 oracle]# cd gg_install/
[root@dg1 gg_install]# ls
ogg112101_fbo_ggs_Linux_x64_ora10g_64bit.zip
[root@dg1 gg_install]# ls -l
total 86820
-rw-r--r--  1 oracle oinstall 88807353 Nov  5 15:54 ogg112101_fbo_ggs_Linux_x64_ora10g_64bit.zip
[root@dg1 gg_install]# pwd
/home/oracle/gg_install
[root@dg1 gg_install]# su - oracle
[oracle@dg1 ~]$ cd /home/oracle/gg_install
[oracle@dg1 gg_install]$ ll
total 86820
-rw-r--r--  1 oracle oinstall 88807353 Nov  5 15:54 ogg112101_fbo_ggs_Linux_x64_ora10g_64bit.zip
[oracle@dg1 gg_install]$ unzip ogg112101_fbo_ggs_Linux_x64_ora10g_64bit.zip
Archive:  ogg112101_fbo_ggs_Linux_x64_ora10g_64bit.zip
  inflating: fbo_ggs_Linux_x64_ora10g_64bit.tar  
  inflating: OGG_WinUnix_Rel_Notes_11.2.1.0.1.pdf  
  inflating: Oracle GoldenGate 11.2.1.0.1 README.txt  
  inflating: Oracle GoldenGate 11.2.1.0.1 README.doc  
[oracle@dg1 gg_install]$ ls
fbo_ggs_Linux_x64_ora10g_64bit.tar            OGG_WinUnix_Rel_Notes_11.2.1.0.1.pdf     Oracle GoldenGate 11.2.1.0.1 README.txt
ogg112101_fbo_ggs_Linux_x64_ora10g_64bit.zip  Oracle GoldenGate 11.2.1.0.1 README.doc
[oracle@dg1 gg_install]$ cd ..
[oracle@dg1 ~]$ mkdir gg
[oracle@dg1 ~]$ ll
total 16
drwxr-xr-x  2 oracle oinstall 4096 Oct  6  2012 Desktop
drwxr-xr-x  2 oracle oinstall 4096 Nov  5 16:02 gg
drwxr-xr-x  2 oracle oinstall 4096 Nov  5 16:02 gg_install
-rw-r--r--  1 oracle oinstall 1386 Oct  3  2012 sqlnet.log
[oracle@dg1 gg_install]$ cd ..
[oracle@dg1 ~]$ cd gg
[oracle@dg1 gg]$ tar -xvf ../gg_install/fbo_ggs_Linux_x64_ora10g_64bit.tar
[oracle@dg1 ~]$ vi .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi


# User specific environment and startup programs


PATH=$PATH:$HOME/bin


export PATH
unset USERNAME






export TMP=/tmp
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/
export ORACLE_SID=WENDING
export PATH=$ORACLE_HOME/bin:/usr/sbin:/usr/X11R6/bin:$PATH
export PATH=$PATH:/home/oracle/ogg
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/usr/local/bin
export LD_LIBRARY_PATH=/home/oracle/ogg:$LD_LIBRARY_PATH
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export LIBPATH=$ORACLE_HOME/lib:$ORACLE_HOME/ctx/lib
                                                                              
[oracle@dg1 ~]$ source .bash_profile
[oracle@dg1 lib]$ cd /home/oracle/ogg/
[oracle@dg1 ogg]$ 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 10g on Apr 23 2012 07:30:46


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






GGSCI (dg1) 1> create subdirs


Creating subdirectories under current directory /home/oracle/ogg


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




GGSCI (dg1) 2> exit
[oracle@dg1 ogg]$ ls
bcpfmt.tpl                 ddl_purgeRecyclebin.sql         demo_ora_pk_befores_insert.sql   jagent.sh          prvtclkm.plb
bcrypt.txt                 ddl_remove.sql                  demo_ora_pk_befores_updates.sql  keygen             pw_agent_util.sh
cfg                        ddl_session1.sql                dirchk                           libantlr3c.so      remove_seq.sql
chkpt_ora_create.sql       ddl_session.sql                 dirdat                           libdb-5.2.so       replicat
cobgen                     ddl_setup.sql                   dirdef                           libgglog.so        retrace
convchk                    ddl_status.sql                  dirjar                           libggrepo.so       reverse
db2cntl.tpl                ddl_staymetadata_off.sql        dirout                           libicudata.so.38   role_setup.sql
ddl_cleartrace.sql         ddl_staymetadata_on.sql         dirpcs                           libicui18n.so.38   sequence.sql
ddlcob                     ddl_tracelevel.sql              dirprm                           libicuuc.so.38     server
ddl_ddl2file.sql           ddl_trace_off.sql               dirrpt                           libxerces-c.so.28  sqlldr.tpl
ddl_disable.sql            ddl_trace_on.sql                dirsql                           libxml2.txt        tcperrs
ddl_enable.sql             defgen                          dirtmp                           logdump            ucharset.h
ddl_filter.sql             demo_more_ora_create.sql        emsclnt                          marker_remove.sql  ulg.sql
ddl_nopurgeRecyclebin.sql  demo_more_ora_insert.sql        extract                          marker_setup.sql   UserExitExamples
ddl_ora10.sql              demo_ora_create.sql             freeBSD.txt                      marker_status.sql  usrdecs.h
ddl_ora10upCommon.sql      demo_ora_insert.sql             ggcmd                            mgr                zlib.txt
ddl_ora11.sql              demo_ora_lob_create.sql         ggMessage.dat                    notices.txt
ddl_ora9.sql               demo_ora_misc.sql               ggsci                            oggerr
ddl_pin.sql                demo_ora_pk_befores_create.sql  help.txt                         params.sql

二、创建OGG用户并测试用户并创建测试表(source和target同样操作)

[oracle@dg1 ogg]$ sqlplus "/ as sysdba"


SQL*Plus: Release 10.2.0.1.0 - Production on Tue Nov 5 16:24:06 2013


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




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


SQL> select name from v$datafiles;           
select name from v$datafiles
                 *
ERROR at line 1:
ORA-00942: table or view does not exist




SQL> select name from v$datafile;


NAME
--------------------------------------------------------------------------------
/u01/oracle/oradata/ORCLDB/system01.dbf
/u01/oracle/oradata/ORCLDB/undotbs01.dbf
/u01/oracle/oradata/ORCLDB/sysaux01.dbf
/u01/oracle/oradata/ORCLDB/users01.dbf
/u01/oracle/oradata/gaojia.dbf


SQL> create tablespace ogg datafile '/u01/oracle/oradata/ORCLDB/ogg01.dbf' size 1024m;           


Tablespace created.


SQL> create user ogg identified by ogg default tablespace ogg;


User created.


SQL> grant connect,resource,dba to ogg;


Grant succeeded.


SQL> GRANT CREATE DATABASE LINK TO ogg;                           
GRANT CREATE SYNONYM TO ogg;                                                              
GRANT CREATE VIEW TO ogg;                           


Grant succeeded.


SQL>
Grant succeeded.


GRANT CREATE job TO ogg;                           
SQL>
Grant succeeded.


SQL> GRANT CREATE ANY MATERIALIZED VIEW TO ogg;                           
GRANT CREATE ANY DIRECTORY TO ogg;
Grant succeeded.


SQL>
Grant succeeded.


SQL>


Grant succeeded.


SQL>
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/oracle/arch1/WENDING
Oldest online log sequence     0
Next log sequence to archive   1
Current log sequence           1
SQL> select supplemental_log_data_min from v$database;


SUPPLEME
--------
NO


SQL> alter database add supplemental log data;


Database altered.


SQL> select supplemental_log_data_min from v$database;


SUPPLEME
--------
YES


SQL> SELECT force_logging FROM v$database;


FOR
---
YES


SQL> select supplemental_log_data_min from v$database;


SUPPLEME
--------
YES


SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options


SQL*Plus: Release 10.2.0.1.0 - Production on Tue Nov 5 17:38:43 2013


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




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


SQL> create user zwp identified by zwp;


User created.


SQL> grant resource,connect to zwp;


Grant succeeded.


SQL> conn zwp/zwp;
Connected.
SQL> create table zwp_test (id number,name varchar2(10));


Table created.

SQL> alter table zwp_test add constraint zwp_test_pk primary key (id);


Table altered.


SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

三、source和target端配置manager进程:

[oracle@dg1 ogg]$ ggsci
`q
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 10g on Apr 23 2012 07:30:46


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






GGSCI (dg1) 1> edit param mgr

GGSCI (dg1) 2> edit params MGR

port 7809
dynamicportlist 7815-7850
autorestart er *, retries 5, waitminutes 3
purgeoldextracts ./dirdat/*,usecheckpoints, minkeepdays 7


LAGREPORTHOURS 1
LAGINFOMINUTES 30
LAGCRITICALMINUTES 45

"dirprm/mgr.prm" [New] 8L, 195C written




GGSCI (dg1) 3> start mgr


Manager started.




GGSCI (dg1) 4> info mgr


Manager is running (IP port dg1.7809).




GGSCI (dg1) 5> info all


Program     Status      Group       Lag at Chkpt  Time Since Chkpt


MANAGER     RUNNING                                          




GGSCI (dg1) 6>


GGSCI (dg1) 6>


GGSCI (dg1) 6> exit


四、source端配置extract进程和DATA PUMP进程

[oracle@dg1 ogg]$ 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 10g on Apr 23 2012 07:30:46


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


GGSCI (dg1) 4> add extract ggtest,tranlog,begin now
EXTRACT added.




GGSCI (dg1) 5> add exttrail ./dirdat/source, extract ggtest, megabutes 100
ERROR: file portion must be two characters.




GGSCI (dg1) 6> add exttrail ./dirdat/et, extract ggtest, megabutes 100
ERROR: Unrecognized argument MEGABUTES.




GGSCI (dg1) 7> add exttrail ./dirdat/et, extract ggtest, megabytes 100
EXTTRAIL added.




GGSCI (dg1) 8> edit params ggtest

extract ggtest
SETENV (ORACLE_SID="WENDING"
SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
USERID ogg , PASSWORD ogg
TRANLOGOPTIONS CONVERTUCS2CLOBS
EXTTRAIL ./dirdat/et
NUMFILES 3000
EOFDELAYCSECS 30
GETTRUNCATES
DYNAMICRESOLUTION
DBOPTIONS ALLOWUNUSEDCOLUMN
FETCHOPTIONS NOUSESNAPSHOT
FETCHOPTIONS SUPPRESSDUPLICATES
FETCHOPTIONS FETCHPKUPDATECOLS
WARNLONGTRANS 3H, CHECKINTERVAL 3M
TABLE  zwp.zwp_test;

"dirprm/ggtest.prm" [New] 17L, 412C written

GGSCI (dg1) 9> add extract ggpump,exttrailsource ./dirdat/et
EXTRACT added.




GGSCI (dg1) 10> add rmttrail ./dirdat/pp,extract ggpump,megabytes 100
RMTTRAIL added.




GGSCI (dg1) 11> edit param ggpump

extract ggpump
SETENV (ORACLE_SID="WENDING"
SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
EOFDELAYCSECS 30
RMTHOST  192.168.1.2,MGRPORT 7809, TCPBUFSIZE 100000, TCPFLUSHBYTES 300000
rmttrail ./dirdat/pp
PASSTHRU
DYNAMICRESOLUTION
TABLE  zwp.*;

"dirprm/ggpump.prm" [New] 9L, 243C written

五、Target端配置replicate进程

[oracle@dg2 ogg]$ 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 10g on Apr 23 2012 07:30:46


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






GGSCI (dg2) 1> add checkpoint ogg.checkpoint
ERROR: Invalid command.


GGSCI (dg2) 2> add checkpointtable ogg.checkpoint
ERROR: Not logged into database, use DBLOGIN.

GGSCI (dg2) 5> dblogin userid ogg, password ogg
Successfully logged into database.


GGSCI (dg2) 6> add checkpointtable ogg.checkpoint


Successfully created checkpoint table ogg.checkpoint.


GGSCI (dg2) 7> add replicat reptest,exttrail ./dirdat/pp,checkpointtable ogg.checkpoint
REPLICAT added.

GGSCI (dg2) 8> edit param reptest

replicat reptest
SETENV (ORACLE_SID="PHYSTDBY"
SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
USERID ogg , PASSWORD ogg
sqlexec "Alter session set commit_write=nowait"
REPORT AT 01:59
REPORTROLLOVER AT 02:00
REPERROR DEFAULT,ABEND
DISCARDFILE ./dirrpt/reptest.dsc,append,megabytes 100
DISCARDROLLOVER AT 06:00
ASSUMETARGETDEFS
ALLOWNOOPUPDATES
DYNAMICRESOLUTION
NUMFILES 3000
EOFDELAYCSECS 30
GETTRUNCATES
BATCHSQL BATCHESPERQUEUE 200,OPSPERBATCH 2000
MAP zwp.zwp_test, TARGET zwp.zwp_test;

六、开启source端和target端的OGG后台进程

GGSCI (dg1) 2> info all


Program     Status      Group       Lag at Chkpt  Time Since Chkpt


MANAGER     RUNNING                                          
EXTRACT     STOPPED     GGPUMP      00:00:00      00:37:08   
EXTRACT     STOPPED     GGTEST      00:00:00      01:00:35   

GGSCI (dg1) 3> start ggtest


Sending START request to MANAGER ...
EXTRACT GGTEST starting
GGSCI (dg1) 4> start ggpump
Sending START request to MANAGER ...
EXTRACT GGPUMP starting



GGSCI (dg1) 7> info all


Program     Status      Group       Lag at Chkpt  Time Since Chkpt


MANAGER     RUNNING                                          
EXTRACT     RUNNING     GGPUMP      00:00:00      00:00:09   
EXTRACT     RUNNING     GGTEST      00:00:00      00:00:02

GGSCI (dg2) 9> info all


Program     Status      Group       Lag at Chkpt  Time Since Chkpt


MANAGER     RUNNING                                          
REPLICAT    STOPPED     REPTEST     00:00:00      00:07:42   




GGSCI (dg2) 10> start reptest


Sending START request to MANAGER ...
REPLICAT REPTEST starting
GGSCI (dg2) 2> info all


Program     Status      Group       Lag at Chkpt  Time Since Chkpt


MANAGER     RUNNING                                          
REPLICAT    RUNNING     REPTEST     00:00:00      00:00:03


七、确认同步情况

source端

[oracle@dg1 ogg]$ sqlplus zwp/zwp


SQL*Plus: Release 10.2.0.1.0 - Production on Tue Nov 5 21:46:01 2013


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




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


SQL> insert into zwp_test values (1,'zwp1');


1 row created.


SQL> insert into zwp_test values (2,'zwp2');


1 row created.


SQL> commit;


Commit complete.


SQL> insert into zwp_test values (3,'zwp3');


1 row created.


SQL> commit;


Commit complete.

Target端

[oracle@dg2 ogg]$ sqlplus "/ as sysdba"


SQL*Plus: Release 10.2.0.1.0 - Production on Tue Nov 5 21:48:02 2013


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




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


SQL> conn zwp/zwp
Connected.
SQL> select * from zwp_test;


        ID NAME
---------- ----------
         1 zwp1
         2 zwp2


SQL> /


        ID NAME
---------- ----------
         1 zwp1
         2 zwp2
         3 zwp3


SQL> /


        ID NAME
---------- ----------
         1 zwp1
         2 zwp2
         3 zwp3
从上面可以看出同步成功。

你可能感兴趣的:(ORACLE 之间的OGG配置)