[운영 종료] TmaxTibero Tech Blog

티맥스티베로 공식 블로그는 https://tmaxtibero.blog/ 로 이전되었습니다.

티맥스티베로 공식 블로그 이전 자세히보기

인터페이스, 연동

[Tibero] DBLINK 설정_Tibero to PostgreSQL (1)

TmaxTiberotech 2023. 7. 31. 15:11

본 문서에서는 Tibero Java Gateway을 이용한 Tibero to PostgreSQL DB Link 설정 및

테스트 환경 구축을 위한 PostgreSQL 설치 방법을 안내 합니다.

테스트 구성 환경

OS
PostgreSQL
Java Gateway
Tibero
Version : Red Hat
Enterprise Linux Server
release 7.4
IP : 192.168.0.180
Version : PostgreSQL 12.3
OS user : postgres
DB name : test
DB user : pg
Port : 5432
Port : 9099
Version : Tibero 6
(DB 6.0 FS07_CS_1912)
OS user : nam
DB name : tibero
DB user : nam
Port : 18629

 

DBLink 설정 및 확인

1. Java Gateway

1.1. tbJavaGW.zip 압축 해제

[nam@www:/home/nam/tibero6/client/bin]$ unzip tbJavaGW.zip
Archive: tbJavaGW.zip
  creating: tbJavaGW/
  creating: tbJavaGW/lib/
inflating: tbJavaGW/jgw.cfg
inflating: tbJavaGW/jgw_service.bat
inflating: tbJavaGW/jgwlog.properties
inflating: tbJavaGW/lib/commons-collections.jar
inflating: tbJavaGW/lib/commons-daemon-1.0.6.jar
inflating: tbJavaGW/lib/commons-pool.jar
inflating: tbJavaGW/lib/log4j-1.2.15.jar
inflating: tbJavaGW/lib/tbgateway.jar
inflating: tbJavaGW/tbgw

1.2. Java Gateway 설정

[nam@www:/home/nam/tibero6/client/bin/tbJavaGW]$ vi jgw.cfg
# Target database
DATABASE=POSTGRESQL
 
# Datasource class name for target database
# use with DATABASE=JDBC30 option.
#DATASOURCE_CLASS_NAME=com.tmax.tibero.jdbc.ext.TbDataSource
 
# XA datasource class name for target database
# use with DATABASE=JDBC30 option.
#XA_DATASOURCE_CLASS_NAME=com.tmax.tibero.jdbc.ext.TbXADataSource
 
# Listener port
LISTENER_PORT=9099
 
# Initial thread pool size
INIT_POOL_SIZE=10
 
# Max thread pool size
MAX_POOL_SIZE=100
 
# Max cursor cache size per thread
MAX_CURSOR_CACHE_SIZE=100
 
# Gateway Encoding-"ASCII", "EUC-KR", "MSWIN949", "UTF-8", "UTF-16", "SHIFT-JIS"
ENCODING=MSWIN949
 
# Max length for Types.LONGVARCHAR
MAX_LONGVARCHAR=4K
 
# Max length for Types.LONGRAW
MAX_LONGRAW=4K

1.3. Postgres JDBC 업로드

아래 링크를 참고해 JDK 버전에 맞는 JDBC를 사용합니다.

 

 

 

Download | pgJDBC

Download Binary JAR file downloads of the JDBC driver are available here and the current version with Maven Repository. Because Java is platform neutral, it is a simple process of just downloading the appropriate JAR file and dropping it into your classpat

jdbc.postgresql.org

 
[nam@www:/home/nam/tibero6/client/bin/tbJavaGW/lib]$ ls -al
total 3028
drwxr-xr-x 2 nam dba 4096 Nov 4 13:44 .
drwxr-xr-x 4 nam dba 4096 Nov 5 09:46 ..
-rw-r--r-- 1 nam dba 559366 Dec 8 2020 commons-collections.jar
-rw-r--r-- 1 nam dba 24019 Dec 8 2020 commons-daemon-1.0.6.jar
-rw-r--r-- 1 nam dba 42492 Dec 8 2020 commons-pool.jar
-rw-r--r-- 1 nam dba 391834 Dec 8 2020 log4j-1.2.15.jar
-rw-r--r-- 1 nam dba 906887 Nov 3 15:11 postgresql-42.2.8.jre7.jar
-rw-r--r-- 1 nam dba 483205 Dec 8 2020 tbgateway.jar

1.4. tbgw 수정

[nam@www:/home/nam/tibero6/client/bin/tbJavaGW]$ vi tbgw
#! /bin/sh
 
#Classpath
commonsdaemon=./lib/commons-daemon-1.0.6.jar
commonspool=./lib/commons-pool.jar
commonscollections=./lib/commons-collections.jar
log4j=./lib/log4j-1.2.15.jar
msjdbc=./lib/sqljdbc.jar:./lib/sqljdbc4.jar
asejdbc=./lib/jconn3.jar
postgresqljdbc=./lib/postgresql-42.2.8.jre7.jar
gateway=./lib/tbgateway.jar
 
#log4j properties
#log4jfile must be exists on classpath
log4jfile=jgwlog.properties
 
#Main Class
mainclass=com.tmax.tibero.gateway.main.GatewayMain
configfile=./jgw.cfg
 
if [[ $# -gt 0 ]] && [[ $1 = "-v" ]] ; then
   java -jar $gateway
else
                  java -Xms128m -Xmx512m -Dlog4j.configuration=$log4jfile -classpath
$commonsdaemon:$commonspool:$commonscollections:$log4j:$gateway:$msjdbc:$asejdbc:
$postgresqljdbc:. $mainclass CONFIG=$configfile $* &
     sleep 1
fi

1.5. tbgw 실행

[nam@www:/home/nam/tibero6/client/bin/tbJavaGW]$ ./tbgw
-------------------------------
Name : TmaxData JAVA GATEWAY
Database: 5
Port : 9099
-------------------------------