我已经创建了一个DB链接到Oracle数据库,指向SQL Server数据库。 如果为此SQL Server数据库正确配置了ODBC。 我还在Oracle数据库服务器上安装了适用于SQL Server的Oracle网关。
当我尝试在我的Oracle数据库上执行此SQL请求时:
SELECT * FROM obbud@qualiactst
(qualiactst is my DBLink :
-- PROMPT CREATE DATABASE LINK qualiactst
CREATE DATABASE LINK qualiactst
CONNECT TO iac IDENTIFIED BY ***** USING 'RIATST';
)
错误信息显示如下:
ORA-12154: TNS : could not resolve the connect identifier specified
我已经使用以下命令配置了Oracle数据库服务器的tnsname.ora文件:
RIATST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = grensql2k12R2-1)(PORT = 14539))
)
(CONNECT_DATA = (SID = RIATST))
(HS=OK)
)
(但我真的不知道是否必须将非oracle数据库添加到tnsname.ora中)
我不明白我做错了什么,如果有些事情遗失了。
你能帮帮我吗? 非常感谢你珍
答案 0 :(得分:0)
看起来您没有将侦听器设置到目标主机(grensql2k12R2-1)或不配置HS初始化文件。
通常,请尝试关注this guide。有太多细节可以在一个答案中检查每一个。
答案 1 :(得分:0)
用于与异构MSSQL数据库进行通信。有两种选择。
1)使用专用的Oracle Database Gateway for SQL Server。 Configuring Oracle Database Gateway for SQL Server 2)用于ODBC的Oracle数据库网关。 Configuring Oracle Database Gateway for ODBC
简单示例为SQL Server配置Oracle数据库网关
ORACLE_HOME \ dg4msql \管理员\ initdg4msql.ora
HS_FDS_CONNECT_INFO=host_name:port_name//database_name
ORACLE_HOME \网络\管理员\的listener.ora
SID_LIST_LISTENER=
############# MS SQL ####################
(SID_LIST=
(SID_DESC=
(SID_NAME=dg4msql)
(ORACLE_HOME=oracle_home_directory)
(PROGRAM=dg4msql)
)
)
##########################################
重启侦听器
lsnrctl stop
lsnrctl start
ORACLE_HOME \网络\管理员\的tnsnames.ora
connect_descriptor_mssql=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=host_name_oracle_gateway_host)
(PORT=port_number_listener_1521)
)
(CONNECT_DATA=
(SID=dg4msql))
(HS=OK))
SQL> CREATE PUBLIC DATABASE LINK name_dblink CONNECT TO "user" IDENTIFIED BY "password" USING 'connect_descriptor_mssql';
SQL> SELECT * FROM DUAL@dblink;
生产服务器Oracle 11.2.0.4的示例
/home/oracle/app/oracle/product/11.2.0/dbhome_1/dg4msql/admin/inittch7.ora
HS_FDS_CONNECT_INFO=[10.89.250.87]:1433/
/home/oracle/app/oracle/product/11.2.0/dbhome_1/dg4msql/admin/inittch7.ora
HS_FDS_CONNECT_INFO=[10.89.250.88]:1433/
/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1525))
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.89.251.242)(PORT = 1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ssps)
(ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = ssps)
)
(SID_DESC=
(SID_NAME=tch8)
(ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1)
(PROGRAM=dg4msql)
)
(SID_DESC=
(SID_NAME=tch7)
(ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1)
(PROGRAM=dg4msql)
)
)
ADR_BASE_LISTENER = /home/oracle/database
/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
SSPS_1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.89.251.242)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ssps)
)
)
atch7 =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST= 10.89.251.242)(PORT=1521))
(CONNECT_DATA=(SID=tch7))
(HS=OK)
)
atch8 =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=10.89.251.242)(PORT=1521))
(CONNECT_DATA=(SID=tch8))
(HS=OK)
)
CREATE DATABASE LINK ATCH7.GIFT.KRSK.MPS
CONNECT TO "asuzm_link" IDENTIFIED BY <ENTER USER PASSWORD HERE>
USING 'atch7'
/
CREATE DATABASE LINK ATCH8.GIFT.KRSK.MPS
CONNECT TO "asuzm_link" IDENTIFIED BY <ENTER USER PASSWORD HERE>
USING 'atch8'
/