Oracle on AWS RDS
Migration
Oops !~~~~~
 Oracle Database 9iR2(9.2.0.8) + Data Size 300GB
 HP-UX 11.11 Model 9000/800/N4000-55
 CPU : PA8600(PA-RISC 2.0) 550MHz * 4EA
 RAN : 6144MB(6GB)
 OS/HW/DB 모두 End Of Support(EOS)
Oracle on AWS RDS로 이관 시 고려 사항
 Oracle Database License 관련 내용 확인
 License Included와 Bring Your Own License(BYOL) 지원
 License Included: Oracle DB SE One, SE Two
 BYOL : 모든 Oracle DB 제품 지원
 지원 가능한 Oracle DB Version?
 Oracle Database 12cR1(12.1.0.2)
 Oracle Database 11gR2(11.2.0.4)
 지원 가능한 이관 방법은?
 Exp/Imp, Data pump등 다양한 이관 방법 지원
 이관 Data Size 및 임시파일(Dump File) 보관 공간 확보 여부?
 Storage를 이용한 Data Dump File을 보관 가능
 최대 Downtime 가능 시간은?
 무 정지 이관 시 AWS DMS 및 3rd Party Tool 사용 가능
 Data 성격 및 국내 IDC 존재 여부?
 개인정보의 경우 국외 이전의 거의 불가능 함.
Oracle on AWS RDS로 지원하는 이관 방법
 Oracle SQL Developer
 Oracle에서 제공하는 Java Base SQL Tool를 이용
 작은 Size의 Data Migration에 적합
 추가 기능을 설치하면 Mysql 및 기타 DBMS도 지원 함
 Oracle Data Pump
 가장 일반적인 Migration Tool 이며, 빠른 이관 속도를 보임
 DBMS_FILE_TRANSFER Option을 사용 해야 함
 Oracle Export/Import
 전통적인 Migration Tool이며, Oracle 8i 부터 지원 함
 LOB Data Type이 있을 경우 매우 느림
 Oracle SQL*Loader
 구분자로 구분된 Text File을 Table에 Insert 하는 방식
 Oracle Materialized Views
 Database link를 이용하여 Materialized Views를 이용하여 이관
 CDC Tool를 이용한 이관 방법
Oracle on AWS RDS 사양 및 가격(Oracle SE1)
인스턴스유형 vCPU
메모리
(GiB)
서울 도쿄 싱가폴 뭄바이 런던
db.t2.small 1 2 $0.082 $0.082 $0.082 $0.067 $0.076
db.t2.micro 1 1 $0.041 $0.041 $0.041 $0.035 $0.038
db.t2.medium 2 4 $0.164 $0.164 $0.164 $0.134 $0.151
db.t2.large 2 8 $0.382 $0.382 $0.429 $0.414 $0.311
db.r3.xlarge 4 30.5 $1.050 $1.050 $1.050 $0.972
db.r3.large 2 15 $0.525 $0.525 $0.525 $0.491
db.r3.4xlarge 16 122 $4.200 $4.200 $4.200 $3.869
db.r3.2xlarge 8 61 $2.100 $2.100 $2.100 $1.938
db.m4.xlarge 4 16 $0.944 $0.969 $0.989 $0.955 $0.966
db.m4.large 2 8 $0.470 $0.483 $0.495 $0.477 $0.483
db.m4.4xlarge 16 64 $3.775 $3.874 $3.957 $3.817 $3.863
db.m4.2xlarge 8 32 $1.888 $1.937 $1.979 $1.912 $1.932
※2017년 06월 기준(라이선스 포함, 단일 AZ 환경)
Oracle on AWS RDS 이관 구성도
AWS cloud
virtual private cloud
EC2
EBS
Oracle DB
On-Premise
Oracle DB
On-Premise
Firewall
SSH Tunnel
AWSOn-Premises
OGG를 이용한 Oracle on AWS RDS 개념도
Source DB
OutboundProxySSH(SOCKES5Proxy)
InboundProxySSH(SOCKES5Proxy)
On-Premises OGG
Trail File
Extract Data
Pump
OGG Hub on EC2
Trail File
Collector Replicate
Target DB
Oracle on AWS RDS
Port 22
Key Based
Authorization
SOCKS
Proxy
Tunnel
①
②
③
④ ⑤
⑥
⑦
⑧
⑨
OGG를 이용한 Oracle on AWS RDS 이관 순서
순서 Source Target
1 Oracle GG Install
2 OGG Setting
3 EC2 Instance에 Oracle Client/OGG Install
4 EC2 Instance에 OGG Setting
5 Source와 Target 간 OGG 구성
6 초기 Data Export
7 EC2 Instance에서 초기 Data Import
8 EC2 에서 OGG Replicat 설정 및 기동
9 Source DB 서비스 종료
10 Listener Stop & Source DB Shutdown
11 Target DB에서 업무 시작
※본 문서에서는 Step 8까지만 진행
Step1. Oracle Golden Gate Install - Source
 Oracle GG 12c 이상 필요 및 최신 PSU 적용 권장
 Oracle GG 12c는 OUI Install 지원
Step2. Oracle Golden Gate Setting - Source
 OGG 전용 Oracle DB User 생성 및 OGG 관련 권한 부여(Sysdba로 실행)
SQL> create user oggs identified by oggs;
SQL> grant connect, resource to OGGS;
SQL> grant select any dictionary, select any table, select any transaction to OGGS;
SQL> grant SELECT on dba_clusters to OGGS;
SQL> grant create table to OGGS;
SQL> grant alter any table to OGGS;
SQL> grant flashback any table to OGGS;
SQL> grant execute on dbms_flashback to OGGS;
SQL> grant execute on utl_file to OGGS;
SQL> grant create session to OGGS;
SQL> grant alter session to OGGS;
SQL> grant insert any table to OGGS;
SQL> grant delete any table to OGGS;
SQL> grant update any table to OGGS;
SQL> grant lock any table to OGGS;
 DB Level Supplemental Log 설정(Sysdba로 실행)
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
SQL> SELECT supplemental_ log_data_min FROM v$database;
SUPPLEME
--------
YES
Step2. Oracle Golden Gate Setting - Source
 OGG 전용 Oracle DB User에 Oracle Stream 권한 부여(Sysdba로 실행)
SQL> exec dbms_streams_auth.grant_admin_privilege('oggs');
 (선택)enable_goldengate_replication parameter True 설정(11.2.0.4 이상 )
SQL> alter system set enable_goldengate_replication=true scope=both;
System altered.
SQL> show spparameter enable_goldengate_replication
SID NAME TYPE VALUE
-------- ----------------------------- ----------- ----------------------------
* enable_goldengate_replication boolean TRUE
 기타 필수 사항
 Archive Log Mode 필수
 RAC 환경인 경우 Archive Log 파일이 공유 볼륨에 있어야 한다.
Step2. Oracle Golden Gate Setting - Source
 OGG SubDir 생성(OS OGG User로 실행)
$./ggsci
GGSCI (ogg.localdomain) 1> create subdirs
Creating subdirectories under current directory /OGG
Parameter files /OGG/dirprm: created
Report files /OGG/dirrpt: created
Checkpoint files /OGG/dirchk: created
Process status files /OGG/dirpcs: created
SQL script files /OGG/dirsql: created
Database definitions files /OGG/dirdef: created
Extract data files /OGG/dirdat: created
Temporary files /OGG/dirtmp: created
Credential store files /OGG/dircrd: created
Masterkey wallet files /OGG/dirwlt: created
Dump files /OGG/dirdmp: created
 Table Level Supplemental Log 설정 (OS OGG User로 실행)
