교육/OGG교육

7/9 (1) ogg 단방향 구성 및 단방향 복제 테스트

슐슈리 2014. 7. 9. 18:48
우선 Source와 Target의 DB 모두 open 된 상태에서 진행!

파란색 - source, target 모두 진행
초록색 - source 만
주황색 - target 만

  • DB 유저 생성 ( OGG를 운영하기 위한 유저 -> OGG)
SQL> create tablespace OGG
   datafile '/oracle/oradata/
   size 100m
   autoextend on;
SQL> create user ogg identified by ogg default tablespace OGG;

  • DB 유저에 대한 권한 설정
SQL> grant dba to ogg;

  • supplemental log 설정
SQL> alter database add supplemental log data;        <- Database level의 supplemental log 활성화
SQL> select supplemental_log_data_min from v$database;

supplemental_log_data_min
-------------------------
YES

  • Archive log 활성화
SQL> alter system set log_archive_dest_1='location=os상의 경로'
   scope=both;
SQL> shutdown immediate
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open;
SQL> alter system switch logfile;
SQL> archive log list

  • 테스트 유저 (업무 유저) 생성
SQL> create user app identified by app;
SQL> grant connect, resource to app;




  • OGG 설치

source와 target 시스템에 각각의 설치파일이 있는 디렉토리에서 압축을 푼다.

4개의 파일 압축해제.

tar 파일을 압축해제하면 여러 파일이 생긴다.

ex) /oradata/ogg - 디렉토리 경로


$ alias ogg='cd /oradata/ogg'

$ ogg

$./ggsci        <- ogg prompt


GGSCI> CREATE SUBDIRS        -> 필수 하위 디렉토리 생성


  • MGR 프로세스 설정

GGSCI> EDIT PARAMS ./GLOBALS        대소문자 구분!


GLOBALS 파일 내용

GGSCHEMA OGG

CHECKPOINTTABLE OGG.GGSCHKPT

SYSLOG NONE


GGSCI> EDIT PARAM MGR


mgr.prm 파일 내용(source)

PORT 9010


mgr.prm 파일 내용(target)

PORT 9020

--DYNAMICPORTLIST 9011-9019

--PURGEOLDEXTRACTS ./dirdat/ex* USECHECKPOINTS, MINKEEPFILES 20

--AUTOSTART ER *

--AUTORESTART ER *, RETRIES 10, WAITMINUTES 1, RESETMINUTES 5

--LAGCRITICALSECONDS 60


*** 파라미터 파일들은 ogg 설치 디렉토리의 DIRPRM 디렉토리 밑에 저장된다!***

파라미터 파일들의 변경 사항이 적용되려면 프로세스들을 내렸다 올려줘야 한다.


GGSCI> START MGR        -> manager process 기동

GGSCI> info all / info mgr        -> manager process 확인





단방향 복제 테스트

테스트 시나리오

app 유저의 tcustmer, tcustord 테이블을 사용하여 테이블 생성 및 데이터 유입을 진행한다. (스크립트롤 사용하여 진행)

Extract와 Pump, Replicat을 설정하고 기동시켜 데이터 동기화를 테스트한다.


  • 테스트 테이블 생성
$ ogg
$ sqlplus app/app

SQL> @demo_ora_create.sql
SQL> select * from tcustmer;
SQL> select * from tcustord;

  • 테스트 테이블에 대한 supplemental logging 설정
GGSCI> dblogin userid ogg
passwd: ogg

GGSCI> info trandata app.tcustmer
GGSCI> info trandata app.tcustord;

GGSCI> add trandata app.tcustmer
GGSCI> add trandata app.tcustord

GGSCI> info trandata app.tcustmer
GGSCI> info trandata app.tcustord


  • checkpoint 테이블 생성 

