【发布时间】:2020-01-24 17:30:35
【问题描述】:
我无法创建从 Oracle XE 18c 到 SQL Server 2017 Express 的 DBLink!
我的服务器 centos 7.6 上有一个 Oracle XE 18c 实例和一个 SQL Server 2017 Express 实例,两者都正常工作。
我想为 SQL Server 创建一个 Oracle dblink。
感谢这条防火墙规则,我可以远程连接到 SQL Server
firewall-cmd --zone=public --add-port=1433/tcp --permanent
firewall-cmd --reload
我已经安装了 Microsoft odbc 工具
curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
yum remove unixODBC-utf16 unixODBC-utf16-devel
yum install -y mssql-tools unixODBC-devel
ACCEPT_EULA=Y yum install msodbcsql
cd /usr/lib64
sudo ln -s libodbccr.so.2.0.0 libodbccr.so.1
sudo ln -s libodbcinst.so.2.0.0 libodbcinst.so.1
sudo ln -s libodbc.so.2.0.0 libodbc.so.1
创建了一个 DB、一个 ODBC DSN 并验证一切正常
sqlcmd -D -S roberto_dsn -U sa -P password -d robertodb -Q "select * FROM dbo.Person"
我已经使用以下代码配置了 Oracle 实例:
nano /opt/oracle/product/18c/dbhomeXE/hs/admin/initroberto.ora
HS_FDS_CONNECT_INFO = roberto_dsn
HS_FDS_TRACE_LEVEL = 0
HS_FDS_SHAREABLE_NAME = /usr/lib64/libodbc.so
set ODBCINI=/etc/odbc.ini
nano /opt/oracle/product/18c/dbhomeXE/network/admin/listener.ora
aggiungere
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC=
(SID_NAME=roberto)
(ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE)
(PROGRAM=dg4odbc)
(envs="LD_LIBRARY_PATH=/usr/lib64:/opt/oracle/product/18c/dbhomeXE/lib")
)
)
nano /opt/oracle/product/18c/dbhomeXE/network/admin/tnsnames.ora
#added
ROBERTO =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.164)(PORT = 1521))
(CONNECT_DATA =
(SID_NAME = roberto)
)
(HS=OK)
)
我正确重启了监听器
lsnrctl stop
lsnrctl start
tnsping roberto
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.164)(PORT = 1521)) (CONNECT_DATA = (SID_NAME = roberto)) (HS=OK))
OK (0 msec)
最后我创建了 DBLink
sqlplus / as sysdba
alter session set container = xepdb1;
CREATE PUBLIC DATABASE LINK ROBERTO CONNECT TO
"sa" IDENTIFIED BY "password" using 'roberto';
我收到的第一个错误如下:
sqlplus sa/password@roberto
ERROR:
ORA-01017: Invalid Username/Password; Logon Denied
还可以使用 DBLink:
select * from dual@roberto;
ORA-28546: Connection initialization failed, probable Net8 admin error
ORA-28511: lost RPC connection to heterogeneous remote agent using SID=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.164)(PORT=1521)))(CONNECT_DATA=(SID_NAME=roberto)))
ORA-02063: preceding 2 lines from roberto
28546. 0000 - "connection initialization failed, probable Net8 admin error"
*Cause: A failure occurred during initialization of a network connection
from the Oracle server to a second process: The connection
was completed but a disconnect occurred while trying to
perform protocol-specific initialization, usually due to
use of different network protocols by opposite sides
of the connection. This usually is caused by incorrect
Net8 administrative setup for database links or external
procedure calls. The most frequent specific causes are:
-- Database link setup for an Oracle-to-Oracle connection
instead connects to a Heterogeneous Services agent
or an external procedure agent.
-- Database link setup for a Heterogeneous Services connection
instead connects directly to an Oracle server.
-- The extproc_connection_data definition in tnsnames.ora
connects to an Oracle instance instead of an external
procedure agent.
-- Connect data for a Heterogeneous Services database link,
usually defined in tnsnames.ora, does not specify (HS=).
-- Connect data for an Oracle-to-Oracle database link,
usually defined in tnsnames.ora, specifies (HS=).
*Action: Check Net8 administration in the following ways
-- When using TNSNAMES.ORA or an Oracle Names server, make sure
that the connection from the ORACLE server uses the correct
service name or SID.
-- Check LISTENER.ORA on the connection end point's host machine
to assure that this service name or SID connects to the
correct program.
-- Confirm in TNSNAMES.ORA or the equivalent service definition
that service 'extproc_connection_data' does NOT contain
(HS=), or that the service definition used by a
Heterogeneous Services database link DOES contain (HS=).
有什么建议吗?
【问题讨论】:
-
你看过sql-server日志,windows主机运行sql-server的日志吗?有什么有趣的吗?
-
SQL Server 2017 Express 在同一台服务器上运行。没有日志。我认为连接在到达 SQL Server 之前就丢失了。我也认为我可能使用了错误的库,但我找不到正确的库。
-
发布了一个可能的答案,但这是我最后的想法/美分。问候
标签: sql-server oracle odbc dblink