디렉토리 내용
dirchk
OGG Process의 Checkpoint가 기록되는 File
저장
dirdat
Extract가 Capture한 Data 변경분을
저장하는 Trail File 생성
dirdef
스키마가 다른 table을 매핑하기 위해
스키마 정보가 저장되어 있는 파일
dirpcs 프로세스 상태 파일들
dirprm
OGG Process 적용테이블의 Mapping 방식
및 추가 설정 Option들을 지정하는 File 생성
dirrpt
OGG Process 처리내역 및 오류 시 원인
저장
dirout
OGG Process 운영 시 발생하는 오류 원인
및 오류 record 내용이 기록되는 Discard
File 저장
GGSCI (ogg.localdomain) 1> dblogin userid oggs password oggs
Successfully logged into database.
GGSCI (ogg.localdomain as oggs@OGG) 2> add schematrandata scott
2017-06-21 10:33:53 INFO OGG-01788 SCHEMATRANDATA has been added on schema scott.
2017-06-21 10:33:53 INFO OGG-01976 SCHEMATRANDATA for scheduling columns has been added
on schema scott.
Step2. Oracle Golden Gate Setting - Source
 OGG Manager Process Parameter 생성 (OS OGG User로 실행/ggsci)
GGSCI (ogg.localdomain) 1> edit param mgr
--# Manager Port
PORT 7800
--# Manage Trail File
PURGEOLDEXTRACTS ./dirdat/ea* USECHECKPOINTS, MINKEEPDAYS 7
--# Manage Process
AUTORESTART ER *, RETRIES 10, WAITMINUTES 1, RESETMINUTES 5
--# LAG
LAGCRITICALSECONDS 60 -- lag 발생시 critical로 report
LAGINFOSECONDS 10 -- lag 발생시 warning (초/분/시간)
LAGREPORTMINUTES 1 -- check 주기
GGSCI (ogg.localdomain) 3> view param mgr
--# Manager Port
PORT 7800
--# Manage Trail File
PURGEOLDEXTRACTS ./dirdat/ea* USECHECKPOINTS, MINKEEPDAYS 7
--# Manage Process
AUTORESTART ER *, RETRIES 10, WAITMINUTES 1, RESETMINUTES 5
--# LAG
LAGCRITICALSECONDS 60 -- lag 발생시 critical로 report
LAGINFOSECONDS 10 -- lag 발생시 warning (초/분/시간)
LAGREPORTMINUTES 1 -- check 주기
Step2. Oracle Golden Gate Setting - Source
 OGG Extract Process Parameter 생성 (OS OGG User로 실행/ggsci)
GGSCI (ogg.localdomain) 4> edit param E_L_EXT1
EXTRACT E_L_EXT1
SETENV (NLS_LANG="American_America.KO16MSWIN949")
USERID oggs , PASSWORD oggs
DiscardFile ./dirout/exta.dsc, append, megabytes 500
DisCardRollover at 00:01
BR BROFF
TRANLOGOPTIONS ALTARCHIVELOGDEST PRIMARY INSTANCE OGG /ORADATA/ARCH/
EXTTRAIL ./dirdat/ea
table scott.ACCOUNT;
table <DB USERNAME>.<Table_Name>;
….
table <DB USERNAME>.<Table_Name>;
GGSCI (ogg.localdomain) 5> view param E_L_EXT1
EXTRACT E_L_EXT1
SETENV (NLS_LANG="American_America.KO16MSWIN949")
USERID oggs , PASSWORD oggs
DiscardFile ./dirout/exta.dsc, append, megabytes 500
DisCardRollover at 00:01
Step2. Oracle Golden Gate Setting - Source
 Extract 프로세스 ADD (OS OGG User로 실행/ggsci)
GGSCI (ogg.localdomain) 1> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER STOPPED
GGSCI (ogg.localdomain) 2> start mgr
Manager started.
GGSCI (ogg.localdomain) 3> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
GGSCI (ogg.localdomain) 4> add extract E_L_EXT1, tranlog , threads 1, begin now
EXTRACT added.
GGSCI (ogg.localdomain) 5> add exttrail ./dirdat/ea , extract E_L_EXT1, megabytes 500
EXTTRAIL added.
GGSCI (ogg.localdomain) 6> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT STOPPED E_L_EXT1 00:00:00 00:00:37
Step3. EC2에 Oracle Client/OGG Install - Target
 Oracle Client Install
 t2.micro는 SWAP 제공 되지 않음
• SWAP이 필요한 경우 참고
http://docs.aws.amazon.com/ko_kr/AWSEC2/latest/UserGuide/inst
ance-store-swap-volumes.html
• OUI의 “-ignoreSysPrereqs “ 옵션 사용하여 SWAP 없이 설치 가능
 t2.micro는 “X Window System”를 제공 하지 않음
• Yum을 설정하여 “X Window System”은 가능 함.
• OUI의 “-silent “ 옵션 사용하여 X Windows System 없이 설치 가능
 OGG Silent Mode Install
$ cd fbo_ggs_Linux_x64_shiphome/Disk1
$ ./runInstaller -silent INSTALL_OPTION=ORA11g 
> SOFTWARE_LOCATION=/OGG 
> START_MANAGER=true 
> MANAGER_PORT=7809 
> DATABASE_LOCATION=/app/oracle/product/11.2.0/client_1 
> INVENTORY_LOCATION=/app/oraInventory 
> UNIX_GROUP_NAME=dba
Step4. EC2에 Oracle GG Setting - Target
 EC2 Instance에 사전에 Oracle Client가 설치 되어 있어야 함
 OGG 전용 Oracle DB User 생성 및 권한 부여
$sqlplus awssystem/oracle1@awsorcl
SQL> create user oggt identified by oggt;
SQL> grant connect,resource to OGGT;
SQL> grant select any dictionary, select any table, select any transaction to OGGT;
SQL> grant SELECT on dba_clusters to OGGT;
SQL> grant create table to OGGT;
SQL> grant alter any table to OGGT;
SQL> grant flashback any table to OGGT;
SQL> grant execute on dbms_flashback to OGGT;
SQL> grant execute on utl_file to OGGT;
SQL> grant create session to OGGT;
SQL> grant alter session to OGGT;
SQL> grant insert any table to OGGT;
SQL> grant delete any table to OGGT;
SQL> grant update any table to OGGT;
SQL> grant lock any table to OGGT;
SQL> exec RDSADMIN.RDSADMIN_UTIL.GRANT_SYS_OBJECT ('DBA_CLUSTERS', 'OGGT');
SQL> EXEC DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE (grantee=>'OGGT',
privilege_type=>'capture', grant_select_privileges=>true, do_grants=>TRUE);
Step4. EC2에 Oracle GG Setting - Target
 DB Level Supplemental Log 설정OGG 전용 Oracle DB User 생성 및 권한
부여
$sqlplus awssystem/oracle1@awsorcl
SQL> SELECT supplemental_log_data_min FROM v$database;
SUPPLEME
--------
NO
/*
--AWS RDS는 alter system 권한을 부여 하지 않음으로 아래와 같은 Error가 발생함
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA
*
ERROR at line 1:
ORA-01031: insufficient privileges
*/
--AWS RDS에서 rdsadmin.rdsadmin_util Package를 이용하여 변경 해야 함.
SQL> exec rdsadmin.rdsadmin_util.alter_supplemental_logging('ADD');
PL/SQL procedure successfully completed.
SQL> SELECT supplemental_log_data_min FROM v$database;
SUPPLEME
--------
YES
Step4. EC2에 Oracle GG Setting - Target
 Archive Log 확인
/*
--AWS RDS는 alter system 권한을 부여 하지 않음으로 아래와 같은 Error가 발생함
SQL> archive log list
ORA-01031: insufficient privileges
SQL>
*/
SQL> select NAME from V$ARCHIVED_LOG;
NAME
--------------------------------------------------------------------------------
/rdsdbdata/db/ORCL_A/arch/redolog-2753-1-943298393.arc
/rdsdbdata/db/ORCL_A/arch/redolog-2754-1-943298393.arc
/*
--AWS RDS는 alter system 권한을 부여 하지 않음으로 아래와 같은 Error가 발생함
SQL> alter system switch logfile;
alter system switch logfile
*
ERROR at line 1:
ORA-01031: insufficient privileges
*/
SQL> exec rdsadmin.rdsadmin_util.switch_logfile;
PL/SQL procedure successfully completed.
Step4. EC2에 Oracle GG Setting - Target
 Archive Log 확인
