반응형

◎ 테스트 환경

OS : CentOS Stream release 8

DB : Oracle Database 19c Enterprise Edition Release 19.3.0.0.0

 

 

 

1. /etc/trino 디렉터리에 catalog라는 디렉터리를 생성합니다.

[root@centos8-oracle19 ~]# cd /etc/trino

[root@centos8-oracle19 trino]# mkdir catalog

[root@centos8-oracle19 trino]# ls -rlt
total 20
-rw-r--r--. 1 trino trino  52 Sep 29 16:55 log.properties
-rw-r--r--. 1 trino trino 510 Sep 29 16:55 jvm.config
-rw-r--r--. 1 trino trino 201 Sep 29 16:55 config.properties
-rw-r--r--. 1 trino trino 237 Oct  6 00:55 node.properties
-rw-r--r--. 1 trino trino  96 Oct  6 00:55 env.sh
drwxr-xr-x. 2 root  root   36 Oct 12 01:54 catalog

 

2. /etc/trino/catalog 디렉토리에 Oracle Databae에 접속하기 위한 .properties 파일을 생성합니다. (파일명은 원하는 이름으로)

[root@centos8-oracle19 catalog]# vi oracle-orcl.properties

connector.name=oracle
# The correct syntax of the connection-url varies by Oracle version and
# configuration. The following example URL connects to an Oracle SID named
# "orcl".
connection-url=jdbc:oracle:thin:@localhost:1521:orcl
connection-user=system
connection-password=<system 계정의 패스워드>

 localhost 부분에는 실제 Oracle Database 서버의 IP를 입력 합니다. (ex: http://xxx.xxx.xxx.xxx)

 1521은 Oracle Database의 LISTENER의 PORT를 입력합니다.

 orcl은 Oracle Database의 SID를 입력합니다.

 

3. Trino를 이용하여 Oracle Database에 접속합니다.

[root@centos8-oracle19 trino]# ./trino --server localhost:8080

trino>

 해당 테스트 환경에서는 Oracle Database가 설치되어 있는 환경으로 IP 대신 localhost를 입력했습니다.

 

4. Oracle Database의 scott 유저의 dept라는 테이블을 조회해 봅니다.

trino> select * from "oracle-orcl".scott.dept;
 deptno |   dname    |   loc
--------+------------+----------
     10 | ACCOUNTING | NEW YORK
     20 | RESEARCH   | DALLAS
     30 | SALES      | CHICAGO
     40 | OPERATIONS | BOSTON
(4 rows)

Query 20221007_011946_00002_5vsb4, FINISHED, 1 node
Splits: 1 total, 1 done (100.00%)
1:54 [4 rows, 0B] [0 rows/s, 0B/s]

 Trino에서 SELECT 쿼리 입력 시, ".properties name".user name.table name으로 조회해야 합니다.

 

5. 실제 Oracle Database에 SQL PLUS로 접속하여 scott 유저의 dept 테이블을 조회해보면 결과가 같은 것을 확인할 수 있습니다.

[root@centos8-oracle19 ~]# su - oracle
Last login: Fri Oct  7 01:27:05 GMT 2022 on pts/0

[oracle@centos8-oracle19 ~]$ sqlplus scott/tiger

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Oct 12 01:58:01 2022
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Last Successful login time: Fri Oct 07 2022 01:12:08 +00:00

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> select * from dept;

    DEPTNO DNAME	  LOC
---------- -------------- -------------
    	10 ACCOUNTING	  NEW YORK
    	20 RESEARCH	  DALLAS
    	30 SALES	  CHICAGO
    	40 OPERATIONS	  BOSTON
반응형

'data platform > trino' 카테고리의 다른 글

Trino Client 설치  (0) 2022.11.11
Trino 설치  (0) 2022.11.11
  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기