Site icon DBA의 정석

Oracle Gateway 이기종 DB Link

 

1             Gateway 개요

n         이기종 Database 간의 통신을 위해서 오라클에서 제공하는 제품이다.

n         이기종 시스템 간의 SQL 변환, 데이터의 원활한 상호 운영성을 제공한다

n         Oracle 9i 버전부터 CD에 포함되어 제공되고 있으며 Gateway 서비스를 제공 받으려면 별도의 라이선스를 구매해야 한다

 

2             Gateway 원리

 

 

 

 

 

 

3             T

1             TEST 목적

 

2             TEST 환경구성

2.1           Oracle DB 정보

n         VMware Workstation 8.0

n         O/S : OEL 5 64bit (Mem 2GB)

n         Host Name : park32 (192.168.1.14)

SQL> select * from v$version;

BANNER

——————————————————————————–

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

 

2.2           DB2 DB 정보

n         VMware Workstation 8.0

n         O/S : OEL 5 64bit (Mem 2GB)

n         Host Name : unione (192.168.1.9)

[db2inst1@unione ~]$ db2level

DB21085I  This instance or install (instance name, where applicable:

“db2inst1”) uses “64” bits and DB2 code release “SQL10012” with level

identifier “0203010E”.

Informational tokens are “DB2 v10.1.0.2”, “s121127”, “IP23394”, and Fix Pack “2”.

Product is installed at “/opt/ibm/db2/V10.1”.

 

2.3           Sybase DB 정보

n         VMware Workstation 8.0

n         O/S : OEL 5 64bit (Mem 2GB)

n         Host Name : unione (192.168.1.9)

[/sybase] $isql -Usa -Psybase -Sunione

1> select @@version

2>go                                                                                                               ———————————————————————————————————————————-

Adaptive Server Enterprise/15.7.0/EBF 20373 SMP ESD#02 /P/x86_64/Enterprise

Linux/ase157esd2/3109/64-bit/FBO/Sat Jul  7 05:36:19 2012

(1 row affected)

 

3             Oracle Gateway 설치

n         Oracle Database 가 설치되어 있는 서버에 Gateway 제품을 설치한다

n         설치 파일 : p10404530_112030_Linux-x86-64_5of7.zip

[test1:/oracle]$ cd media/gateways

[test1:/oracle/media/gateways]$ ls -la

total 68

drwxr-xr-x  7 oracle dba  4096 Sep 22  2011 .

drwxr-xr-x  3 oracle dba  4096 May 24 13:30 ..

drwxr-xr-x  6 oracle dba  4096 Sep 22  2011 doc

drwxr-xr-x  4 oracle dba  4096 Sep 22  2011 install

drwxr-xr-x  4 oracle dba  4096 Sep 22  2011 legacy

-rwxr-xr-x  1 oracle dba 28122 Sep 22  2011 readme.html

drwxr-xr-x  2 oracle dba  4096 Sep 22  2011 response

-rwxr-xr-x  1 oracle dba  3226 Sep 22  2011 runInstaller

drwxr-xr-x 14 oracle dba  4096 Sep 22  2011 stage

-rwxr-xr-x  1 oracle dba  6525 Aug 23  2011 welcome.html

[test1:/oracle/media/gateways]$ ./runInstaller

n         GUI 모드 설치 화면

 

 

 

 

 

 

 

 

 

 

 

 

 

1             Gateway 설정

1.1           DB2 Gateway 파라메터 설정

[test1:/oracle/product/11g/db/dg4db2/admin]$ cat initdg4db2.ora

# This is a customized agent init file that contains the HS parameters

# that are needed for the Database Gateway for DB2

# HS init parameters

HS_FDS_CONNECT_INFO=[192.168.1.9]:50000/sample,LUW

HS_FDS_TRACE_LEVEL=OFF

HS_FDS_RECOVERY_ACCOUNT=RECOVER

HS_FDS_RECOVERY_PWD=RECOVER

HS_TRANSACTION_MODEL=COMMIT_CONFIRM

HS_FDS_TRANSACTION_ISOLATION=READ_COMMITTED

HS_FDS_SUPPORT_STATISTICS=TRUE

HS_FDS_RESULTSET_SUPPORT=FALSE

HS_FDS_PACKAGE_COLLID=ORACLEGTW

HS_IDLE_TIMEOUT=0

1.2           SYBASE Gateway 파라메터 설정

[test1:/oracle/product/11g/db/dg4sybs/admin]$ cat initdg4sybs.ora

# This is a customized agent init file that contains the HS parameters

# that are needed for the Database Gateway for Sybase

# HS init parameters

HS_FDS_CONNECT_INFO=[192.168.1.9]:5000/pubs2

HS_FDS_TRACE_LEVEL=OFF

HS_FDS_RECOVERY_ACCOUNT=RECOVER

HS_FDS_RECOVERY_PWD=RECOVER

 

2             Oracle LISTENER 설정

2.1           listener.ora 파일 설정

[test1:/oracle/product/11g/db/network/admin]$ cat listener.ora

# listener.ora Network Configuration File: /oracle/product/11g/db/network/admin/listener.ora

# Generated by Oracle configuration tools.

LISTENER =     ß 오라클 기본 리스너

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.14)(PORT = 1521))

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

)

)

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME = test1)

(ORACLE_HOME = /oracle/product/11g/db)

)

)

 

LISTENER_GW =     ß DB2 Gateway 용 리스너

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.14)(PORT = 1522))   ß Oracle Server IP

)