/*
--AWS RDS는 alter system 권한을 부여 하지 않음으로 아래와 같은 Error가 발생함
SQL> alter system checkpoint;
alter system checkpoint
*
ERROR at line 1:
ORA-01031: insufficient privileges
*/
SQL> exec rdsadmin.rdsadmin_util.checkpoint;
PL/SQL procedure successfully completed.
SQL> select NAME from V$ARCHIVED_LOG;
NAME
--------------------------------------------------------------------------------
/rdsdbdata/db/ORCL_A/arch/redolog-2753-1-943298393.arc
/rdsdbdata/db/ORCL_A/arch/redolog-2754-1-943298393.arc
/rdsdbdata/db/ORCL_A/arch/redolog-2755-1-943298393.arc
/rdsdbdata/db/ORCL_A/arch/redolog-2756-1-943298393.arc
SQL>
Step4. EC2에 Oracle GG Setting - Target
 enable_goldengate_replication parameter True 설정(11.2.0.4 이상만)
/*
--AWS RDS는 alter system 권한을 부여 하지 않음으로 아래와 같은 Error가 발생함
SQL> alter system set enable_goldengate_replication=true scope=both;
alter system set enable_goldengate_replication=true scope=both
*
ERROR at line 1:
ORA-01031: insufficient privileges
*/
 RDS Dashboard -> Parameter Groups 에서 생성 후 Restart 해야 함
Step4. EC2에 Oracle GG Setting - Target
 OGG Subdir 생성 (OS OGG User로 실행)
[aogg@ip-172-31-X-XX OGG]$ ./ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 12.2.0.1.170221 OGGCORE_12.2.0.1.0OGGBP_PLATFORMS_170123.1033_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Jan 23 2017 21:54:15
Operating system character set identified as UTF-8.
Copyright (C) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 1> create subdirs
Creating subdirectories under current directory /OGG
Parameter files /OGG/dirprm: created
Report files /OGG/dirrpt: created
Checkpoint files /OGG/dirchk: created
Process status files /OGG/dirpcs: created
SQL script files /OGG/dirsql: created
Database definitions files /OGG/dirdef: created
Extract data files /OGG/dirdat: created
Temporary files /OGG/dirtmp: created
Credential store files /OGG/dircrd: created
Masterkey wallet files /OGG/dirwlt: created
Dump files /OGG/dirdmp: created
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 2>
Step4. EC2에 Oracle GG Setting - Target
 Local System OGG GLOBALS 파라미터 설정 (OS OGG User로 실행)
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 1> edit param mgr
--# Manager Port
PORT 7800
PURGEOLDEXTRACTS ./dirdat/ea* USECHECKPOINTS, MINKEEPDAYS 7
--# Manage Process
AUTORESTART ER *, RETRIES 10, WAITMINUTES 1, RESETMINUTES 5
--# LAG
LAGCRITICALSECONDS 60 -- lag 발생시 critical로 report
LAGINFOSECONDS 10 -- lag 발생시 warning (초/분/시간)
LAGREPORTMINUTES 1 -- check 주기
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 2> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER STOPPED
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 3> start mgr
Manager started.
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 4> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
Step5. S/T간 OGG Setting - Source
 Local System OGG GLOBALS 파라미터 설정 (OS OGG User로 실행)
GGSCI (ogg.localdomain) 1> edit param ./GLOBALS
Checkpointtable oggs.chkpt
Syslog none
Ggschema oggs
 Local System EXTRACT 시작 (OS OGG User로 실행)
GGSCI (ogg.localdomain) 1> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT STOPPED E_L_EXT1 00:00:00 00:07:04
GGSCI (ogg.localdomain) 2> start E_L_EXT1
Sending START request to MANAGER ...
EXTRACT E_L_EXT1 starting
GGSCI (ogg.localdomain) 3> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT STARTING E_L_EXT1 00:00:00 00:07:14
Step5. S/T간 OGG Setting - Target
 Local System과 AWS EC2 OGG Hub간 SSH 구성 (OS OGG User로 실행)
[aogg@ip-172-31-X-XX OGG]$ ./ggsci
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 1> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 2> edit param mgr
PORT 7800
PURGEOLDEXTRACTS ./dirdat/ea* USECHECKPOINTS, MINKEEPDAYS 7
AUTORESTART ER *, RETRIES 10, WAITMINUTES 1, RESETMINUTES 5
--# Enable secrule for collector
ACCESSRULE, PROG COLLECTOR, IPADDR ec2-52-78-XXX-XXX.ap-northeast-
2.compute.amazonaws.com, ALLOW
--# LAG
LAGCRITICALSECONDS 60 -- lag 발생시 critical로 report
LAGINFOSECONDS 10 -- lag 발생시 warning (초/분/시간)
LAGREPORTMINUTES 1 -- check 주기
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 3> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
Step5. S/T간 OGG Setting - Source
 Start SSH Proxy Server on Local OGG System Setting (OS OGG User)
[logg@ogg OGG]$ pwd
/OGG
[logg@ogg OGG]$ ssh -i "/home/logg/CDC_EC2_OGG.pem" -v -N -f -D 127.0.0.1:8888 aogg@ec2-
52-78-XXX-XXX.ap-northeast-2.compute.amazonaws.com > ./dirrpt/socks.log 2>&1
 Verify the SSH Socks Proxy server process (OS OGG User)
[logg@ogg OGG]$ cat ./dirrpt/socks.log
OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Connecting to ec2-52-78-XXX-XXX.ap-northeast-2.compute.amazonaws.com [52.78.230.216]
port 22.
……
Authenticated to ec2-52-78-XXX-XXX.ap-northeast-2.compute.amazonaws.com ([52.78.230.216]:22).
debug1: Local connections to 127.0.0.1:8888 forwarded to remote address socks:0
debug1: Local forwarding listening on 127.0.0.1 port 8888.
debug1: channel 0: new [port listener]
debug1: Requesting no-more-sessions@openssh.com
debug1: forking to background
debug1: Entering interactive session.
[logg@ogg OGG]$
Step5. S/T간 OGG Setting - Source
 Local System OGG Restart (OS OGG User)
GGSCI (ogg.localdomain) 1> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER STOPPED
EXTRACT STOPPED E_L_EXT1 00:00:00 00:01:05
GGSCI (ogg.localdomain) 2> start mgr
Manager started.
GGSCI (ogg.localdomain) 3> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT STOPPED E_L_EXT1 00:00:00 00:01:11
GGSCI (ogg.localdomain) 4> start E_L_EXT1
Sending START request to MANAGER ...
EXTRACT E_L_EXT1 starting
GGSCI (ogg.localdomain) 5> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING E_L_EXT1 00:00:00 00:00:00
Step5. S/T간 OGG Setting - Source
 Local system -> EC2 OGG Pump 생성(OS OGG User)
[logg@ogg OGG]$ ./ggsci
GGSCI (ogg.localdomain) 1> edit param P_L_AWS
EXTRACT P_L_AWS
DiscardFile ./dirout/pumpaws.dsc, append, megabytes 500
DisCardRollover at 00:01
REPORTCOUNT EVERY 1 MINUTES, RATE
EOFDELAYCSECS 10
FLUSHCSECS 10
CHECKPOINTSECS 2
PASSTHRU
--GETTRUNCATES
RMTHOST ec2-52-78-XXX-XXX.ap-northeast-2.compute.amazonaws.com, MGRPORT 7800,
SOCKSPROXY 127.0.0.1:8888
RMTTRAIL ./dirdat/r1
table <DB USERNAME>.<Table_Name>;
….
table <DB USERNAME>.<Table_Name>;
RMTTRAIL ./dirdat/r2
table <DB USERNAME>.<Table_Name>;
….
table <DB USERNAME>.<Table_Name>;
Step5. S/T간 OGG Setting - Source
 Local system -> EC2 OGG Pump 생성(OS OGG User)
