oracle 11gogg,【OGG】Oracle GoldenGate 11g (二) GoldenGate 11g 单向同步配置 上

Oracle GoldenGate 11g (二)

GoldenGate 11g 单向同步配置 上

Item

Source System

Target System

Platform

RHEL6.4 - 64bit

RHEL6.4 - 64bit

Hostname

rhel64.oracle.com

ora11g.oracle.com

Database

Oracle 11.2.0.3

Oracle 11.2.0.3

Character Set

AL32UTF8

AL32UTF8

ORACLE_SID

PROD

EMREP

Listener Name/Port

LISTENER/1521

LISTENER/1521

Goldengate User

ogg

ogg

1.1Configure Oracle Database for

Goldengate

1.1.1Create Goldengate user

Create user ogg for both source system and

target system, and grant appropriate privileges.

为源库和目标库创建ogg用户并赋予相应权限。

1.1.1.1For Source System(PROD):

创建表空间;创建用户、赋予权限

[oracle@rhel101 ~]$ sqlplus / as sysdba

SYS@PROD>create tablespace tbs_gguser datafile

'/u01/app/oracle/oradata/PROD/gguser.dbf' size 50m

autoextend on;

SYS@PROD>create user ogg identified by ogg default

tablespace tbs_gguser

2  temporary tablespace TEMP quota unlimited on

tbs_gguser;

SYS@PROD>grant connect,resource to ogg;

SYS@PROD>grant alter session to ogg;

SYS@PROD>grant select any table,select any dictionary,alter any table to ogg;

SYS@PROD>grant

flashback any table to ogg;

SYS@PROD>grant

execute on dbms_flashback to ogg;

Create test table for Source System:

为源库创建测试表、插入数据、创建主键约束

SYS@PROD>conn scott/tiger

SCOTT@PROD>create table ggtab as select * from emp;

SCOTT@PROD>alter table ggtab add constraint

pk_ggtab_empno primary key(empno);

SCOTT@PROD>select * from ggtab;

1.1.1.2 For Target System(EMREP):

创建表空间;创建用户、赋予权限

[oracle@rhel102 ~]$ sqlplus / as sysdba

SYS@EMREP>create tablespace tbs_gguser datafile

2  '/u01/app/oracle/oradata/EMREP/gguser.dbf'

size 50m autoextend on;

SYS@EMREP>create user ogg identified by ogg default

tablespace tbs_gguser

2  temporary tablespace TEMP quota unlimited on

tbs_gguser;

SYS@EMREP>grant connect,resource to ogg;

SYS@EMREP>grant alter session to ogg;

SYS@EMREP>grant select any dictionary, select any table

to ogg;

SYS@EMREP>grant

update any table,delete any table,insert any table to ogg;

Create empty test table

SYS@EMREP>conn scott/tiger

SCOTT@EMREP>create table ggtab as select * from emp where

1=2;

SCOTT@EMREP>alter table ggtab add constraint pk_ggtab_empno

primary key(empno);

1.1.2Enable supplemental log mode in source system

Check that supplemental log mode is enabled

by following query:

SYS@PROD>select supplemental_log_data_min from

v$database;

SUPPLEME

--------

NO

If not, enable it:

SYS@PROD>alter database add supplemental log data;

SYS@PROD>alter system switch logfile;

SYS@PROD>select supplemental_log_data_min from

v$database;

be89c6f42376ebd7d5233a8b29ecba46.png

1.1.3Enable archive log mode in source system

Enable archive log mode:

[oracle@rhel101 ~]$ mkdir /u01/app/oracle/arch

[oracle@rhel101 ~]$ls -ld /u01/app/oracle/arch

f3ee91ba73a731ff742108d06b3a84de.png

SYS@PROD>alter system set

log_archive_dest_1='location=/u01/app/oracle/arch';

SYS@PROD>shutdown immediate;

SYS@PROD>startup mount;

SYS@PROD>alter database archivelog;

SYS@PROD>alter database open;

SYS@PROD>alter system archive log current;

SYS@PROD>archive log list;

293effdce6c15857f8aabec7fec7d287.png

1.1.4Enable force logging mode in source system

