我在解决一个问题时遇到了麻烦。
操作系统是CentOS,MariaDB的版本是10.4。
UnixODBC已安装并使用odbc.ini和odbcinit.ini正确配置。
当我尝试使用“isql -v orcl scott tiger”连接时,它成功连接。
然而,当我在MariaDB中尝试相同的操作时,我遇到了以下错误:Maria02 [test]> CREATE TABLE ora_emp -> ENGINE=CONNECT -> TABLE_TYPE=ODBC TABNAME='EMP' CONNECTION='DSN=orcl;UID=scott;PWD=tiger'; ERROR 1105 (HY000): SQLDriverConnect: [unixODBC][Driver Manager]Can't open lib '/home/oracle/instantclient_11_2/libsqora.so.11.1': file not found
LD_LIBRARY_PATH环境变量设置为/home/oracle/instantclient_11_2。
[root@localhost instantclient_11_2]# ldd libsqora.so.11.1
linux-vdso.so.1 => (0x00007fff0d2b5000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fb5a7c54000)
libm.so.6 => /lib64/libm.so.6 (0x00007fb5a7952000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fb5a7736000)
libnsl.so.1 => /lib64/libnsl.so.1 (0x00007fb5a751c000)
libclntsh.so.11.1 => /home/oracle/instantclient_11_2/libclntsh.so.11.1 (0x00007fb5a4bad000)
libodbcinst.so.1 => /lib64/libodbcinst.so.1 (0x00007fb5a499b000)
libc.so.6 => /lib64/libc.so.6 (0x00007fb5a45cd000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb5a7e58000)
libnnz11.so => /home/oracle/instantclient_11_2/libnnz11.so (0x00007fb5a4200000)
libaio.so.1 => /lib64/libaio.so.1 (0x00007fb5a3ffe000)
libltdl.so.7 => /lib64/libltdl.so.7 (0x00007fb5a3df4000)
字符串
上面是'ldd'命令的结果,似乎没有问题。
文件“/home/oracle/instantclient_11_2/libsqora.so.11.1”肯定存在。
我将非常感谢任何帮助解决这个问题。
- 谢谢-谢谢
$ rpm -qa unixODBC*
unixODBC-2.3.1-14.el7.x86_64
unixODBC-devel-2.3.1-14.el7.x86_64
$ export ORACLE_HOME=/home/oracle/instantclient_11_2
$ export LD_LIBRARY_PATH=$ORACLE_HOME
$ vi /etc/odbcinst.ini
[Oracle 11g ODBC driver]
Description = Oracle ODBC driver for Oracle 11g
Driver = /home/oracle/instantclient_11_2/libsqora.so.11.1
$ vi /etc/odbc.ini
[orcl]
Driver = Oracle 11g ODBC driver
ServerName = //192.168.80.1:1521/oracle
DSN = orcl
UserName = scott
Password = tiger
$ isql -v orcl scott tiger
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
$ mysql -uroot
MariaDB [(none)]> install plugin connect soname 'ha_connect.so';
MariaDB [(none)]> use test;
MariaDB [test]> CREATE TABLE ora_emp ENGINE=CONNECT TABLE_TYPE=ODBC TABNAME='EMP' CONNECTION='DSN=orcl;UID=scott;PWD=tiger';
ERROR 1105 (HY000): SQLDriverConnect: [unixODBC][Driver Manager]Can't open lib '/home/oracle/instantclient_11_2/libsqora.so.11.1' : file not found
型
1条答案
按热度按时间dluptydi1#
由于MariaDB通常由CentOS(和其他)上的systemd启动,并且默认systemd服务具有ProtectHome=yes,导致该服务无法访问/home文件。
推荐:
字符串
并将路径更改为
/usr/local/oracle/instantclient_11_2
对于systemd服务,
LD_LIBRARY_PATH
也需要存在。systemctl edit mariadb.service
并附加到此文件:型