oracle通過透明網(wǎng)關(guān)(Oracle Transparent Geteways),,訪問ms sql server和其他數(shù)據(jù)庫
環(huán)境: 1、在安裝有oracle服務(wù)器端,,ms sql server的客戶端,,通過oracle的透明網(wǎng)關(guān)訪問ms sql server數(shù)據(jù)庫 2、在ms sql server服務(wù)器上創(chuàng)建用戶conn_ora,并且要能訪問ms sql server數(shù)據(jù)庫msdb 安裝Oracle Transparent Geteways: 1,、'開始'菜單的'Oracle Installation Products'下的'Universal Installer' \\192.168.0.8\e$\數(shù)據(jù)工具\oracle9.2\ORANT920\ORA92_1\NT\I386\stage\products.jar 下一步- 2,、選擇安裝類型: 自定義,下一步 3,、選擇可用產(chǎn)品組件: 將 'Oracle Transparent Geteways 9.2.0.1.0'下的'Oracle Transparent Geteways for Microsoft SQL Server 9.2.0.1.0'選中,; 將 'Oracle Transparent Geteways 9.2.0.1.0'下的'Oracle Transparent Geteways for Sybase 9.2.0.1.0'選中; 下一步,; 4,、設(shè)置Sybase路徑 選擇你的'SYBASE的完整安裝路徑'; 下一步 5,、設(shè)置數(shù)據(jù)庫服務(wù)器名 和數(shù)據(jù)庫名稱?,?,? Microsoft SQL Server:192.168.0.111 Microsoft SQL 數(shù)據(jù)庫:msdb 服務(wù)器名稱或者ip地址,數(shù)據(jù)庫名字 6,、繼續(xù)安裝: \\192.168.0.8\e$\數(shù)據(jù)工具\oracle9.2\ORANT920\ORA92_2\NT\I386\stage \\192.168.0.8\e$\數(shù)據(jù)工具\oracle9.2\ORANT920\ORA92_3\NT\I386\stage 7,、安裝完成: 此時,oracle安裝主目錄下有了'tg4msql'目錄 C:\oracle\ora92\tg4msql 設(shè)置環(huán)境參數(shù),,創(chuàng)建dblink: 1,、C:\oracle\ora92\tg4msql\admin下的inittg4msql.ora文件 文件內(nèi)容: # This is a sample agent init file that contains the HS parameters that are # needed for the Transparent Gateway for SQL Server # # HS init parameters # HS_FDS_CONNECT_INFO="SERVER=ZZL;DATABASE=MSDB" HS_FDS_TRACE_LEVEL=OFF HS_FDS_RECOVERY_ACCOUNT=RECOVER HS_FDS_RECOVERY_PWD=RECOVER 說明: HS_FDS_CONNECT_INFO=ZZL.MSDB和 HS_FDS_CONNECT_INFO="SERVER=ZZL;DATABASE=MSDB"和 HS_FDS_CONNECT_INFO="SERVER=192.168.0.111;DATABASE=MSDB" 都可以,兩種寫法,,其中‘SERVER’是服務(wù)器名稱或者ip,,DATABASE是數(shù)據(jù)庫名稱, 當然,,如果在192.168.0.111這臺服務(wù)器上,,有兩個sql server實例,則使用‘服務(wù)器名\實例名’的方式設(shè)置上面的SERVER值,, 如:HS_FDS_CONNECT_INFO="SERVER=ZZL\MSSQLSERVER;DATABASE=MSDB" 2,、設(shè)置listener.ora文件 位置:C:\oracle\ora92\network\admin 文件內(nèi)容: SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = C:\oracle\ora92) (PROGRAM = extproc) ) (SID_DESC = (GLOBAL_DBNAME = orademo) (PROGRAM = orademo) (ORACLE_HOME = C:\oracle\ora92) (SID_NAME = orademo) ) (SID_DESC = (PROGRAM = tg4msql) (ORACLE_HOME = C:\oracle\ora92) (SID_NAME = tg4msql) ) ) 其中新增: (SID_DESC = (PROGRAM = tg4msql) (ORACLE_HOME = C:\oracle\ora92) #oracle的主目錄 (SID_NAME = tg4msql) ) 3、配置tnsnames.ora文件 位置:C:\oracle\ora92\network\admin 文件內(nèi)容: # TNSNAMES.ORA Network Configuration File: C:\oracle\ora92\network\admin\tnsnames.ora # Generated by Oracle configuration tools. SDLGDB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.8)(PORT = 1521)) ) (CONNECT_DATA = (SID = SSTORA) (SERVER = DEDICATED) ) ) ORADEMO = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = zzl)(PORT = 1521)) ) (CONNECT_DATA = (SID = orademo) (SERVER = DEDICATED) ) ) zzl_sql200 = #數(shù)據(jù)庫連接名稱,,任意命名 (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.111)(PORT = 1521)) #'192.168.0.111'為 oracle服務(wù)器的機器名 ) (CONNECT_DATA = (SID = tg4msql) ) (HS=OK) #Oracle Server要調(diào)用異構(gòu)服務(wù)來處理 ) 其中新增: zzl_sql200 = #數(shù)據(jù)庫連接名稱,,任意命名 (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.111)(PORT = 1521)) #'192.168.0.111'為 oracle服務(wù)器的機器名 ) (CONNECT_DATA = (SID = tg4msql) ) (HS=OK) #Oracle Server要調(diào)用異構(gòu)服務(wù)來處理 ) 4、配置init.ora.1115200612231 位置:C:\oracle\admin\orademo\pfile 將global_names設(shè)置為真值,,及global_names=true 5,、重新啟動服務(wù): 在window的開始的運行中執(zhí)行: net stop OracleOraHome92TNSListener net stop OracleServiceORADEMO net start OracleOraHome92TNSListener net start OracleServiceORADEMO 說明:OracleOraHome92TNSListener 是監(jiān)聽服務(wù),,OracleServiceORADEMO是實例服務(wù) 6,、創(chuàng)建dblink: 以普通用戶登錄oracle:如cs/cs@orademo --drop DATABASE LINK link_zhaozhenlong; CREATE DATABASE LINK link_zhaozhenlong CONNECT TO "sa" IDENTIFIED BY "xxb" USING 'zzl_sql200'; 說明:ms sql server的用戶名和密碼必須小寫,而且要加雙引號,, 否則會報如下錯誤: 錯誤信息: ORA-28500: connection from ORACLE to a non-Oracle system returned this messsage: [Transparent gateway from MSSQL][Microsoft][ODBC SQL Server Driver][SQL Server]?? 'sa'????? (SQL State:28000; SQL Code: 18456) ORA-02063: preceding 2 lines from LINK_ZZL 錯誤原因: 在CREATE DATABASE LINK LINK_ZZL的連接字符串中,,ms sql server的用戶名和密碼必須小寫,而且要加雙引號 7,、在pl/sql中執(zhí)行: select * from sysobjects@link_zhaozhenlong where rownum <=5; 結(jié)果如下: 1 sysrowsetcolumns 4 S 4 0 0 0 0 0 2005-10-14 1:36:15 2 sysrowsets 5 S 4 0 0 0 0 0 2005-10-14 1:36:15 3 sysallocunits 7 S 4 0 0 0 0 0 2005-10-14 1:36:15 4 sysfiles1 8 S 4 0 0 0 0 0 2003-4-8 9:13:38 5 syshobtcolumns 13 S 4 0 0 0 0 0 2005-10-14 1:36:15 訪問dblink時說明: 這是基于網(wǎng)關(guān)的方式,,因此不能在斷開網(wǎng)絡(luò)的情況下本地的oracle連接本地的ms sql server 否則會報如下錯誤: ORA-28545: error diagnosed by Net8 when connecting to an agent NCRO: Failed to make RSLV connection ORA-02063: preceding 2 lines from LINK_ZZL |
|