변경 데이터를 target DB에 반영할 때 변경 데이터의 transaction과 함께 checkpoint를 저장한다. 즉 target에서 replicat은 checkpoint 정보를 변경 데이터의 transaction에 포함하여 1개의 transaction으로 같이 commit 처리한다. 그래서 target DB에 checkpoint 정보를 저장하는 테이블을 생성해야 한다.


GGSCI> dblogin userid ogg
passwd: ogg

GGSCI> ADD CHECKPOINTTABLE

  • Extract 설정
GGSCI> edit param ext01


ext01.prm 파일 내용(source)

--# Extract Name

extract ext01

--# DB Information

UserID ogg, Password ogg

--# Management Discard File

DiscardFile ./dirout/ext01.dec, append, megabytes 50

DisCardRollover at 00:01

--# Report File (Not using at Product Env)

ReportCount Every 1 Records, Rate

ReportRollover at 00:01

--# Warn for long running txns

WARNLONGTRANS 1H, CHECKINTERVAL 10m

--# Trail (Ext)

ExtTrail ./dirdat/ex

--# Table List
TABLE APP.*;

  • Extract (ext01)을 Group에 추가

GGSCI> info all


GGSCI> dblogin userid ogg

passwd: ogg


GGSCI> add extract ext01, tranlog, begin now

GGSCI> add exttrail ./dirdat/ex, extract ext01, megabytes 50


GGSCI> info all / info ext01


  • Extract (ext01) 기동 및 확인

GGSCI> start ext01

GGSCI> info ext01

GGSCI> info all


  • PUMP 설정
GGSCI> edit param pmp01

pmp01.prm 파일 내용(source)

--# Pump Name

extract pmp01

--# Mode

PassThru

--# Target Information

RmtHost 127.0.0.1, MGRPORT 9020

--# Trail (Rmt)

RmtTrail ./dirdat/ex

--# Report File (Not using at Product Env)

ReportCount Every 1 Records, Rate

--ReportCount EVERY 1 HOURS, RATE

ReportRollover at 00:01

--# Table List

Table APP.*;


  • Pump (pmp01)을 Group에 추가

GGSCI> info all


GGSCI> add extract pmp01, exttrailsource ./dirdat/ex

GGSCI> add exttrail ./dirdat/ex, extract pmp01, megabytes 50


GGSCI> info all / info pmp01


  • Pump (pmp01) 기동 및 확인

GGSCI> start pmp01

GGSCI> info pmp01

GGSCI> info all


  • Replicat 설정
GGSCI> edit param rep01

rep01.prm 파일 내용(target)

--# Replicat Name

Replicat rep01

--# DB Information

USERID ogg, Password ogg

--# Management Discard File

DiscardFile ./dirout/rep01.dec, append, megabytes 50

DisCardRollover at 00:01

--# Report File (Not using at Product Env)

ReportCount Every 1 Records, Rate

--ReportCount EVERY 1 HOURS, RATE

ReportRollover at 00:01

--# Auto Mapping Column

AssumeTargetDefs

--# Table List

MAP app.tcustmer, Target app.tcustmer;

MAP app.tcustord, Target app.tcustord;


  • Replicat (rep01)을 Group에 추가

GGSCI> info all


GGSCI> add replicat rep01, exttrail ./dirdat/ex


GGSCI> info all / info rep01


  • Replicat (rep01) 기동 및 확인

GGSCI> start rep01

GGSCI> info rep01

GGSCI> info all


  • Source DB에 데이터 유입
$ ogg
$ sqlplus app/app @demo_ora_insert.sql
....

  • 데이터 확인
$ sqlplus app/app
SQL> select * from tcustmer;
SQL> select * from tcustord;


이외의 insert, update, delete 작업도 진행해 보자!


Report 확인

report 파일은 설치 디렉토리의 diript 밑에 존재하며 Process 시작할 때마다 Report 파일이 자동으로 Rolling 된다.


GGSCI> view report exp01/pmp01/rep01

GGSCI> stats ext01/pmp01/rep01