squip从db2导入hdfs的问题

问题描述 投票:0回答:1

我正在尝试使用sqoop将数据从DB2导入到hdfs。由于我没有复制db2jcc4.jar到/ var / lib / sqoop /目录的管理员权限,因此我将jar复制到了我要执行的位置,并使用--libjars选项指定了该jar。

    sqoop import \
   --libjars db2jcc4.jar \
   --driver com.ibm.db2.jcc.DB2Driver \
   --connect 'jdbc:db2://<hostname>:50000/<dbname>' \
   --username <username> \
   --password <password> \
   --table <tablename> \
   --target-dir /hdfs path

我收到如下错误:

   20/04/15 15:16:59 ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.RuntimeException: Could not load db driver class: com.ibm.db2.jcc.DB2Driver
java.lang.RuntimeException: Could not load db driver class: com.ibm.db2.jcc.DB2Driver
        at org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:875)
        at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:52)
        at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:763)
        at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:786)
        at org.apache.sqoop.manager.SqlManager.getColumnInfoForRawQuery(SqlManager.java:289)
        at org.apache.sqoop.manager.SqlManager.getColumnTypesForRawQuery(SqlManager.java:260)
        at org.apache.sqoop.manager.SqlManager.getColumnTypes(SqlManager.java:246)
        at org.apache.sqoop.manager.ConnManager.getColumnTypes(ConnManager.java:327)
        at org.apache.sqoop.orm.ClassWriter.getColumnTypes(ClassWriter.java:1858)
        at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1657)
        at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:106)
        at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:494)
        at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:621)
        at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:183)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:234)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:243)
        at org.apache.sqoop.Sqoop.main(Sqoop.java:252)

谁能帮我解决问题

db2 sqoop hadoop2 sqoop2 data-ingestion
1个回答
0
投票

连接到Db2不仅需要db2jcc4.jar,还需要其相应的许可证JAR,例如db2jcc_license_cisuz.jar或db2jcc_license_cu.jar。许可证JAR的文件名根据所访问的Db2服务器平台而有所不同(对于Linux,UNIX和Windows Db2服务器,使用cu,而cisuz添加对IBM i中型和z / OS大型机Db2服务器的访问)。

两个db2jcc JAR都需要在程序使用的任何类路径变量中列出。对于sqoop,环境变量为HADOOP_CLASSPATH,运行sqoop时可能仍需要指定--libjars选项。

export HADOOP_CLASSPATH="/tmp/jdbcjars/db2jcc4.jar:/tmp/jdbcjars/db2jcc_license_cisuz.jar"
sqoop import --libjars /tmp/jdbcjars/db2jcc4.jar,/tmp/jdbcjars/db2jcc_license_cisuz.jar ...
© www.soinside.com 2019 - 2024. All rights reserved.