达梦配置ODBC连接
基础环境
操作系统:Red Hat Enterprise Linux Server release 7.9 (Maipo)
数据库版本:DM Database Server 64 V8
架构:单实例
1 下载ODBC包
下载网址:https://www.unixodbc.org/
unixODBC-2.3.0.tar.gz
2 编译并安装ODBC
--解压
tar -zxvf unixODBC-2.3.0.tar.gz
--设置
[root@test2 opt]# cd unixODBC-2.3.0/
[root@test2 unixODBC-2.3.0]# ./configure --enable-gui=no
--编译、安装
[root@test2 unixODBC-2.3.0]# make && make install
--确认
[root@test2 unixODBC-2.3.0]# odbc_config --version
2.3.0
[root@test2 unixODBC-2.3.0]# odbcinst -j
unixODBC 2.3.0
DRIVERS............: /usr/local/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
3 配置/usr/local/etc/odbc.ini
vi /usr/local/etc/odbc.ini
[TEST]
description=ODBC DM8 DSND
driver=ODBC DM8 DRIVER
server=192.168.10.231
uid=sysdba
pwd=Dameng123
tcp_port=5237
[PROD]
description=ODBC DM8 DSND
driver=ODBC DM8 DRIVER
server=192.168.10.232
uid=sysdba
pwd=Dameng123
tcp_port=5238
4 配置/usr/local/etc/odbcinst.ini
vi /usr/local/etc/odbcinst.ini
[ODBC DM8 DRIVER]
description=driver for dm8
driver=/dm8/bin/libdodbc.so
5 连接测试
[dmdba@test1 ~]$ isql TEST
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select instance_name from v$instance;
+---------------------------------------------------------------------------------------------------------------------------------+
| INSTANCE_NAME |
+---------------------------------------------------------------------------------------------------------------------------------+
| TEST |
+---------------------------------------------------------------------------------------------------------------------------------+
SQLRowCount returns 1
1 rows fetched
SQL>
[dmdba@test1 ~]$ isql PROD
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select instance_name from v$instance;
+---------------------------------------------------------------------------------------------------------------------------------+
| INSTANCE_NAME |
+---------------------------------------------------------------------------------------------------------------------------------+
| PROD |
+---------------------------------------------------------------------------------------------------------------------------------+
SQLRowCount returns 1
1 rows fetched
SQL>
谨记:心存敬畏,行有所止。