GGSCI (ogg.localdomain) 2> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING E_L_EXT1 00:00:00 00:00:00
GGSCI (ogg.localdomain) 3> add extract P_L_AWS, exttrailsource ./dirdat/ea
EXTRACT added.
GGSCI (ogg.localdomain) 4> add rmttrail ./dirdat/r1 , extract P_L_AWS, megabytes 500
RMTTRAIL added.
GGSCI (ogg.localdomain) 5> add rmttrail ./dirdat/r2 , extract P_L_AWS, megabytes 500
RMTTRAIL added.
GGSCI (ogg.localdomain) 8> start EXTRACT P_L_AWS
Sending START request to MANAGER ...
EXTRACT P_L_AWS starting
GGSCI (ogg.localdomain) 9> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING E_L_EXT1 00:00:00 00:00:06
EXTRACT RUNNING P_L_AWS 00:00:00 00:00:01
Step6. 초기 Data Export - Source
 rows=n 옵션 사용 Schema Export (OS Oracle User)
[oracle@ogg STAGE]$ exp system/welcome1 owner=SCOTT rows=n file=00_exp_scott_no_data.dmp
log=00_exp_scott_no_data.log
. exporting foreign function library names for user SCOTT
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions for user SCOTT
About to export SCOTT's objects ...
. exporting database links
. exporting sequence numbers
. exporting cluster definitions
. about to export SCOTT's tables via Conventional Path ...
. . exporting table ACCOUNT
[oracle@ogg STAGE]$
Step6. 초기 Data Export - Source
 FLASHBACK_SCN 이용하여 특정 시점 Data export (OS Oracle User)
[oracle@ogg STAGE]$ sqlplus “/as sysdba”
SQL> COL CURRENT_SCN for 99999999999999999999999999999
SQL> SELECT dbms_flashback.get_system_change_number as CURRENT_SCN FROM DUAL;
CURRENT_SCN
------------------------------
750720
SQL> exit
[oracle@ogg STAGE]$ exp system/welcome1 owner=SCOTT file=02_exp_scott_data.dmp
log=02_exp_scott_data.log FLASHBACK_SCN=750720
Export: Release 11.2.0.4.0 - Production on Thu Jun 22 16:06:21 2017
. exporting object type definitions for user SCOTT
About to export SCOTT's objects ...
. about to export SCOTT's tables via Conventional Path ...
. . exporting table ACCOUNT 28969 rows exported
……
. exporting post-schema procedural objects and actions
. exporting statistics
Export terminated successfully without warnings.
[oracle@ogg STAGE]$
 FTP를 이용하여 EC2에 이동
Step7. EC2 에서 초기 Data Import - Target
 Schema Import (OS Oracle User)
[oracle@ip-172-31-X-XX WORK]$ imp awssystem/oracle1@awsorcl FROMUSER=SCOTT
TOUSER=SCOTT file=00_exp_scott_no_data.dmp
Import: Release 11.2.0.4.0 - Production on Thu Jun 22 02:59:50 2017
…..
. importing SCOTTs objects into SCOTT
Import terminated successfully without warnings.
 Data Import (OS Oracle User)
[oracle@ip-172-31-X-XX WORK]$ time imp awssystem/oracle1@awsorcl FROMUSER=SCOTT
TOUSER=SCOTT file=02_exp_scott_data.dmp DATA_ONLY=Y
Import: Release 11.2.0.4.0 - Production on Thu Jun 22 03:22:30 2017
. . importing table "S_GOGAEK" 378789 rows imported
. . importing table "S_JAEGO" 274276 rows imported
. . importing table "S_ZIPCODE" 49033 rows imported
Import terminated successfully without warnings.
real 9m24.253s
user 0m18.202s
sys 0m2.560s'
[oracle@ip-172-31-X-XX WORK]$
Step8. EC2 에서 OGG Replicat 설정 및 기동
- Target
 AWS EC2 Hub에 OGG Replicat 파라미터 설정 (OS OGG User)
[aogg@ip-172-31-X-XX OGG]$ ./ggsci
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 1> edit param R_L_AWS1
REPLICAT R_L_AWS1
SETENV (NLS_LANG="American_America.KO16MSWIN949")
USERID oggt@awsorcl , PASSWORD oggt
DiscardFile ./dirout/rep01.dsc, append, megabytes 100
DisCardRollover at 00:01
REPORTCOUNT EVERY 1 MINUTES, RATE
ASSUMETARGETDEFS
MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>;
MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>;
MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>;
MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>;
MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>;
Step8. EC2 에서 OGG Replicat 설정 및 기동
- Target
 AWS EC2 Hub에 OGG Replicat 파리미터 설정 (OS OGG User)
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 3> edit param R_L_AWS2
REPLICAT R_L_AWS2
SETENV (NLS_LANG="American_America.KO16MSWIN949")
USERID oggt@awsorcl , PASSWORD oggt
DiscardFile ./dirout/rep01.dsc, append, megabytes 100
DisCardRollover at 00:01
REPORTCOUNT EVERY 1 MINUTES, RATE
ASSUMETARGETDEFS
MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>;
MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>;
MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>;
MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>;
MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>;
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 4> edit param ./GLOBALS
Checkpointtable oggt.chkpt
Syslog none
Ggschema oggt
Step8. EC2 에서 OGG Replicat 설정 및 기동
- Target
 AWS EC2 Hub에 OGG Replicat 등록 및 시작 (OS OGG User)
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 5> add replicat R_L_AWS1,
exttrail ./dirdat/r1, checkpointtable oggt.chkpt
REPLICAT added.
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 6> add replicat R_L_AWS2,
exttrail ./dirdat/r2, checkpointtable oggt.chkpt
REPLICAT added.
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 7> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
REPLICAT STOPPED R_L_AWS1 00:00:00 00:00:28
REPLICAT STOPPED R_L_AWS2 00:00:00 00:00:03
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 8> start replicat R_L_AWS1, aftercsn 750720
Sending START request to MANAGER ...
REPLICAT R_L_AWS1 starting
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 9> start replicat R_L_AWS2, aftercsn 750720
Sending START request to MANAGER ...
REPLICAT R_L_AWS2 starting
Step8. EC2 에서 OGG Replicat 설정 및 기동
- Target
 동기화 확인 (OS OGG User)
[aogg@ip-172-31-X-XX OGG]$ ./ggsci
GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 1> stats R_L_AWS1
Sending STATS request to REPLICAT R_L_AWS1 ...
Start of Statistics at 2017-07-04 01:47:17.
Replicating from SCOTT.EMP to SCOTT.EMP:
*** Total statistics since 2017-06-23 00:10:57 ***
Total inserts 70.00
..
Total operations 84.00
*** Daily statistics since 2017-07-04 00:00:00 ***
Total inserts 14.00
…
Total operations 28.00
….
End of Statistics.
Appendix : AWS RDS DBA에서 제거된 권한
 Oracle on AWS RDS에서 DBA에서 제거된 권한
 ALTER DATABASE
 ALTER SYSTEM
 CREATE ANY DIRECTORY
 CREATE EXTERNAL JOB
 DROP ANY DIRECTORY
 GRANT ANY PRIVILEGE
 GRANT ANY ROLE
 READ ANY FILE GROUP