SID_LIST_LISTENER_GW =

(SID_LIST =

(SID_DESC =

(SID_NAME = dg4db2)     ß tnsnames.ora 에 설정 된 alias

(ORACLE_HOME = /oracle/product/11g/db)

(ENV=”LD_LIBRARY_PATH=/oracle/product/11g/db/dg4db2/driver/lib;/oracle/product/11g/db/lib”) (PROGRAM = dg4db2)

)

)

 

LISTENER_SB =     ß Sybase Gateway 용 리스너

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.14)(PORT = 1523))   ß Oracle Server IP

)

SID_LIST_LISTENER_SB =

(SID_LIST =

(SID_DESC =

(SID_NAME = dg4sybs)     ß tnsnames.ora 에 설정 된 alias

(ORACLE_HOME = /oracle/product/11g/db)

(ENV=LD_LIBRARY_PATH=/oracle/product/11g/db/dg4sybs/driver/lib;/oracle/product/11g/db/lib”)

(PROGRAM = dg4sybs)

)

)

 

ADR_BASE_LISTENER = /oracle

 

2.2           tnsnames.ora 파일 설정

[test1:/oracle/product/11g/db/network/admin]$ cat tnsnames.ora

TEST1 =   ß Oracle TNS 명

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.14)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = TEST1)

)

)

 

dg4db2 =   ß DB2 TNS 명

(description =

(address = (protocol = tcp)(host = 192.168.1.14)(port = 1522))   ß Oracle Server IP

(connect_data = (sid = dg4db2))

(HS = OK)   ß 이기종 DB 간 연결을 허용

)

dg4sybs =    ß Sybase TNS 명

(description =

(address = (protocol = tcp)(host = 192.168.1.14)(port = 1523))    ß Oracle Server IP

(connect_data = (sid = dg4sybs))

(HS = OK)    ß 이기종 DB 간 연결을 허용

)

 

2.3           LISTENER 시작

[test1:/oracle]$ lsnrctl start LISTENER_GW

 

LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 14-JUN-2013 16:59:21

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Starting /oracle/product/11g/db/bin/tnslsnr: please wait…

 

(중략)

 

Service “dg4db2” has 1 instance(s).

Instance “dg4db2”, status UNKNOWN, has 1 handler(s) for this service…

The command completed successfully

 

[test1:/oracle]$ lsnrctl start LISTENER_SB

 

LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 14-JUN-2013 17:02:31

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Starting /oracle/product/11g/db/bin/tnslsnr: please wait…

 

(중략)

 

Service “dg4sybs” has 1 instance(s).

Instance “dg4sybs”, status UNKNOWN, has 1 handler(s) for this service…

The command completed successfully

 

 

3             DB Link 생성

연결하여 사용하면 된다.

SQL> create public database link 링크명 connect to 유저명 identified by 패스워드

using ‘TNSNAMES.ORA에서 지정한 서비스명‘;

 

3.1           DB2 연결을 위한 DB Link 생성

SQL> create public database link DB2_LINK connect to db2inst1 identified by db2inst1 using ‘dg4db2’;

Database link created.

 

3.2           SYBASE 연결을 위한 DB Link 생성

SQL> create public database link sb_link connect to “sa” identified by “sybase” using ‘dg4sybs’;

Database link created.

 

3.3           DB Link 생성 확인

SQL> select * from dba_db_links;

 

OWNER    DB_LINK        USERNAME     HOST      CREATED

———-    ————     ————        ————  ——————-

PUBLIC     DB2_LINK      DB2INST1      dg4db2     2013-05-24:13:48:31

PUBLIC     SB_LINK        sa                 dg4sybs   2013-05-24:13:58:24

 

 

 

4             Gateway 데이터 조회 (select)

4.1           Oracle – DB2 데이터 조회

 

 

 

n        Oracle Databae 에서 dblink 를 통해‘staff’ 테이블 조회 성공

 

 

 

9.2           Oracle – Sybase 데이터 조회

 

n        Sybase Databae 에서 ‘sales’ 테이블 조회(Instance Name : pubs2)

 

 

 

 

n        Oracle Databae 에서 dblink 를 통해 ‘sales’ 테이블 조회 실패

 

 

n        중요) 위에서도 언급 했듯이 Sybase 에서는 /소문자를 엄격하게 구별한다

따라서 테이블 명을 비롯한 모든 필드명에 반드시 “-“ 따옴표를 붙여 구별해 주어야 한다

n        Oracle Databae 에서 dblink 를 통해 “sales” 테이블 조회 성공

 

 

 

10       Gateway 데이터 이행 (migration)

 

n        create table ~ as ~ select 명령문을 사용하여 테이블 및 데이터를 가져올 수 있다

 

SQL> create table table_name as (select * from target_table_name@db_link);

 

 

10.1     Oracle – DB2 데이터 이행

 

n        Oracle Databae 에서 dblink 를 통해 DB2 의 ‘staff’ 테이블 생성 성공

SQL> create table staff as
(select * from staff@DB2_LINK);

Table created.

 

n        Oracle 에서 생성된 ‘staff’ 테이블 조회 확인

 

 

10.2     Oracle – Sybase 데이터 이행

 

n         Oracle Databae 에서 dblink 를 통해 Sybase 의 ‘sales’ 테이블 생성 성공

 

 

SQL> create table sales as
(select * from “sales”@SB_LINK);

 

Table created.

 

 

n        Oracle 에서 생성된 ‘sales’ 테이블 조회 확인

 

 

Exit mobile version