| 名称 | 值 |
|---|---|
| cpu | Intel® Core™ i5-1035G1 CPU @ 1.00GHz |
| 操作系统 | CentOS Linux release 7.9.2009 (Core) |
| 内存 | 4G |
| 逻辑核数 | 3 |
| Gbase-8a节点1-IP | 192.168.142.10 |
| Gbase-8a节点2-IP | 192.168.142.11 |
| Oracle节点1-IP | 192.168.142.11 |
| Gbase-8a数据库版本 | 8.6.2.43-R33.132743 |
| Oracle数据库版本 | Release 11.2.0.1.0 Production |
| unixODBC版本 | 2.3.4 |
默认安装的。
[root@xdw1 ~]# su - oracle
上一次登录:二 8月 16 09:14:39 CST 2022pts/3 上
[oracle@xdw1 ~]$ dg4odbc
Oracle Corporation --- TUESDAY AUG 16 2022 09:31:12.030
Heterogeneous Agent Release 11.2.0.1.0 - 64bit Production Built with
Oracle Database Gateway for ODBC
相关安装包下载可以参考之前写的一篇文章Postgresql学习02-配置ODBC数据源
[root@xdw1 pkg]# tar -xvf unixODBC-2.3.4.tar.gz
[root@xdw1 unixODBC-2.3.4]# ./configure --prefix=/usr/local/unixODBC-2.3.4 --includedir=/usr/include --libdir=/usr/lib -bindir=/usr/bin --sysconfdir=/etc
[root@xdw1 unixODBC-2.3.4]# make -j 3
[root@xdw1 unixODBC-2.3.4]# make install
[root@xdw1 unixODBC-2.3.4]# odbcinst -j
unixODBC 2.3.4
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
/etc/profile文件末尾添加如下两行。
export ODBCSYSINI=/etc
export ODBCINI=/etc/odbc.ini
添加完source一下这个文件,让环境变量在当前会话生效。
[root@xdw1 unixODBC-2.3.4]# source /etc/profile
我的libgsodbc8.so动态库放在/opt/pkg下,需要和官网申请。
[root@xdw1 unixODBC-2.3.4]# cat /etc/odbcinst.ini
[GBaseODBCDriver]
Driver=/opt/pkg/libgsodbc8.so
UsageCount=1
DontDLClose=1
Threading=0
[root@xdw1 unixODBC-2.3.4]# cat /etc/odbc.ini
[gbase8a]
Description=ODBC
Driver=GBaseODBCDriver
Server=192.168.142.10
Port=5258
UID=czg
Password=qwer1234
Database=czg
[root@xdw1 unixODBC-2.3.4]# su - oracle
上一次登录:二 8月 16 09:31:10 CST 2022pts/3 上
[oracle@xdw1 ~]$ isql gbase8a -v
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select version();
+--------------------+
| version() |
+--------------------+
| 8.6.2.43-R33.132743|
+--------------------+
SQLRowCount returns 1
1 rows fetched
tnsnames.ora添加如下内容:
gbase8a =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.142.11)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = gbase8a)
)
(HS = OK)
)
完整内容如下:
[oracle@xdw1 admin]$ pwd
/u01/app/oracle/product/11.2.0/network/admin
[oracle@xdw1 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.142.11)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
gbase8a =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.142.11)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = gbase8a)
)
(HS = OK)
)
listener.ora添加如下内容:
(SID_DESC =
(SID_NAME = gbase8a)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0)
(PROGRAM = dg4odbc)
完整内容如下:
[oracle@xdw1 admin]$ pwd
/u01/app/oracle/product/11.2.0/network/admin
[oracle@xdw1 admin]$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0
[oracle@xdw1 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.142.11)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(SID_NAME = orcl)
)
(SID_DESC =
(SID_NAME = gbase8a)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0)
(PROGRAM = dg4odbc)
)
)
[oracle@xdw1 admin]$ pwd
/u01/app/oracle/product/11.2.0/hs/admin
[oracle@xdw1 admin]$ cat initgbase8a.ora
HS_FDS_CONNECT_INFO = gbase8a
HS_FDS_TRACE_LEVEL = 0
HS_FDS_SHAREABLE_NAME=/usr/lib64/libodbc.so
HS_FDS_SUPPORT_STATISTICS=FALSE
HS_LANGUAGE=AMERICAN_AMERICA.WE8ISO8859P15
set ODBCINI=/etc/odbc.ini
[oracle@xdw1 admin]$ lsnrctl reload
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 16-AUG-2022 14:48:41
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
[oracle@xdw1 admin]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 16-AUG-2022 14:48:47
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 15-AUG-2022 14:42:47
Uptime 1 days 0 hr. 5 min. 59 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/xdw1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.142.11)(PORT=1521)))
Services Summary...
Service "gbase8a" has 1 instance(s).
Instance "gbase8a", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@xdw1 admin]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Tue Aug 16 14:11:27 2022
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> conn czg/qwer1234
Connected.
SQL> create public database link gbase8a connect to "czg" identified by "qwer1234" using 'gbase8a';
Database link created.
SQL> select * from czg@gbase8a;
a b
---------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2 zxj
1 czg
SQL>
gbase> select * from czg.czg;
+------+------+
| a | b |
+------+------+
| 2 | zxj |
| 1 | czg |
+------+------+
2 rows in set (Elapsed: 00:00:00.17)