Enable force logging mode:           in case of "no

logging" operations

SYS@PROD>alter database

force logging;

SYS@PROD>select force_logging

from v$database;

296a9c749eeedb6c4a8c21a5f5addc55.png

1.1.5Enable transaction data change capture for test table in Source

system

GGSCI (rhel101.oracle.com) 11> dblogin userid

ogg,password ogg

Successfully logged into database.

GGSCI (rhel101.oracle.com) 12> add trandata scott.ggtab

Logging of supplemental redo data enabled

for table SCOTT.GGTAB.

GGSCI (rhel101.oracle.com) 13> info trandata

scott.ggtab

Logging of supplemental redo log data is

enabled for table SCOTT.GGTAB.

Columns supplementally logged for table

SCOTT.GGTAB: EMPNO.

1.2Configure Goldengate Manager

Process

1.2.1Configure MGR in source system

Create the Manager parameter file.

[oracle@rhel101 11.2.1]$ ggsci

GGSCI (rhel101.oracle.com) 1> edit params mgr

Use the editor to assign a port.此端口号对应 对端的pump配置端口号

PORT 7809

PURGEOLDEXTRACTS ./dirdat,

USECHECKPOINTS

Start the Manager

GGSCI

(rhel101.oracle.com) 2>start mgr

Verify that the Manager has started.

GGSCI

(rhel101.oracle.com) 3>info mgr

Manager

is running (IP port rhel101.oracle.com.7809).

1.2.2Configure MGR in target system

Create the Manager parameter file.

GGSCI (rhel102.oracle.com) 5> edit params mgr

PORT 7809

PURGEOLDEXTRACTS /u01/app/oracle/ggs/11.2.1/dirdat,

USECHECKPOINTS

Start the Manager.

GGSCI (rhel102.oracle.com) 6> start mgr

GGSCI (rhel102.oracle.com) 7> info mgr

Manager is running (IP port

rhel102.oracle.com.7809).

GGSCI (rhel102.oracle.com) 2> start mgr

Verify that the Manager has started.

GGSCI (rhel102.oracle.com) 3> info mgr

Manager is running (IP port rhel102.oracle.com.7809).

1.3Load Initial Data by Direct

Load method

1.3.1Configure Extract process in source system

Add an Extract process called EINI_1:

GGSCI (rhel101.oracle.com) 2> add extract

eini_1,sourceistable

EXTRACT added.

GGSCI (rhel101.oracle.com) 3> info extract

*,tasks

EXTRACT

EINI_1    Initialized   2017-01-05 09:25   Status STOPPED

Checkpoint Lag       Not Available

Log Read Checkpoint  Not Available

First Record         Record 0

Task                 SOURCEISTABLE

Edit EINI_1:

GGSCI (rhel101.oracle.com) 6> edit params eini_1

Add:

-- GoldenGate Initial Data Capture

-- for scott.ggtab

EXTRACT EINI_1

SETENV (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)

USERID ogg, PASSWORD ogg

RMTHOST rhel102.oracle.com, MGRPORT

7809

RMTTASK REPLICAT, GROUP RINI_1

TABLE scott.ggtab;

For chinese support, we should set

environment variable “NLS_LANG” in Extract/Pump/Replicat process parameters.

1.3.2Configure replicat process in target systemrini_1

Add initial load delivery process

GGSCI (rhel102.oracle.com) 4> add replicat rini_1,specialrun

REPLICAT added

GGSCI (rhel102.oracle.com) 4> info replicat *,tasks

REPLICAT   RINI_1    Initialized   2017-01-05 09:30   Status STOPPED

Checkpoint Lag

00:00:00 (updated 00:00:22 ago)

Log Read Checkpoint

Not Available

Task

SPECIALRUN

Edit initial load delivery process RINI_1:.

GGSCI (rhel102.oracle.com) 6> edit params rini_1

Add:

-- GoldenGate Initial Load Delivery

REPLICAT RINI_1

SETENV

(NLS_LANG=AMERICAN_AMERICA.AL32UTF8)

ASSUMETARGETDEFS

USERID ogg, PASSWORD ogg

DISCARDFILE ./dirrpt/RINIaa.dsc,