Oracle on AWS RDS Migration - 성기명

  • 1.
    Oracle on AWSRDS Migration
  • 2.
    Oops !~~~~~  OracleDatabase 9iR2(9.2.0.8) + Data Size 300GB  HP-UX 11.11 Model 9000/800/N4000-55  CPU : PA8600(PA-RISC 2.0) 550MHz * 4EA  RAN : 6144MB(6GB)  OS/HW/DB 모두 End Of Support(EOS)
  • 3.
    Oracle on AWSRDS로 이관 시 고려 사항  Oracle Database License 관련 내용 확인  License Included와 Bring Your Own License(BYOL) 지원  License Included: Oracle DB SE One, SE Two  BYOL : 모든 Oracle DB 제품 지원  지원 가능한 Oracle DB Version?  Oracle Database 12cR1(12.1.0.2)  Oracle Database 11gR2(11.2.0.4)  지원 가능한 이관 방법은?  Exp/Imp, Data pump등 다양한 이관 방법 지원  이관 Data Size 및 임시파일(Dump File) 보관 공간 확보 여부?  Storage를 이용한 Data Dump File을 보관 가능  최대 Downtime 가능 시간은?  무 정지 이관 시 AWS DMS 및 3rd Party Tool 사용 가능  Data 성격 및 국내 IDC 존재 여부?  개인정보의 경우 국외 이전의 거의 불가능 함.
  • 4.
    Oracle on AWSRDS로 지원하는 이관 방법  Oracle SQL Developer  Oracle에서 제공하는 Java Base SQL Tool를 이용  작은 Size의 Data Migration에 적합  추가 기능을 설치하면 Mysql 및 기타 DBMS도 지원 함  Oracle Data Pump  가장 일반적인 Migration Tool 이며, 빠른 이관 속도를 보임  DBMS_FILE_TRANSFER Option을 사용 해야 함  Oracle Export/Import  전통적인 Migration Tool이며, Oracle 8i 부터 지원 함  LOB Data Type이 있을 경우 매우 느림  Oracle SQL*Loader  구분자로 구분된 Text File을 Table에 Insert 하는 방식  Oracle Materialized Views  Database link를 이용하여 Materialized Views를 이용하여 이관  CDC Tool를 이용한 이관 방법
  • 5.
    Oracle on AWSRDS 사양 및 가격(Oracle SE1) 인스턴스유형 vCPU 메모리 (GiB) 서울 도쿄 싱가폴 뭄바이 런던 db.t2.small 1 2 $0.082 $0.082 $0.082 $0.067 $0.076 db.t2.micro 1 1 $0.041 $0.041 $0.041 $0.035 $0.038 db.t2.medium 2 4 $0.164 $0.164 $0.164 $0.134 $0.151 db.t2.large 2 8 $0.382 $0.382 $0.429 $0.414 $0.311 db.r3.xlarge 4 30.5 $1.050 $1.050 $1.050 $0.972 db.r3.large 2 15 $0.525 $0.525 $0.525 $0.491 db.r3.4xlarge 16 122 $4.200 $4.200 $4.200 $3.869 db.r3.2xlarge 8 61 $2.100 $2.100 $2.100 $1.938 db.m4.xlarge 4 16 $0.944 $0.969 $0.989 $0.955 $0.966 db.m4.large 2 8 $0.470 $0.483 $0.495 $0.477 $0.483 db.m4.4xlarge 16 64 $3.775 $3.874 $3.957 $3.817 $3.863 db.m4.2xlarge 8 32 $1.888 $1.937 $1.979 $1.912 $1.932 ※2017년 06월 기준(라이선스 포함, 단일 AZ 환경)
  • 6.
    Oracle on AWSRDS 이관 구성도 AWS cloud virtual private cloud EC2 EBS Oracle DB On-Premise Oracle DB On-Premise Firewall SSH Tunnel
  • 7.
    AWSOn-Premises OGG를 이용한 Oracleon AWS RDS 개념도 Source DB OutboundProxySSH(SOCKES5Proxy) InboundProxySSH(SOCKES5Proxy) On-Premises OGG Trail File Extract Data Pump OGG Hub on EC2 Trail File Collector Replicate Target DB Oracle on AWS RDS Port 22 Key Based Authorization SOCKS Proxy Tunnel ① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨
  • 8.
    OGG를 이용한 Oracleon AWS RDS 이관 순서 순서 Source Target 1 Oracle GG Install 2 OGG Setting 3 EC2 Instance에 Oracle Client/OGG Install 4 EC2 Instance에 OGG Setting 5 Source와 Target 간 OGG 구성 6 초기 Data Export 7 EC2 Instance에서 초기 Data Import 8 EC2 에서 OGG Replicat 설정 및 기동 9 Source DB 서비스 종료 10 Listener Stop & Source DB Shutdown 11 Target DB에서 업무 시작 ※본 문서에서는 Step 8까지만 진행
  • 9.
    Step1. Oracle GoldenGate Install - Source  Oracle GG 12c 이상 필요 및 최신 PSU 적용 권장  Oracle GG 12c는 OUI Install 지원
  • 10.
    Step2. Oracle GoldenGate Setting - Source  OGG 전용 Oracle DB User 생성 및 OGG 관련 권한 부여(Sysdba로 실행) SQL> create user oggs identified by oggs; SQL> grant connect, resource to OGGS; SQL> grant select any dictionary, select any table, select any transaction to OGGS; SQL> grant SELECT on dba_clusters to OGGS; SQL> grant create table to OGGS; SQL> grant alter any table to OGGS; SQL> grant flashback any table to OGGS; SQL> grant execute on dbms_flashback to OGGS; SQL> grant execute on utl_file to OGGS; SQL> grant create session to OGGS; SQL> grant alter session to OGGS; SQL> grant insert any table to OGGS; SQL> grant delete any table to OGGS; SQL> grant update any table to OGGS; SQL> grant lock any table to OGGS;  DB Level Supplemental Log 설정(Sysdba로 실행) SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA; SQL> SELECT supplemental_ log_data_min FROM v$database; SUPPLEME -------- YES
  • 11.
    Step2. Oracle GoldenGate Setting - Source  OGG 전용 Oracle DB User에 Oracle Stream 권한 부여(Sysdba로 실행) SQL> exec dbms_streams_auth.grant_admin_privilege('oggs');  (선택)enable_goldengate_replication parameter True 설정(11.2.0.4 이상 ) SQL> alter system set enable_goldengate_replication=true scope=both; System altered. SQL> show spparameter enable_goldengate_replication SID NAME TYPE VALUE -------- ----------------------------- ----------- ---------------------------- * enable_goldengate_replication boolean TRUE  기타 필수 사항  Archive Log Mode 필수  RAC 환경인 경우 Archive Log 파일이 공유 볼륨에 있어야 한다.
  • 12.
    Step2. Oracle GoldenGate Setting - Source  OGG SubDir 생성(OS OGG User로 실행) $./ggsci GGSCI (ogg.localdomain) 1> create subdirs Creating subdirectories under current directory /OGG Parameter files /OGG/dirprm: created Report files /OGG/dirrpt: created Checkpoint files /OGG/dirchk: created Process status files /OGG/dirpcs: created SQL script files /OGG/dirsql: created Database definitions files /OGG/dirdef: created Extract data files /OGG/dirdat: created Temporary files /OGG/dirtmp: created Credential store files /OGG/dircrd: created Masterkey wallet files /OGG/dirwlt: created Dump files /OGG/dirdmp: created  Table Level Supplemental Log 설정 (OS OGG User로 실행) 디렉토리 내용 dirchk OGG Process의 Checkpoint가 기록되는 File 저장 dirdat Extract가 Capture한 Data 변경분을 저장하는 Trail File 생성 dirdef 스키마가 다른 table을 매핑하기 위해 스키마 정보가 저장되어 있는 파일 dirpcs 프로세스 상태 파일들 dirprm OGG Process 적용테이블의 Mapping 방식 및 추가 설정 Option들을 지정하는 File 생성 dirrpt OGG Process 처리내역 및 오류 시 원인 저장 dirout OGG Process 운영 시 발생하는 오류 원인 및 오류 record 내용이 기록되는 Discard File 저장 GGSCI (ogg.localdomain) 1> dblogin userid oggs password oggs Successfully logged into database. GGSCI (ogg.localdomain as oggs@OGG) 2> add schematrandata scott 2017-06-21 10:33:53 INFO OGG-01788 SCHEMATRANDATA has been added on schema scott. 2017-06-21 10:33:53 INFO OGG-01976 SCHEMATRANDATA for scheduling columns has been added on schema scott.
  • 13.
    Step2. Oracle GoldenGate Setting - Source  OGG Manager Process Parameter 생성 (OS OGG User로 실행/ggsci) GGSCI (ogg.localdomain) 1> edit param mgr --# Manager Port PORT 7800 --# Manage Trail File PURGEOLDEXTRACTS ./dirdat/ea* USECHECKPOINTS, MINKEEPDAYS 7 --# Manage Process AUTORESTART ER *, RETRIES 10, WAITMINUTES 1, RESETMINUTES 5 --# LAG LAGCRITICALSECONDS 60 -- lag 발생시 critical로 report LAGINFOSECONDS 10 -- lag 발생시 warning (초/분/시간) LAGREPORTMINUTES 1 -- check 주기 GGSCI (ogg.localdomain) 3> view param mgr --# Manager Port PORT 7800 --# Manage Trail File PURGEOLDEXTRACTS ./dirdat/ea* USECHECKPOINTS, MINKEEPDAYS 7 --# Manage Process AUTORESTART ER *, RETRIES 10, WAITMINUTES 1, RESETMINUTES 5 --# LAG LAGCRITICALSECONDS 60 -- lag 발생시 critical로 report LAGINFOSECONDS 10 -- lag 발생시 warning (초/분/시간) LAGREPORTMINUTES 1 -- check 주기
  • 14.
    Step2. Oracle GoldenGate Setting - Source  OGG Extract Process Parameter 생성 (OS OGG User로 실행/ggsci) GGSCI (ogg.localdomain) 4> edit param E_L_EXT1 EXTRACT E_L_EXT1 SETENV (NLS_LANG="American_America.KO16MSWIN949") USERID oggs , PASSWORD oggs DiscardFile ./dirout/exta.dsc, append, megabytes 500 DisCardRollover at 00:01 BR BROFF TRANLOGOPTIONS ALTARCHIVELOGDEST PRIMARY INSTANCE OGG /ORADATA/ARCH/ EXTTRAIL ./dirdat/ea table scott.ACCOUNT; table <DB USERNAME>.<Table_Name>; …. table <DB USERNAME>.<Table_Name>; GGSCI (ogg.localdomain) 5> view param E_L_EXT1 EXTRACT E_L_EXT1 SETENV (NLS_LANG="American_America.KO16MSWIN949") USERID oggs , PASSWORD oggs DiscardFile ./dirout/exta.dsc, append, megabytes 500 DisCardRollover at 00:01
  • 15.
    Step2. Oracle GoldenGate Setting - Source  Extract 프로세스 ADD (OS OGG User로 실행/ggsci) GGSCI (ogg.localdomain) 1> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER STOPPED GGSCI (ogg.localdomain) 2> start mgr Manager started. GGSCI (ogg.localdomain) 3> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING GGSCI (ogg.localdomain) 4> add extract E_L_EXT1, tranlog , threads 1, begin now EXTRACT added. GGSCI (ogg.localdomain) 5> add exttrail ./dirdat/ea , extract E_L_EXT1, megabytes 500 EXTTRAIL added. GGSCI (ogg.localdomain) 6> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING EXTRACT STOPPED E_L_EXT1 00:00:00 00:00:37
  • 16.
    Step3. EC2에 OracleClient/OGG Install - Target  Oracle Client Install  t2.micro는 SWAP 제공 되지 않음 • SWAP이 필요한 경우 참고 http://docs.aws.amazon.com/ko_kr/AWSEC2/latest/UserGuide/inst ance-store-swap-volumes.html • OUI의 “-ignoreSysPrereqs “ 옵션 사용하여 SWAP 없이 설치 가능  t2.micro는 “X Window System”를 제공 하지 않음 • Yum을 설정하여 “X Window System”은 가능 함. • OUI의 “-silent “ 옵션 사용하여 X Windows System 없이 설치 가능  OGG Silent Mode Install $ cd fbo_ggs_Linux_x64_shiphome/Disk1 $ ./runInstaller -silent INSTALL_OPTION=ORA11g > SOFTWARE_LOCATION=/OGG > START_MANAGER=true > MANAGER_PORT=7809 > DATABASE_LOCATION=/app/oracle/product/11.2.0/client_1 > INVENTORY_LOCATION=/app/oraInventory > UNIX_GROUP_NAME=dba
  • 17.
    Step4. EC2에 OracleGG Setting - Target  EC2 Instance에 사전에 Oracle Client가 설치 되어 있어야 함  OGG 전용 Oracle DB User 생성 및 권한 부여 $sqlplus awssystem/oracle1@awsorcl SQL> create user oggt identified by oggt; SQL> grant connect,resource to OGGT; SQL> grant select any dictionary, select any table, select any transaction to OGGT; SQL> grant SELECT on dba_clusters to OGGT; SQL> grant create table to OGGT; SQL> grant alter any table to OGGT; SQL> grant flashback any table to OGGT; SQL> grant execute on dbms_flashback to OGGT; SQL> grant execute on utl_file to OGGT; SQL> grant create session to OGGT; SQL> grant alter session to OGGT; SQL> grant insert any table to OGGT; SQL> grant delete any table to OGGT; SQL> grant update any table to OGGT; SQL> grant lock any table to OGGT; SQL> exec RDSADMIN.RDSADMIN_UTIL.GRANT_SYS_OBJECT ('DBA_CLUSTERS', 'OGGT'); SQL> EXEC DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE (grantee=>'OGGT', privilege_type=>'capture', grant_select_privileges=>true, do_grants=>TRUE);
  • 18.
    Step4. EC2에 OracleGG Setting - Target  DB Level Supplemental Log 설정OGG 전용 Oracle DB User 생성 및 권한 부여 $sqlplus awssystem/oracle1@awsorcl SQL> SELECT supplemental_log_data_min FROM v$database; SUPPLEME -------- NO /* --AWS RDS는 alter system 권한을 부여 하지 않음으로 아래와 같은 Error가 발생함 SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA; ALTER DATABASE ADD SUPPLEMENTAL LOG DATA * ERROR at line 1: ORA-01031: insufficient privileges */ --AWS RDS에서 rdsadmin.rdsadmin_util Package를 이용하여 변경 해야 함. SQL> exec rdsadmin.rdsadmin_util.alter_supplemental_logging('ADD'); PL/SQL procedure successfully completed. SQL> SELECT supplemental_log_data_min FROM v$database; SUPPLEME -------- YES
  • 19.
    Step4. EC2에 OracleGG Setting - Target  Archive Log 확인 /* --AWS RDS는 alter system 권한을 부여 하지 않음으로 아래와 같은 Error가 발생함 SQL> archive log list ORA-01031: insufficient privileges SQL> */ SQL> select NAME from V$ARCHIVED_LOG; NAME -------------------------------------------------------------------------------- /rdsdbdata/db/ORCL_A/arch/redolog-2753-1-943298393.arc /rdsdbdata/db/ORCL_A/arch/redolog-2754-1-943298393.arc /* --AWS RDS는 alter system 권한을 부여 하지 않음으로 아래와 같은 Error가 발생함 SQL> alter system switch logfile; alter system switch logfile * ERROR at line 1: ORA-01031: insufficient privileges */ SQL> exec rdsadmin.rdsadmin_util.switch_logfile; PL/SQL procedure successfully completed.
  • 20.
    Step4. EC2에 OracleGG Setting - Target  Archive Log 확인 /* --AWS RDS는 alter system 권한을 부여 하지 않음으로 아래와 같은 Error가 발생함 SQL> alter system checkpoint; alter system checkpoint * ERROR at line 1: ORA-01031: insufficient privileges */ SQL> exec rdsadmin.rdsadmin_util.checkpoint; PL/SQL procedure successfully completed. SQL> select NAME from V$ARCHIVED_LOG; NAME -------------------------------------------------------------------------------- /rdsdbdata/db/ORCL_A/arch/redolog-2753-1-943298393.arc /rdsdbdata/db/ORCL_A/arch/redolog-2754-1-943298393.arc /rdsdbdata/db/ORCL_A/arch/redolog-2755-1-943298393.arc /rdsdbdata/db/ORCL_A/arch/redolog-2756-1-943298393.arc SQL>
  • 21.
    Step4. EC2에 OracleGG Setting - Target  enable_goldengate_replication parameter True 설정(11.2.0.4 이상만) /* --AWS RDS는 alter system 권한을 부여 하지 않음으로 아래와 같은 Error가 발생함 SQL> alter system set enable_goldengate_replication=true scope=both; alter system set enable_goldengate_replication=true scope=both * ERROR at line 1: ORA-01031: insufficient privileges */  RDS Dashboard -> Parameter Groups 에서 생성 후 Restart 해야 함
  • 22.
    Step4. EC2에 OracleGG Setting - Target  OGG Subdir 생성 (OS OGG User로 실행) [aogg@ip-172-31-X-XX OGG]$ ./ggsci Oracle GoldenGate Command Interpreter for Oracle Version 12.2.0.1.170221 OGGCORE_12.2.0.1.0OGGBP_PLATFORMS_170123.1033_FBO Linux, x64, 64bit (optimized), Oracle 11g on Jan 23 2017 21:54:15 Operating system character set identified as UTF-8. Copyright (C) 1995, 2017, Oracle and/or its affiliates. All rights reserved. GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 1> create subdirs Creating subdirectories under current directory /OGG Parameter files /OGG/dirprm: created Report files /OGG/dirrpt: created Checkpoint files /OGG/dirchk: created Process status files /OGG/dirpcs: created SQL script files /OGG/dirsql: created Database definitions files /OGG/dirdef: created Extract data files /OGG/dirdat: created Temporary files /OGG/dirtmp: created Credential store files /OGG/dircrd: created Masterkey wallet files /OGG/dirwlt: created Dump files /OGG/dirdmp: created GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 2>
  • 23.
    Step4. EC2에 OracleGG Setting - Target  Local System OGG GLOBALS 파라미터 설정 (OS OGG User로 실행) GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 1> edit param mgr --# Manager Port PORT 7800 PURGEOLDEXTRACTS ./dirdat/ea* USECHECKPOINTS, MINKEEPDAYS 7 --# Manage Process AUTORESTART ER *, RETRIES 10, WAITMINUTES 1, RESETMINUTES 5 --# LAG LAGCRITICALSECONDS 60 -- lag 발생시 critical로 report LAGINFOSECONDS 10 -- lag 발생시 warning (초/분/시간) LAGREPORTMINUTES 1 -- check 주기 GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 2> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER STOPPED GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 3> start mgr Manager started. GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 4> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING
  • 24.
    Step5. S/T간 OGGSetting - Source  Local System OGG GLOBALS 파라미터 설정 (OS OGG User로 실행) GGSCI (ogg.localdomain) 1> edit param ./GLOBALS Checkpointtable oggs.chkpt Syslog none Ggschema oggs  Local System EXTRACT 시작 (OS OGG User로 실행) GGSCI (ogg.localdomain) 1> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING EXTRACT STOPPED E_L_EXT1 00:00:00 00:07:04 GGSCI (ogg.localdomain) 2> start E_L_EXT1 Sending START request to MANAGER ... EXTRACT E_L_EXT1 starting GGSCI (ogg.localdomain) 3> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING EXTRACT STARTING E_L_EXT1 00:00:00 00:07:14
  • 25.
    Step5. S/T간 OGGSetting - Target  Local System과 AWS EC2 OGG Hub간 SSH 구성 (OS OGG User로 실행) [aogg@ip-172-31-X-XX OGG]$ ./ggsci GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 1> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 2> edit param mgr PORT 7800 PURGEOLDEXTRACTS ./dirdat/ea* USECHECKPOINTS, MINKEEPDAYS 7 AUTORESTART ER *, RETRIES 10, WAITMINUTES 1, RESETMINUTES 5 --# Enable secrule for collector ACCESSRULE, PROG COLLECTOR, IPADDR ec2-52-78-XXX-XXX.ap-northeast- 2.compute.amazonaws.com, ALLOW --# LAG LAGCRITICALSECONDS 60 -- lag 발생시 critical로 report LAGINFOSECONDS 10 -- lag 발생시 warning (초/분/시간) LAGREPORTMINUTES 1 -- check 주기 GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 3> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING
  • 26.
    Step5. S/T간 OGGSetting - Source  Start SSH Proxy Server on Local OGG System Setting (OS OGG User) [logg@ogg OGG]$ pwd /OGG [logg@ogg OGG]$ ssh -i "/home/logg/CDC_EC2_OGG.pem" -v -N -f -D 127.0.0.1:8888 aogg@ec2- 52-78-XXX-XXX.ap-northeast-2.compute.amazonaws.com > ./dirrpt/socks.log 2>&1  Verify the SSH Socks Proxy server process (OS OGG User) [logg@ogg OGG]$ cat ./dirrpt/socks.log OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 56: Applying options for * debug1: Connecting to ec2-52-78-XXX-XXX.ap-northeast-2.compute.amazonaws.com [52.78.230.216] port 22. …… Authenticated to ec2-52-78-XXX-XXX.ap-northeast-2.compute.amazonaws.com ([52.78.230.216]:22). debug1: Local connections to 127.0.0.1:8888 forwarded to remote address socks:0 debug1: Local forwarding listening on 127.0.0.1 port 8888. debug1: channel 0: new [port listener] debug1: Requesting [email protected] debug1: forking to background debug1: Entering interactive session. [logg@ogg OGG]$
  • 27.
    Step5. S/T간 OGGSetting - Source  Local System OGG Restart (OS OGG User) GGSCI (ogg.localdomain) 1> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER STOPPED EXTRACT STOPPED E_L_EXT1 00:00:00 00:01:05 GGSCI (ogg.localdomain) 2> start mgr Manager started. GGSCI (ogg.localdomain) 3> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING EXTRACT STOPPED E_L_EXT1 00:00:00 00:01:11 GGSCI (ogg.localdomain) 4> start E_L_EXT1 Sending START request to MANAGER ... EXTRACT E_L_EXT1 starting GGSCI (ogg.localdomain) 5> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING EXTRACT RUNNING E_L_EXT1 00:00:00 00:00:00
  • 28.
    Step5. S/T간 OGGSetting - Source  Local system -> EC2 OGG Pump 생성(OS OGG User) [logg@ogg OGG]$ ./ggsci GGSCI (ogg.localdomain) 1> edit param P_L_AWS EXTRACT P_L_AWS DiscardFile ./dirout/pumpaws.dsc, append, megabytes 500 DisCardRollover at 00:01 REPORTCOUNT EVERY 1 MINUTES, RATE EOFDELAYCSECS 10 FLUSHCSECS 10 CHECKPOINTSECS 2 PASSTHRU --GETTRUNCATES RMTHOST ec2-52-78-XXX-XXX.ap-northeast-2.compute.amazonaws.com, MGRPORT 7800, SOCKSPROXY 127.0.0.1:8888 RMTTRAIL ./dirdat/r1 table <DB USERNAME>.<Table_Name>; …. table <DB USERNAME>.<Table_Name>; RMTTRAIL ./dirdat/r2 table <DB USERNAME>.<Table_Name>; …. table <DB USERNAME>.<Table_Name>;
  • 29.
    Step5. S/T간 OGGSetting - Source  Local system -> EC2 OGG Pump 생성(OS OGG User) GGSCI (ogg.localdomain) 2> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING EXTRACT RUNNING E_L_EXT1 00:00:00 00:00:00 GGSCI (ogg.localdomain) 3> add extract P_L_AWS, exttrailsource ./dirdat/ea EXTRACT added. GGSCI (ogg.localdomain) 4> add rmttrail ./dirdat/r1 , extract P_L_AWS, megabytes 500 RMTTRAIL added. GGSCI (ogg.localdomain) 5> add rmttrail ./dirdat/r2 , extract P_L_AWS, megabytes 500 RMTTRAIL added. GGSCI (ogg.localdomain) 8> start EXTRACT P_L_AWS Sending START request to MANAGER ... EXTRACT P_L_AWS starting GGSCI (ogg.localdomain) 9> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING EXTRACT RUNNING E_L_EXT1 00:00:00 00:00:06 EXTRACT RUNNING P_L_AWS 00:00:00 00:00:01
  • 30.
    Step6. 초기 DataExport - Source  rows=n 옵션 사용 Schema Export (OS Oracle User) [oracle@ogg STAGE]$ exp system/welcome1 owner=SCOTT rows=n file=00_exp_scott_no_data.dmp log=00_exp_scott_no_data.log . exporting foreign function library names for user SCOTT . exporting PUBLIC type synonyms . exporting private type synonyms . exporting object type definitions for user SCOTT About to export SCOTT's objects ... . exporting database links . exporting sequence numbers . exporting cluster definitions . about to export SCOTT's tables via Conventional Path ... . . exporting table ACCOUNT [oracle@ogg STAGE]$
  • 31.
    Step6. 초기 DataExport - Source  FLASHBACK_SCN 이용하여 특정 시점 Data export (OS Oracle User) [oracle@ogg STAGE]$ sqlplus “/as sysdba” SQL> COL CURRENT_SCN for 99999999999999999999999999999 SQL> SELECT dbms_flashback.get_system_change_number as CURRENT_SCN FROM DUAL; CURRENT_SCN ------------------------------ 750720 SQL> exit [oracle@ogg STAGE]$ exp system/welcome1 owner=SCOTT file=02_exp_scott_data.dmp log=02_exp_scott_data.log FLASHBACK_SCN=750720 Export: Release 11.2.0.4.0 - Production on Thu Jun 22 16:06:21 2017 . exporting object type definitions for user SCOTT About to export SCOTT's objects ... . about to export SCOTT's tables via Conventional Path ... . . exporting table ACCOUNT 28969 rows exported …… . exporting post-schema procedural objects and actions . exporting statistics Export terminated successfully without warnings. [oracle@ogg STAGE]$  FTP를 이용하여 EC2에 이동
  • 32.
    Step7. EC2 에서초기 Data Import - Target  Schema Import (OS Oracle User) [oracle@ip-172-31-X-XX WORK]$ imp awssystem/oracle1@awsorcl FROMUSER=SCOTT TOUSER=SCOTT file=00_exp_scott_no_data.dmp Import: Release 11.2.0.4.0 - Production on Thu Jun 22 02:59:50 2017 ….. . importing SCOTTs objects into SCOTT Import terminated successfully without warnings.  Data Import (OS Oracle User) [oracle@ip-172-31-X-XX WORK]$ time imp awssystem/oracle1@awsorcl FROMUSER=SCOTT TOUSER=SCOTT file=02_exp_scott_data.dmp DATA_ONLY=Y Import: Release 11.2.0.4.0 - Production on Thu Jun 22 03:22:30 2017 . . importing table "S_GOGAEK" 378789 rows imported . . importing table "S_JAEGO" 274276 rows imported . . importing table "S_ZIPCODE" 49033 rows imported Import terminated successfully without warnings. real 9m24.253s user 0m18.202s sys 0m2.560s' [oracle@ip-172-31-X-XX WORK]$
  • 33.
    Step8. EC2 에서OGG Replicat 설정 및 기동 - Target  AWS EC2 Hub에 OGG Replicat 파라미터 설정 (OS OGG User) [aogg@ip-172-31-X-XX OGG]$ ./ggsci GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 1> edit param R_L_AWS1 REPLICAT R_L_AWS1 SETENV (NLS_LANG="American_America.KO16MSWIN949") USERID oggt@awsorcl , PASSWORD oggt DiscardFile ./dirout/rep01.dsc, append, megabytes 100 DisCardRollover at 00:01 REPORTCOUNT EVERY 1 MINUTES, RATE ASSUMETARGETDEFS MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>; MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>; MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>; MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>; MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>;
  • 34.
    Step8. EC2 에서OGG Replicat 설정 및 기동 - Target  AWS EC2 Hub에 OGG Replicat 파리미터 설정 (OS OGG User) GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 3> edit param R_L_AWS2 REPLICAT R_L_AWS2 SETENV (NLS_LANG="American_America.KO16MSWIN949") USERID oggt@awsorcl , PASSWORD oggt DiscardFile ./dirout/rep01.dsc, append, megabytes 100 DisCardRollover at 00:01 REPORTCOUNT EVERY 1 MINUTES, RATE ASSUMETARGETDEFS MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>; MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>; MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>; MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>; MAP <DBUSERNAME>.<TABLENAME>, TARGET <DBUSERNAME>.<TABLENAME>; GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 4> edit param ./GLOBALS Checkpointtable oggt.chkpt Syslog none Ggschema oggt
  • 35.
    Step8. EC2 에서OGG Replicat 설정 및 기동 - Target  AWS EC2 Hub에 OGG Replicat 등록 및 시작 (OS OGG User) GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 5> add replicat R_L_AWS1, exttrail ./dirdat/r1, checkpointtable oggt.chkpt REPLICAT added. GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 6> add replicat R_L_AWS2, exttrail ./dirdat/r2, checkpointtable oggt.chkpt REPLICAT added. GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 7> info all Program Status Group Lag at Chkpt Time Since Chkpt MANAGER RUNNING REPLICAT STOPPED R_L_AWS1 00:00:00 00:00:28 REPLICAT STOPPED R_L_AWS2 00:00:00 00:00:03 GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 8> start replicat R_L_AWS1, aftercsn 750720 Sending START request to MANAGER ... REPLICAT R_L_AWS1 starting GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 9> start replicat R_L_AWS2, aftercsn 750720 Sending START request to MANAGER ... REPLICAT R_L_AWS2 starting
  • 36.
    Step8. EC2 에서OGG Replicat 설정 및 기동 - Target  동기화 확인 (OS OGG User) [aogg@ip-172-31-X-XX OGG]$ ./ggsci GGSCI (ip-172-31-X-XX.ap-northeast-2.compute.internal) 1> stats R_L_AWS1 Sending STATS request to REPLICAT R_L_AWS1 ... Start of Statistics at 2017-07-04 01:47:17. Replicating from SCOTT.EMP to SCOTT.EMP: *** Total statistics since 2017-06-23 00:10:57 *** Total inserts 70.00 .. Total operations 84.00 *** Daily statistics since 2017-07-04 00:00:00 *** Total inserts 14.00 … Total operations 28.00 …. End of Statistics.
  • 37.
    Appendix : AWSRDS DBA에서 제거된 권한  Oracle on AWS RDS에서 DBA에서 제거된 권한  ALTER DATABASE  ALTER SYSTEM  CREATE ANY DIRECTORY  CREATE EXTERNAL JOB  DROP ANY DIRECTORY  GRANT ANY PRIVILEGE  GRANT ANY ROLE  READ ANY FILE GROUP