sqoop从db2特定架构导入所有hive

时间:2017-05-02 09:26:01

标签: database hadoop jdbc db2 sqoop

我试图使用下面的命令行从DB2中的特定模式导入所有表。

sqoop import-all-tables  --username user --password pass \
--connect jdbc:db2://myip:50000/databs:CurrentSchema=testdb \
--driver com.ibm.db2.jcc.DB2Driver  --fields-terminated-by ',' \
--lines-terminated-by '\n' --hive-database default --hive-import --hive-overwrite \
--create-hive-table -m 1;

遇到以下错误

    2017-05-02 09:21:18,474 ERROR - [main:] ~ Error reading database metadata: 
    com.ibm.db2.jcc.am.SqlSyntaxErrorException: [jcc][10165][10051][4.11.77] 
    Invalid database URL syntax: 
    jdbc:db2://myip:50000/msrc:CurrentSchema=testdb. ERRORCODE=-4461, 
    SQLSTATE=42815 (SqlManager:43)
    com.ibm.db2.jcc.am.SqlSyntaxErrorException: [jcc][10165][10051][4.11.77] 
    Invalid database URL syntax: 
    jdbc:db2://myip:50000/msrc:CurrentSchema=testdb. ERRORCODE=-4461, 
    SQLSTATE=42815
        at com.ibm.db2.jcc.am.gd.a(gd.java:676)
        at com.ibm.db2.jcc.am.gd.a(gd.java:60)
        at com.ibm.db2.jcc.am.gd.a(gd.java:85)
        at com.ibm.db2.jcc.DB2Driver.tokenizeURLProperties(DB2Driver.java:911)
        at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:408)
        at java.sql.DriverManager.getConnection(DriverManager.java:571)
        at java.sql.DriverManager.getConnection(DriverManager.java:215)
        at 
   org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:885)
        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.ImportAllTablesTool.run(ImportAllTablesTool.java:95)
        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)
    Caused by: java.util.NoSuchElementException
        at java.util.StringTokenizer.nextToken(StringTokenizer.java:349)
        at java.util.StringTokenizer.nextToken(StringTokenizer.java:377)
        at com.ibm.db2.jcc.DB2Driver.tokenizeURLProperties(DB2Driver.java:899)
        ... 13 more
    Could not retrieve tables list from server
   2017-05-02 09:21:18,696 ERROR - [main:] ~ manager.listTables() returned null 
    (ImportAllTablesTool:98)
   [

1 个答案:

答案 0 :(得分:0)

<强>命令:

 sqoop import-all-tables \
 --driver com.ibm.db2.jcc.DB2Driver \
 --connect jdbc:db2://myip:50000/databs \
 --username username --password password \
 --hive-database default --hive-import --m 1 \
 --create-hive-table --hive-overwrite

import-all-tables工具将一组表从RDBMS导入HDFS。每个表中的数据存储在HDFS中的单独目录中。

要使import-all-tables工具有用,必须满足以下条件:

  • 每个表必须有一个单列主键。
  • 您必须打算导入每个表的所有列。
  • 您不得打算使用非默认拆分列,也不得通过WHERE子句强加任何条件。