PURGE

MAP scott.*, TARGET scott.*;

Note: In the MAP statement, the first

owner/schema is for the source and the second for the target.

1.3.3Accomplish Initial Load

Start Initial Load process EINI_1 insource system, then RINI_1 process

in target system will be started automatically:

GGSCI (rhel101.oracle.com) 6> start extract

eini_1

Sending START request to MANAGER ...

EXTRACT EINI_1 starting

GGSCI (rhel101.oracle.com) 7> info extract eini_1

EXTRACT

EINI_1    Initialized   2017-01-05 09:25   Status RUNNING

Checkpoint Lag       Not Available

Log Read Checkpoint  Not Available

First Record         Record 0

Task                 SOURCEISTABLE

1.3.4Verify Initial Load result and process status

GGSCI (rhel101.oracle.com) 11> view report

eini_1

2017-01-05 09:35:06  INFO

OGG-01017  Wildcard resolution

set to IMMEDIATE because SOURCEISTABLE is used.

***********************************************************************

Oracle GoldenGate Capture

for Oracle

Version 11.2.1.0.3 14400833

OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO

Linux, x64, 64bit (optimized), Oracle 11g on Aug 23 2012 20:32:12

Copyright (C) 1995, 2012, Oracle and/or

its affiliates. All rights reserved.

Starting at 2017-01-05

09:35:06

***********************************************************************

Operating System Version:

Linux

Version #1 SMP Tue Jan 29 11:47:41 EST

2013, Release 2.6.32-358.el6.x86_64

Node: rhel101.oracle.com

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: 6727

Description:

***********************************************************************

**            Running with the following parameters                  **

***********************************************************************

2017-01-05 09:35:06  INFO

OGG-03035  Operating system

character set identified as UTF-8. Locale: en_US, LC_ALL:.

EXTRACT EINI_1

SETENV (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)

Set environment variable

(NLS_LANG=AMERICAN_AMERICA.AL32UTF8)

USERID ogg, PASSWORD ***

RMTHOST rhel102.oracle.com, MGRPORT 7809

RMTTASK REPLICAT, GROUP RINI_1

TABLE scott.ggtab;

Using the following key columns for

source table SCOTT.GGTAB: EMPNO.

2017-01-05 09:35:07  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/app/oracle/ggs/11.2.1/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.3.0 - 64bit Production

PL/SQL Release 11.2.0.3.0 - Production

CORE

11.2.0.3.0      Production

TNS for Linux: Version 11.2.0.3.0 -

Production

NLSRTL Version 11.2.0.3.0 - Production

Database Language and Character Set:

NLS_LANG         =

"AMERICAN_AMERICA.AL32UTF8"

NLS_LANGUAGE     = "AMERICAN"

NLS_TERRITORY    = "AMERICA"

NLS_CHARACTERSET = "AL32UTF8"

Processing table SCOTT.GGTAB

***********************************************************************

*                   ** Run Time Statistics

**                         *

***********************************************************************

Report at 2017-01-05 09:35:19 (activity

since 2017-01-05 09:35:07)

Output to RINI_1:

From Table SCOTT.GGTAB:

#                   inserts:        14

#

updates:         0

#

deletes:         0

#

discards:         0

REDO Log Statistics

Bytes parsed

0

Bytes output

2588

You can also verify the results in

target system:

GGSCI (rhel102.oracle.com) 11> view report

rini_1

***********************************************************************

Oracle GoldenGate Delivery for

Oracle

Version 11.2.1.0.3 14400833

OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO

Linux, x64, 64bit (optimized), Oracle 11g on Aug 23 2012 20:37:31

Copyright (C) 1995, 2012, Oracle

and/or its affiliates. All rights reserved.

Starting at 2017-01-05

09:34:48

***********************************************************************

Operating System Version:

Linux

Version #1 SMP Tue Jan 29 11:47:41

EST 2013, Release 2.6.32-358.el6.x86_64

Node: rhel102.oracle.com

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: 6466

Description:

***********************************************************************

**            Running with the following

parameters                  **

***********************************************************************

2017-01-05 09:34:53  INFO

