platform
unbuntu 8.04
Oracle Database 10g r2
MS Sql Server 2008
필요한 package
# apt-get install unixodbc unixodbc-dev tdsodbc
freetds driver를 unixODBC에 인식# odbcinst -i -d -f /usr/share/tdsodbc/odbcinst.ini
tamplate 생성후 unixODBC에 추가# vi ms.ini
[MS]
Driver = TDS
Description = SQL Server
Trace = No
Server = 192.168.x.x
Database = test
# odbcinst -i -s -f mydsn.ini -h
또는 /etc/odbc.ini, /etc/odbcinst.ini에 직접 추가/etc/odbc.ini
[TDS]
Description = freetds
Driver = /usr/lib/odbc/libtdsodbc.so
FileUsage = 1
/etc/odbcinst.ini
[MS]
Driver = TDS
Description = SQL Server
Trace = No
Server = 192.168.x.x
Database = test
접속 테스트# isql -v MS userid password
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
여기 까지가 unixODBC와 freetds연동을 위한 설정이다. Oracle hs(Heterogeneous Services)를 추가해야 한다.여기서 부터는 oracle 계정으로 :-)
Oracle listerner 추가(listener.ora)
SID_LIST_HSODBC =
(SID_LIST =
(SID_DESC =
(SID_NAME=hsodbc)
(ORACLE_HOME=/opt/oracle/product/10r2)
(PROGRAM=/opt/oracle/product/10r2/bin/hsodbc)
(ENVS=LD_LIBRARY_PATH=/opt/oracle/product/10r2/lib:/usr/lib/) # lib from freetds
)
)
HSODBC =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.x)
(PORT = 1522))
)
)
)
tnsnames.ora 추가hs =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.x)(PORT = 1522))
)
(CONNECT_DATA =
(ORACLE_HOME = /opt/oracle/product/10r2)
(SID = hsodbc)
)
(HS = OK)
)
listener hsodbc 실행$ lsnrctl start hsodbc
$ tnsping hs
Oracle hs 설정vi $ORACLE_HOME/hs/admin/inithsodbc.ora HS_FDS_CONNECT_INFO = MS HS_FDS_TRACE_LEVEL = 4 HS_FDS_TRACE_FILE_NAME = /tmp/ms.trc HS_FDS_SHAREABLE_NAME = /usr/lib/libodbc.so # lib from unixODBC set ODBCINI=/etc/odbc.iniOracle database link 설정 및 테스트
SQL> create database link ms connect to "userid" identified by "password" using 'hs';
ok
SQL> select * from test@ms;
...
...
...
SQL>
isql로는 연결이 되는데 hs에서는 안 될 경우 환경변수를 확인해보거나 unixODBC와 freetds를 소스로 설치해서 해보길 바란다.