DB Link ์์ฑ ๋ฐ ํ์ธ
DB Link ์์ฑ ๋ฐฉ๋ฒ์ Local๊ณผ Listener ๋ฐฉ์์ด ๋์ผํฉ๋๋ค.
Local ๋ฐฉ์์์๋ Gateway ํ๋ก์ธ์ค์ ๊ธฐ๋์ด ํ์ํ์ง ์์ต๋๋ค.
๋ค์์ DB Link ์์ฑ๊ณผ ํ์ธ ๋ฐฉ๋ฒ์ ๋ํ ์ค๋ช ์ ๋๋ค.
DB Link ์์ฑ ํ์ธ ์
DB Link ์์ฑ์ ํ์ธํ ๋ select๋ฌธ์ 'Table๋ช @< DB Link๋ช >'์ผ๋ก ์ค์ ํ๋ฉด DB Link๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
DB Link ์ด์ฉํ์ฌ Oracle์ Table ์กฐํ ์
Oracle ์ Table ์์ฑ ํ ์์ฑํ Database Link ๋ฅผ ์ด์ฉํ์ฌ ์กฐํํ๋ ์์์ ๋๋ค.
Oracle ์ test ํ ์ด๋ธ์ ์์ฑํฉ๋๋ค.
DB Link ํ์ธ ์
DB Link ์์ฑ ํ ํ์ธ์ ํ๋ ๊ฒฝ์ฐ select ๋ฌธ์ 'Table๋ช @< DB Link๋ช >'์ผ๋ก ์ค์ ํ๋ฉด DB Link๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
they support single-sitetransactions only.Gateways are an integral component of the overall hetero geneous connectivity solution. Specifically, they provide: SQL and Data Dictionary Translation infor mation
$ tbsql sys/tibero@tibero_a
tbSQL 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Connected to Tibero using tibero_a.
SQL> select * from v$instance;
INSTANCE_NUMBER INSTANCE_NAME DB_NAME HOST_NAME PARALLEL THREAD# VERSION
STARTUP_TIME STATUS SHUTDOWN_PENDING TIP_FILE
----------------- ------------ ---------- --------- ------- ----------------
--------------------- ----------------------------------
0 tibero tibero dqa-optane1 NO 0 7
2023/06/12 NORMAL NO
/hdd/home/sampler22/tibero7/config/tibero.tip
1 row selected.
SQL> create database link < DB LINK๋ช > connect to < ์ ์ ์ฌ์ฉ์ ID > identified by < ์ ์ ํจ์ค์๋ >
2 using < ์ ์์ ์ฌ์ฉํ alias >;
ํญ๋ชฉ
์ค๋ช
< DB LINK๋ช >
์์ฑํ DB Link Object ์ด๋ฆ์ด๋ค.
< ์ ์ ์ฌ์ฉ์ ID >
๋์ DB ์๋ฒ์ ์ ์ํ ์ฌ์ฉ์ ์ด๋ฆ์ด๋ค.
< ์ ์ ํจ์ค์๋ >
๋์ DB ์๋ฒ์ ์ ์ํ ํจ์ค์๋์ด๋ค.
$ tbsql tibero/tmax
tbSQL 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Connected to Tibero.
SQL> create database link T7LINK connect to tibero identified by 'tmax'
2 using 'tibero_a';
Database Link 'T7LINK' created.
SQL> CONN tibero/tmax
Connected to Tibero.
SQL> ls
NAME SUBNAME TYPE
-------------------------------- ------------------ -------------------
T7LINK DATABASE LINK
SQL> select * from dual@T7LINK;
DUMMY
-------
X
1 row selected.
GLOBAL : ๊ธ๋ก๋ฒ ํธ๋์ญ์ ์ธ ๊ฒฝ์ฐ ์ค์ ๊ฐ์ด๋ค.
LOCAL : ๋ก์ปฌ ํธ๋์ญ์ ์ธ ๊ฒฝ์ฐ ์ค์ ๊ฐ์ด๋ค.
[/yuha/t7/tibero7/client/config]$ sqlplus tibero/tmax@ORCL
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jun 14 14:56:07 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Last Successful login time: Wed Jun 14 2023 14:55:11 +09:00
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL>
# gateway for oracle
# local
gw_local=(
(GATEWAY=
(PROGRAM=/yuha/t7/gateway/gw4orcl)
(TARGET=ORCL)
(TX_MODE=GLOBAL)
)
)
$ cd $TBGW_HOME/oracle/config
$ vi tbgw.cfg
LOG_DIR=/yuha/t7/gateway/oracle/log
LOG_LVL=2
MAX_LOG_SIZE=502400000
create database link <DB Link๋ช > connect to <user๋ช > identified by '<password>'
using '<Network Alias๋ช >';
GRANT CREATE DATABASE LINK TO USER_NAME;
GRANT CREATE PUBLIC DATABASE LINK TO USER_NAME;
$ tbsql tibero/tmax
tbSQL 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Connected to Tibero.
SQL> create database link T7LINK connect to tibero identified by 'tmax'
2 using 'gw_local';
Database Link 'T7LINK' created.
$ tbsql tibero/tmax
tbSQL 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Connected to Tibero.
SQL> select * from dual@T7LINK;
DUMMY
-------
X
1 row selected.
$ sqlplus tibero/tmax
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jun 14 16:01:10 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Last Successful login time: Wed Jun 14 2023 15:58:11 +09:00
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> create table test(c1 number);
Table created.
SQL> insert into test values(100);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from test;
C1
------------
100
$ tbsql tibero/tmax
tbSQL 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Connected to Tibero.
SQL> select * from test@T7LINK;
C1
--------
100
1 row selected.
SQL> insert into test@T7LINK values(200);
row inserted.
SQL> commit;
Commit completed.
SQL> select * from test@T7LINK;
C1
--------
100
200
2 rows selected.
GLOBAL : ๊ธ๋ก๋ฒ ํธ๋์ญ์ ์ธ ๊ฒฝ์ฐ ์ค์ ๊ฐ์ด๋ค.
LOCAL : ๋ก์ปฌ ํธ๋์ญ์ ์ธ ๊ฒฝ์ฐ ์ค์ ๊ฐ์ด๋ค.
[/yuha/t7/tibero7/client/config]$ sqlplus tibero/tmax@ORCL
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jun 14 14:56:07 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Last Successful login time: Wed Jun 14 2023 14:55:11 +09:00
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL>
$ tbsql tibero/tmax
tbSQL 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Connected to Tibero.
SQL> create database link T7LINK connect to tibero identified by 'tmax'
2 using 'gw_listen';
Database Link 'T7LINK' created.
$ tbsql tibero/tmax
tbSQL 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Connected to Tibero.
SQL> select * from dual@T7LINK;
DUMMY
-----
X
1 row selected.
$ sh gw_install.sh
Configuring gateway environment for tibero to oracle...
TBGW_HOME is /yuha/t7/gateway.
Gateway configuration file is created in /yuha/t7/gateway/oracle/config. Check the file,
and add or rewrite options if you want.
Gateway install is done.
$ tbsql tibero/tmax@gw_listen
tbSQL 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Connected to using gw_listen.
SQL> select * from dual;
DUMMY
------
X
1 row selected.
$ file $ORACLE_HOME/bin/dg4odbc
/yuha/oracle/ORA19/app/oracle/product/19.0.0/db_1/bin/dg4odbc: ELF 64-bit LSB
executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for
GNU/Linux 2.6.32, BuildID[sha1]=05c8c6e1646c7f78af76fec4fc034f83383843f1, not
stripped
# Oracle To Tibero DB Link Setting
export TB_HOME=/yuha/oracle/tibero7
export LD_LIBRARY_PATH=$TB_HOME/client/lib:$LD_LIBRARY_PATH
export PATH=$TB_HOME/client/bin:$PATH
alias nadm='cd $ORACLE_HOME/network/admin'
alias hadm='cd $ORACLE_HOME/hs/admin'
]$ lsnrctl start ltibero
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 15-JUN-2023 17:17:49
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Starting /yuha/oracle/ORA19/app/oracle/product/19.0.0/db_1/bin/tnslsnr: please
wait...
TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is
/yuha/oracle/ORA19/app/oracle/product/19.0.0/db_1/network/admin/listener.ora
Log messages written to
/yuha/oracle/ORA19/app/oracle/diag/tnslsnr/haeun/ltibero/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.17.24)
(PORT=1522)))
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.17.24)(PORT=1522))
STATUS of the LISTENER
--------------------------
Alias ltibero
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 15-JUN-2023 17:17:49
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File
/yuha/oracle/ORA19/app/oracle/product/19.0.0/db_1/network/admin/listener.ora
Listener Log File
/yuha/oracle/ORA19/app/oracle/diag/tnslsnr/haeun/ltibero/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.17.24)(PORT=1522)))
Services Summary...
Service "dg4_tibero" has 1 instance(s).
Instance "dg4_tibero", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
$ lsnrctl stop ltibero
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 15-JUN-2023 16:13:05
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.17.24)(PORT=1522))
The command completed successfully
$ lsnrctl status <listener_name>
$ lsnrctl status ltibero
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 15-JUN-2023 17:18:20
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.17.24)(PORT=1522))
STATUS of the LISTENER
-------------------------
Alias ltibero
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 15-JUN-2023 17:18:15
Uptime 0 days 0 hr. 0 min. 4 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File
/yuha/oracle/ORA19/app/oracle/product/19.0.0/db_1/network/admin/listener.ora
Listener Log File
/yuha/oracle/ORA19/app/oracle/diag/tnslsnr/haeun/ltibero/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.17.24)(PORT=1522)))
Services Summary...
Service "dg4_tibero" has 1 instance(s).
Instance "dg4_tibero", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
$ tnsping <alias_name>
$ tnsping tb7
TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 15-JUN-2023 17:18:34
Copyright (c) 1997, 2019, Oracle. All rights reserved.
Used parameter files:
/yuha/oracle/ORA19/app/oracle/product/19.0.0/db_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)
(HOST = 192.168.17.24)(PORT = 1522)) (CONNECT_DATA = (SID = dg4_tibero)) (HS = OK))
OK (0 msec)
create database link <DB Link๋ช > connect to <user๋ช > identified by "<password>" using
'<Network Alias๋ช >';
GRANT CREATE DATABASE LINK TO USER_NAME;
GRANT CREATE PUBLIC DATABASE LINK TO USER_NAME;
$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Jun 15 17:26:24 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> drop database link o2t_link;
Database link dropped.
SQL> create database link o2t_link connect to tibero identified by tmax using 'tb7';
Database link created.
SQL> select * from dual@o2t_link;
DUM
---
X
$ tbsql tibero/tmax@o2t
tbSQL 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Connected to VGliZXJv using o2t.
SQL> create table test(c1 number);
Table 'TEST' created.
SQL> insert into test values(10);
1 row inserted.
SQL> commit;
Commit completed.
$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Jun 15 17:34:02 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> select * from test@o2t_link;
C1
----------
10
SQL> insert into test@o2t_link values(20);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from test@o2t_link;
C1
----------
10
20
$ iodbctest "DSN=Tibero7;UID=tibero;PWD=tmax"
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.52.0709.0909
Driver: 07.00.0218 (libtbodbc.so)
SQL>select * from test;
C1
----------------------------------
10
20
result set 1 returned 2 rows.
HS_FDS_CONNECT_INFO=tibero
#HS_FDS_TRACE_LEVEL=DEBUG
# Tibero ODBC Driver
HS_FDS_SHAREABLE_NAME=/home/ora11/tibero5/client/lib/libtbodbc.so
# iODBC Driver Manager
#HS_FDS_SHAREABLE_NAME=/home/ora11/iodbc/lib/libiodbc.so
#HS_LANGUAGE=AMERICAN_AMERICA.KO16MSWIN949
#
# ODBC specific environment variables
#
#set ODBCINI=<full path name of the odbc initilization file>
#set ODBCINI=/home/ora11/.odbc.ini
#
# Environment variables required for the non-Oracle system
#
#set <envvar>=<value>
#set TB_NLS_LANG=UTF8
#set TBCLI_LOG_LVL=TRACE
SQL> select name, value$ from sys.props$ where name like 'NLS_CHAR%';
NAME
-----------------------------------------------------------------
VALUE$
-----------------------------------------------------------------
NLS_CHARACTERSET
AL32UTF8
SQL> conn scott/tiger
Connected.
SQL> select * from dual@tlink;
select * from dual@tlink
*
ERROR at line 1:
ORA-28511: lost RPC connection to heterogeneous remote agent using
SID=ORA-28511: lost RPC connection to heterogeneous
remote agent using
SID=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.70.185)(PORT=1522))
(CONNECT_DATA=(SID=tibero)))
ORA-02063: preceding line from TLINK
Process ID: 14824
Session ID: 8 Serial number: 14464
HS_LANGUAGE=AMERICAN_AMERICA.KO16MSWIN949
$ sqlplus scott/tiger
SQL*Plus: Release 11.2.0.1.0 Production on Tue Jun 4 14:23:11 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from dual@tlink;
DUM
---
X