OGG-03035  Operating system

character set identified as UTF-8. Locale: en_US, LC_ALL:.

REPLICAT RINI_1

SETENV

(NLS_LANG=AMERICAN_AMERICA.AL32UTF8)

Set environment variable

(NLS_LANG=AMERICAN_AMERICA.AL32UTF8)

ASSUMETARGETDEFS

USERID ogg, PASSWORD ***

DISCARDFILE ./dirrpt/RINIaa.dsc,

PURGE

MAP scott.*, TARGET scott.*;

2017-01-05 09:34: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/app/oracle/ggs/11.2.1/dirtmp.

CACHEMGR virtual memory values

(may have been adjusted)

CACHESIZE:                                2G

CACHEPAGEOUTSIZE (normal):                8M

PROCESS VM AVAIL FROM OS

(min):           4G

CACHESIZEMAX (strict force to

disk):   3.41G

Database Version:

Oracle Database 11g Enterprise

Edition Release 11.2.0.3.0 - 64bit Production

PL/SQL Release 11.2.0.3.0 -

Production

CORE    11.2.0.3.0      Production

TNS for Linux: Version 11.2.0.3.0

- Production

NLSRTL Version 11.2.0.3.0 -

Production

Database Language and Character

Set:

NLS_LANG         =

"AMERICAN_AMERICA.AL32UTF8"

NLS_LANGUAGE     = "AMERICAN"

NLS_TERRITORY    = "AMERICA"

NLS_CHARACTERSET =

"AL32UTF8"

***********************************************************************

**                     Run Time Messages                             **

***********************************************************************

Wildcard MAP resolved (entry

scott.*):

MAP "SCOTT"."GGTAB", TARGET

scott."GGTAB";

Using following columns in default

map by name:

EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO

Using the following key columns

for target table SCOTT.GGTAB: EMPNO.

***********************************************************************

*                   ** Run Time Statistics

**                         *

***********************************************************************

Report at 2017-01-05 09:35:05

(activity since 2017-01-05 09:35:00)

From Table SCOTT.GGTAB to

SCOTT.GGTAB:

#                   inserts:        14

#                   updates:         0

#                   deletes:         0

#                  discards:         0

。。。。。。

Check the initial data has been

transferred to Target system:

SCOTT@EMREP>select * from

ggtab;

6e243d091c079db5ee820c08fa4b2c31.png

1.3.5Check process status

After initial load, extract process

EINI_1 and replicat process RINI_1 stop automatically.

Source system:

GGSCI (rhel101.oracle.com) 12> info extract

eini_1

EXTRACT    EINI_1

Last Started 2017-01-05 09:35

Status STOPPED

Checkpoint Lag       Not Available

Log Read Checkpoint  Table SCOTT.GGTAB

2017-01-05 09:35:14  Record 14

Task                 SOURCEISTABLE

Target System:

GGSCI (rhel102.oracle.com) 12> info replicat

rini_1

REPLICAT   RINI_1

Initialized   2017-01-05

09:30   Status STOPPED

Checkpoint Lag       00:00:00 (updated 00:16:12 ago)

Log Read Checkpoint  Not Available

Task                 SPECIALRUN

1.3.6Solution for Error

a3f16141a03bab0603c90b85c70cf3d1.png

eini_1

parameter  should put the parent table

first,for example:

EXTRACT EINI_1

SETENV (NLS_LANG=AMERICAN_AMERICA.ZHS16GBK)

USERID ogg, PASSWORD ogg

RMTHOST lvxingaho2, MGRPORT 7809

RMTTASK REPLICAT, GROUP RINI_1

TABLE scott.dept;

TABLE scott.emp;

1.4Configure Extract Process in

Source system

1.4.1Edit extract process parametereora_1

GGSCI (rhel101.oracle.com) 15> edit

params eora_1

Add:

-- Change Capture parameter file to capture ggtbs changes

EXTRACT EORA_1

SETENV (NLS_LANG=AMERICAN_AMERICA.AL32UTF8)

USERID ogg, PASSWORD ogg

EXTTRAIL ./dirdat/la

TABLE scott.ggtbs;

Please note that “la” is prefix for

