无法在 Linux 上通过 JDBC 将 Sqoop 连接到 Oracle TimesTen
Posted
技术标签:
【中文标题】无法在 Linux 上通过 JDBC 将 Sqoop 连接到 Oracle TimesTen【英文标题】:Unable to Connect Sqoop to Oracle TimesTen through JDBC on Linux 【发布时间】:2018-02-19 03:43:32 【问题描述】:我已经在 linux 上安装了 Timesten 数据库(完整版)(Linux 是通过 Oracle 虚拟机和 cloudera VM 安装的客户操作系统)
我正在尝试在 linux 上运行以下 sqoop 命令并出现以下错误
命令
sqoop list-tables --connect jdbc:timesten:direct:dsn=sampledb_1122 --driver com.timesten.jdbc.TimesTenDriver
**error**
ERROR manager.SqlManager: Error reading database metadata: java.sql.SQLException: Problems with loading native library/missing methods: no ttJdbc in java.library.path
java.sql.SQLException: Problems with loading native library/missing methods: no ttJdbc in java.library.path
at com.timesten.jdbc.JdbcOdbcConnection.connect(JdbcOdbcConnection.java:1809)
at com.timesten.jdbc.TimesTenDriver.connect(TimesTenDriver.java:305)
at com.timesten.jdbc.TimesTenDriver.connect(TimesTenDriver.java:161)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:233)
at org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:878)
at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:52)
at org.apache.sqoop.manager.SqlManager.listTables(SqlManager.java:520)
at org.apache.sqoop.tool.ListTablesTool.run(ListTablesTool.java:49)
at org.apache.sqoop.Sqoop.run(Sqoop.java:143)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:179)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:218)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:227)
at org.apache.sqoop.Sqoop.main(Sqoop.java:236)
Could not retrieve tables list from server
18/02/18 18:56:04 ERROR tool.ListTablesTool: manager.listTables() returned null
TimesTen bin 和 lib 文件夹位置
/home/cloudra/timesten/TimesTen/tt1122_64/bin /home/cloudera/timesten/TimesTen/tt1122_64/lib
在我的环境和其他参数中设置了以下值
USERNAME=cloudera
DESKTOP_SESSION=gnome
MAIL=/var/spool/mail/cloudera
PATH=/var/lib/sqoop:/home/cloudera/timesten/TimesTen/tt1122_64/bin:/home/cloudera/timesten/TimesTen/tt1122_64/lib:/home/cloudera/anaconda3/bin:/var/lib/sqoop:/home/cloudra/timesten/TimesTen/tt1122_64/bin:/home/cloudera/timesten/TimesTen/tt1122_64/lib:/home/cloudera/anaconda3/bin:/home/cloudera/anaconda3/bin:/usr/local/firefox:/sbin:/usr/java/jdk1.7.0_67-cloudera/bin:/usr/local/apache-ant/apache-ant-1.9.2/bin:/usr/local/apache-maven/apache-maven-3.0.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/cloudera/bin
PWD=/home/cloudera
THREAD_FLAGS=native
HOME=/home/cloudera
SHLVL=2
M2_HOME=/usr/local/apache-maven/apache-maven-3.0.4
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
LOGNAME=cloudera
CVS_RSH=ssh
CLASSPATH=/home/cloudera/timesten/TimesTen/tt1122_64/lib/ttjdbc6.jar
[cloudera@quickstart ~]$ echo $LD_LIBRARY_PATH
/home/cloudera/timesten/TimesTen/tt1122_64/lib:/home/cloudera/timesten/TimesTen/tt1122_64/lib:
[cloudera@quickstart ~]$ java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
[cloudera@quickstart ~]$
cloudera@quickstart bin]$ ./ttversion
TimesTen Release 11.2.2.8.0 (64 bit Linux/x86_64) (tt1122_64:53396) 2015-01-20T08:36:31Z
Instance admin: cloudera
Instance home directory: /home/cloudera/timesten/TimesTen/tt1122_64
World accessible
Daemon home directory: /home/cloudera/timesten/TimesTen/tt1122_64/info
PL/SQL enabled.
除上述之外.. ttjdbc6.jar 文件位于以下位置
[cloudera@quickstart sqoop]$ pwd
/var/lib/sqoop
[cloudera@quickstart sqoop]$ ls -ltr
total 0
lrwxrwxrwx 1 root root 40 Jun 9 2015 mysql-connector-java.jar -> /usr/share/java/mysql-connector-java.jar
lrwxrwxrwx 1 root root 58 Feb 16 21:37 ttjdbc6.jar -> /home/cloudera/timesten/TimesTen/tt1122_64/lib/ttjdbc6.jar
[cloudera@quickstart timesten]$ pwd
/usr/lib/timesten
[cloudera@quickstart timesten]$ ls -ltr
total 276
-rwxrwxrwx 1 root root 279580 Feb 18 11:33 ttjdbc6.jar
Java_library_path 输出
[cloudera@quickstart timesten]$ java -XshowSettings:properties
Property settings:
awt.toolkit = sun.awt.X11.XToolkit
file.encoding = UTF-8
file.encoding.pkg = sun.io
file.separator = /
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
java.awt.printerjob = sun.print.PSPrinterJob
java.class.path = /home/cloudera/timesten/TimesTen/tt1122_64/lib/ttjdbc6.jar
java.class.version = 51.0
java.endorsed.dirs = /usr/java/jdk1.7.0_67-cloudera/jre/lib/endorsed
java.ext.dirs = /usr/java/jdk1.7.0_67-cloudera/jre/lib/ext
/usr/java/packages/lib/ext
java.home = /usr/java/jdk1.7.0_67-cloudera/jre
java.io.tmpdir = /tmp
java.library.path = /home/cloudera/timesten/TimesTen/tt1122_64/lib
/home/cloudera/timesten/TimesTen/tt1122_64/lib
/usr/java/packages/lib/amd64
/usr/lib64
/lib64
/lib
/usr/lib
java.runtime.name = Java(TM) SE Runtime Environment
java.runtime.version = 1.7.0_67-b01
我执行了 ttenv.sh 脚本,但是当我检查 env 参数时它没有设置任何参数,所以我必须手动进行。
大师和专家.. 请在这里帮助我.. 不知道是什么问题以及为什么我收到上述错误。
感谢您的帮助..
【问题讨论】:
【参考方案1】:这里的关键是:
java.sql.SQLException: Problems with loading native library/missing methods:
no ttJdbc in java.library.path
TimesTen JDBC 驱动程序是类型 1 / 2 驱动程序,它依赖于底层的 TimesTen 本机库。具体来说,它需要位于<TimesTen_install_dir>/lib
中的几个共享库,例如libttJdbc.so
(错误所抱怨的那个)、libtten.so
等。通常您需要确保java.library.path
包含此目录(它出现是这种情况)并且CLASSPATH
在该目录中包含ttjdbc7.jar
文件。另一种可能性是您的 TimesTen 安装是“仅限客户端”安装,在这种情况下,您不能使用“直接”驱动程序,如果您尝试这样做,您会得到这个确切的错误。我建议检查一下你是否真的在<TimesTen_install_dir>/lib
中有文件libttJdbc.so
和libtten.so
,如果没有,那么这意味着你只安装了一个客户端并且需要配置/使用客户端/服务器连接。
【讨论】:
以上是关于无法在 Linux 上通过 JDBC 将 Sqoop 连接到 Oracle TimesTen的主要内容,如果未能解决你的问题,请参考以下文章
在 Linux 命令行上检查 postgresql jdbc 驱动程序版本的命令是啥?
将windows上面的项目拷贝到Linux环境下报错不能够找到对应的表com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table