ogg实施(一),OGG安装、初始化

环境:

源数据库:实例名:source

                        DB版本:11.2.0.4.0

                        OGG版本:Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO

                        字符集:ZHS16GBK

                        主机名:ser1


目标数据库:实例名:target

                        DB版本:11.2.0.4.0

                        OGG版本:Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO

                        字符集:ZHS16GBK

                        主机名:ser2


oracle环境变量中添加:export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib



ogg安装:

ser1、ser2全部执行

[oracle@ser1 u01]$ mkdir ogg
[oracle@ser1 u01]$
[oracle@ser1 u01]$ cd ogg
[oracle@ser1 ogg]$
[oracle@ser1 ogg]$ cp /tmp/ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip .
[oracle@ser1 ogg]$
[oracle@ser1 ogg]$ unzip ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip
Archive:  ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip
  inflating: fbo_ggs_Linux_x64_ora11g_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@ser1 ogg]$
[oracle@ser1 ogg]$ tar xvf fbo_ggs_Linux_x64_ora11g_64bit.tar
UserExitExamples/
UserExitExamples/ExitDemo_more_recs/

…………

ulg.sql
usrdecs.h
zlib.txt
[oracle@ser1 ogg]$

[oracle@ser1 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 11g on Apr 23 2012 08:32:14

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

GGSCI (ser1) 1> create subdirs

Creating subdirectories under current directory /u01/ogg

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

GGSCI (ser1) 2>


OGG安装完成……



建立OGG用户,并授权。

ser1:

sys用户执行:
SQL> create user ogg identified by ogg;     --正式环境可以使用单独的表空间。此处为测试环境。

User created.

SQL> grant connect,resource to ogg;         --单独赋权dba,在执行ddl复制的配置脚本时可能会报错。

Grant succeeded.

SQL> grant create session,alter session to ogg;


Grant succeeded.

SQL> grant select any dictionary,select any table to ogg;

Grant succeeded.

SQL> grant alter any table to ogg;

Grant succeeded.

SQL> grant flashback any table to ogg;


Grant succeeded.

SQL> grant EXECUTE on DBMS_FLASHBACK to ogg;

Grant succeeded.

SQL> select SUPPLEMENTAL_LOG_DATA_MIN from v$database;

SUPPLEME
--------

NO


SQL>  alter database add supplemental log data;

Database altered.


SQL> alter database force logging;

Database altered.

SQL> alter system switch logfile;

System altered.

SQL> conn hr/hr   -------------初始化测试数据,也可以通过ogg自带脚本生成(demo_ora_createdemo_ora_insert
Connected.
SQL>
SQL> create table t1 (id number,name varchar2(16));

Table created.

SQL> alter table t1 add constraint pk_t1 primary key (id);

Table altered.

SQL> insert into t1 values (1,'kk');

1 row created.

SQL> insert into t1 values (2,'tom');

1 row created.

SQL> insert into t1 values (3,'jack');

1 row created.

SQL> commit;

Commit complete.

SQL> select * from t1;

        ID NAME
---------- ----------------
         1 kk
         2 tom
         3 jack

SQL>



ser2:建立ogg用户、赋权、建测试表。

SQL> conn / as sysdba

SQL> create user ogg identified by ogg;

User created.

SQL> grant connect ,resource to ogg;

Grant succeeded.

SQL> grant create session,alter session to ogg;

Grant succeeded.

SQL> grant select any dictionary,select any table to ogg;


Grant succeeded.

SQL> grant create table to ogg;


Grant succeeded.

SQL>  alter database add supplemental log data;

Database altered.

SQL>  alter database force logging;

Database altered.

SQL> alter system switch logfile;

System altered.

SQL> conn hr/hr

SQL> create table t1 (id number,name varchar2(16));

Table created.

SQL> alter table t1 add constraint pk_t1 primary key (id);


Table altered.

SQL> conn / as sysdba
SQL> grant insert ,update,delete on hr.t1 to ogg;


Grant succeeded.

SQL>



ser1:开启测试表补充日志

GGSCI (ser1) 2> dblogin userid ogg,password ogg


Successfully logged into database.

GGSCI (ser1) 3> add trandata hr.t1

Logging of supplemental redo data enabled for table HR.T1.



ser1:配置mgr进程

GGSCI (ser1) 4> edit params mgr

port 7809
purgeoldextracts /u01/ogg/dirdat,usecheckpoints

~

~

"dirprm/mgr.prm" [New] 2L, 58C written

GGSCI (ser1) 5> start mgr

Manager started.

GGSCI (ser1) 6> info mgr

Manager is running (IP port ser1.7809).

GGSCI (ser1) 7>



ser2:配置mgr进程

GGSCI (ser2) 1> edit params mgr


port 7809
purgeoldextracts /u01/ogg/dirdat,usecheckpoints

~

~

"dirprm/mgr.prm" [New] 2L, 58C written

GGSCI (ser2) 2> start mgr

Manager started.

GGSCI (ser2) 3> info mgr

Manager is running (IP port ser2.7809).

GGSCI (ser2) 4>


ser1:配置初始化extract进程,初始化有多种方式,同样可以使用数据泵等方式实现。

GGSCI (ser1) 7> add extract eini_1,sourceistable
EXTRACT added.

GGSCI (ser1) 8> info extract *,tasks

EXTRACT                                  EINI_1                Initialized   2016-04-05 17:21   Status STOPPED
Checkpoint Lag                       Not Available
Log Read Checkpoint            Not Available
                     First Record         Record 0
Task                 SOURCEISTABLE

GGSCI (ser1) 9> edit params eini_1
EXTRACT EINI_1
SETENV (NLS_LANG= AMERICAN_AMERICA.ZHS16GBK)
USERID ogg, PASSWORD ogg
RMTHOST 192.168.93.129, MGRPORT 7809            --ip地址可以通过服务名实现
RMTTASK REPLICAT, GROUP RINI_1
TABLE hr.t1;

~
~
"dirprm/eini_1.prm" [New] 6L, 166C written

GGSCI (ser1) 10>



ser2:配置初始化相应的replicat进程,该进程随源数据库extract进程自动启动。

GGSCI (ser2) 4> add replicat rini_1,specialrun


REPLICAT added.

GGSCI (ser2) 5> info replicat *,tasks

REPLICAT   RINI_1    Initialized   2016-04-05 17:26   Status STOPPED
Checkpoint Lag       00:00:00 (updated 00:00:08 ago)
Log Read Checkpoint  Not Available
Task                 SPECIALRUN


GGSCI (ser2) 6> edit params rini_1


REPLICAT RINI_1
SETENV (NLS_LANG= AMERICAN_AMERICA.ZHS16GBK)
ASSUMETARGETDEFS
USERID ogg, PASSWORD ogg
DISCARDFILE ./dirrpt/RINIaa.dsc, PURGE
MAP hr.t1, TARGET hr.t1;

~
~
"dirprm/rini_1.prm" [New] 6L, 167C written


ser1:启动初始化extract进程

GGSCI (ser1) 15> start extract eini_1

Sending START request to MANAGER ...
EXTRACT EINI_1 starting

GGSCI (ser1) 17> view report eini_1


2016-04-05 17:37:54  INFO    OGG-01017  Wildcard resolution set to IMMEDIATE because SOURCEISTABLE is us
ed.

***********************************************************************
                 Oracle GoldenGate Capture 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:42:16
 
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.


                    Starting at 2016-04-05 17:37:54
***********************************************************************

Operating System Version:
Linux
Version #1 SMP Wed Feb 22 17:37:40 EST 2012, Release 2.6.32-300.10.1.el5uek
Node: ser1
Machine: x86_64
                         soft limit   hard limit
Address Space Size   :    unlimited    unlimited
Heap Size            :    unlimited    unlimited
File Size            :    unlimited    unlimited
CPU Time             :    unlimited    unlimited

Process id: 5302

Description:

***********************************************************************
**            Running with the following parameters                  **
***********************************************************************

2016-04-05 17:37:54  INFO    OGG-03035  Operating system character set identified as UTF-8. Locale: en_U
S, LC_ALL:.
EXTRACT EINI_1
SETENV (NLS_LANG= AMERICAN_AMERICA.ZHS16GBK)
Set environment variable (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)
USERID ogg, PASSWORD ***
RMTHOST 192.168.93.129, MGRPORT 7809
RMTTASK REPLICAT, GROUP RINI_1
TABLE hr.t1;
Using the following key columns for source table HR.T1: ID.


2016-04-05 17:37:55  INFO    OGG-01815  Virtual Memory Facilities for: COM
    anon alloc: mmap(MAP_ANON)  anon free: munmap
    file alloc: mmap(MAP_SHARED)  file free: munmap
    target directories:
    /u01/ogg/dirtmp.

CACHEMGR virtual memory values (may have been adjusted)
CACHESIZE:                               64G
CACHEPAGEOUTSIZE (normal):                8M
PROCESS VM AVAIL FROM OS (min):         128G
CACHESIZEMAX (strict force to disk):     96G

Database Version:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE    11.2.0.4.0      Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

Database Language and Character Set:
NLS_LANG         = "AMERICAN_AMERICA.ZHS16GBK"
NLS_LANGUAGE     = "AMERICAN"
NLS_TERRITORY    = "AMERICA"
NLS_CHARACTERSET = "ZHS16GBK"

Processing table HR.T1

***********************************************************************
*                   ** Run Time Statistics **                         *
***********************************************************************


Report at 2016-04-05 17:38:03 (activity since 2016-04-05 17:37:55)

Output to RINI_1:

From Table HR.T1:
       #                   inserts:         3
       #                   updates:         0
       #                   deletes:         0
       #                  discards:         0


REDO Log Statistics
  Bytes parsed                    0
  Bytes output                  228


GGSCI (ser1) 18>



ser2:验证hr.t1表数据

SQL> conn hr/hr

Connected.

SQL> select * from t1;

no rows selected

SQL> /

        ID NAME
---------- ----------------
         1 kk
         2 tom
         3 jack

SQL>


数据初始化完成……

你可能感兴趣的:(ogg实施(一),OGG安装、初始化)