local trail file.

GGSCI (rhel101.oracle.com) 69> view params

eora_1

88c915787453467fb7027251100df247.png

Execute the following commands in

source system to add Primary Extract group.

GGSCI (rhel101.oracle.com) 16> add extract eora_1,tranlog,begin now

EXTRACT added.

1.4.2Define GoldenGate local trail

GGSCI (rhel101.oracle.com) 17> ADD EXTTRAIL ./dirdat/la, EXTRACT EORA_1, MEGABYTES 5

EXTTRAIL added.

1.4.3Start primary Extract process

GGSCI (rhel101.oracle.com) 18> start extract eora_1

Sending START request to MANAGER ...

EXTRACT EORA_1 starting

Verify extract process is running or

not:

GGSCI (rhel101.oracle.com) 19> info extract

eora_1

EXTRACT    EORA_1

Last Started 2017-01-05 10:00   Status

RUNNING

Checkpoint Lag       00:00:00 (updated 00:00:08 ago)

Log Read Checkpoint  Oracle Redo Logs

2017-01-05 10:00:27  Seqno 8, RBA 13643776

SCN 0.1111409 (1111409)

GGSCI (rhel101.oracle.com) 20> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING

EXTRACT     RUNNING     EORA_1      00:00:00      00:00:00

Now Goldengate will generate local

tail file “aa000000”under

dirdat in Source system:

[oracle@rhel101 ~]$ ll

/u01/app/oracle/ggs/11.2.1/dirdat/

total 4

-rw-rw-rw- 1 oracle oinstall 1059

Jan  5 10:00 la000000

1cd00714265ce26772a13ecc72b28292.png

1.5Configure pump process in Source

system

1.5.1Edit data pump process parameterpora_1

GGSCI (rhel101.oracle.com) 20> edit params pora_1

Add:

-- Data Pump parameter file to read the local trail of scott.ggtbs

changes

EXTRACT PORA_1

SETENV

(NLS_LANG=AMERICAN_AMERICA.AL32UTF8)

PASSTHRU

RMTHOST rhel102.oracle.com, MGRPORT

7809

RMTTRAIL ./dirdat/ra

TABLE scott.ggtab;

Please note that “ra” is prefix for remote

trail file.

c863a346ed6036eb2d6554a78761d482.png

Add data pump Extract group

GGSCI (rhel101.oracle.com) 21> add

extract pora_1,exttrailsource ./dirdat/la

EXTRACT added.

Verify results:

GGSCI (rhel101.oracle.com) 26> info extract

pora_1

EXTRACT    PORA_1

Last Started 2017-01-05 10:05

Status STOPED

Checkpoint Lag       00:00:00 (updated 00:01:20 ago)

Log Read Checkpoint  File ./dirdat/la000000

First Record  RBA 0

1.5.2Add GoldenGate remote trail in Source system

GGSCI (rhel101.oracle.com) 24> add rmttrail ./dirdat/ra,extract pora_1,megabytes 5

RMTTRAIL added.

Start data pump process:

GGSCI (rhel101.oracle.com)

25> start

extract pora_1

Sending

START request to MANAGER ...

EXTRACT

PORA_1 starting

GGSCI

(rhel101.oracle.com) 35>info extract pora_1

EXTRACT    PORA_1

Last Started 2017-01-05 10:11

Status RUNNING

Checkpoint

Lag       00:00:00 (updated 00:00:04 ago)

Log Read

Checkpoint  File ./dirdat/la000000

First Record  RBA 1059

GGSCI

(rhel101.oracle.com) 36> info all

Program     Status

Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING

EXTRACT     RUNNING

EORA_1      00:00:00      00:00:08

EXTRACT     RUNNING

PORA_1      00:00:00      00:00:06

Now Goldengate will generate remote

tail file “ra000000”under dirdat in Target system:

[oracle@rhel102 ~]$ ll

/u01/app/oracle/ggs/11.2.1/dirdat/

total 0

-rw-rw-rw- 1 oracle oinstall 0

Jan  5 10:11 ra000000

f4ad2515425e182500ecb5d15dd21e4a.png

吕星昊

2017年11月20日

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值