我想从运行 Oracle 自定义 Linux 风格的服务器上的 Oracle 实例中选择运行 openSUSE 的服务器上的 PostgreSQL 实例。我想使用 Oracle ODBC 网关来执行此操作。我过去成功地做到了这一点,并继续使用相同的 Oracle 机器和其他 SUSE/Postgres 机器来做到这一点。
我在 SUSE(Postgres)端的 ODBC 管理器是:unixODBC
我的 odbc.ini 是:
[postgresql]
Description = Test to Postgres
Driver = /usr/lib64/psqlodbcw.so
Trace = Yes
TraceFile = sql.log
Database = host
Servername = localhost
UserName = *****
Password = *****
Port = 5432
Protocol =
ReadOnly = Yes
RowVersioning = No
ShowSystemTables = No
ShowOidColumn = No
FakeOidIndex = No
ConnSettings =
我的 odbcinst.ini 是
[postgresql]
Description = Postgresql driver for Linux
Driver = /usr/lib64/psqlodbcw.so
UsageCount = 1
我的 tnsnames.ora(省略了其他 ODBC 条目)是:
# tnsnames.ora Network Configuration File: /opt/oracle/product/11gR1/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = dbs1)(PORT = 1522))
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dbs1)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
ODBC_SERVER123=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=dbs1)
(PORT=1522)
)
(CONNECT_DATA=
(SID=server123)
)
(HS=OK)
)
我的 listener.ora(省略了其他 SID_DESC 条目)是:
# listener.ora Network Configuration File: /opt/oracle/product/11gR1/db/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST=
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
(ADDRESS = (PROTOCOL = TCP)(HOST = dbs1)(PORT = 1522))
)
)
)
ADR_BASE_LISTENER = /opt/oracle
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(SID_NAME=server123)
(ORACLE_HOME=/opt/oracle/product/11gR1/db)
(PROGRAM=dg4odbc)
(ENVS=LD_LIBRARY_PATH=/usr/lib64:/opt/oracle/product/11gR1/db/lib)
)
)
TRACE_LEVEL_LISTENER = 0
LOGGING_LISTENER = off
此外,这里是位于 $ORACLE_HOME/hs/admin 中的 inithost123.ora 文件:
#
# HS init parameters
#
HS_FDS_CONNECT_INFO = server123
HS_FDS_TRACE_LEVEL = 0
#HS_FDS_TRACE_LEVEL=DEBUG
HS_FDS_SHAREABLE_NAME = /usr/lib64/libodbc.so
HS_FDS_SUPPORT_STATISTICS = FALSE
HS_LANGUAGE=AMERICAN_AMERICA.WE8ISO8859P1
#HS_LANGUAGE=AMERICAN_AMERICA.US7ASCII
HS_FDS_TIMESTAMP_MAPPING = "TIMESTAMP(6)"
HS_FDS_FETCH_ROWS=1
HS_FDS_SQLLEN_INTERPRETATION=32
#
# ODBC specific environment variables
#
set ODBCINI=/etc/unixODBC/odbc.ini
#
# Environment variables required for the non-Oracle system
#
#set <envvar>=<value>
为了更好的衡量,我的 sqlnet.ora 是:
# sqlnet.ora Network Configuration File: /opt/oracle/product/11gR1/db/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
ADR_BASE = /opt/oracle
我使用以下命令添加了网关链接 oracle 端:
CREATE DATABASE LINK ODBC_SERVER123 CONNECT TO "*****" IDENTIFIED BY "*****" USING 'ODBC_SERVER123';
当我尝试执行我的选择时,我收到以下错误:
[SQL] select * from "legit_view"@ODBC_SERVER123
[Err] ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
[unixODBC][Driver Manager]Data source name not found, and no default driver specified {IM002}
ORA-02063: preceding 2 lines from ODBC_SERVER123
我可以使用 isql 在 SUSE/Postgres 机器上本地成功测试 ODBC:
>isql -v postgresql ***** *****
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>
我忘记了哪一步?