从Oracle进行的Sqoop导入失败,出现“线程“主”中的异常java.lang.NoClassDefFoundError:org / apache / hadoop / mapreduce / InputFormat”

时间:2018-08-09 11:18:22

标签: hadoop mapreduce sqoop hadoop2

当尝试使用Sqoop将数据从Oracle导入Hadoop时,它失败,并显示错误"Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/mapreduce/InputFormat"

彻底解决此Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.mapreduce.InputFormat。但是,这些并没有解决我的问题。

命令使用如下。

sqoop import -D mapred.child.java.opts='-Djava.security.egd=file:/dev/urandom' --connect jdbc:oracle:thin:@//host:port/servicename --username XXXXX --password XXXXX   --hadoop-mapred-home /usr/lib/hadoop-mapreduce --table DB.STUDENTS --verbose --target-dir /user/1234/out -m 1

下面是我收到错误的日志部分。

18/08/10 03:42:48 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-user1234/compile/115556141b1ea2b78ea960493a789953/DB1.STUDENTS.jar
18/08/10 03:42:48 DEBUG orm.CompilationManager: Scanning for .class files in directory: /tmp/sqoop-user1234/compile/115556141b1ea2b78ea960493a789953
18/08/10 03:42:48 DEBUG orm.CompilationManager: Got classfile: /tmp/sqoop-user1234/compile/115556141b1ea2b78ea960493a789953/DB1_STUDENTS.class -> DB1_STUDENTS.class
18/08/10 03:42:48 DEBUG orm.CompilationManager: Finished writing jar file /tmp/sqoop-user1234/compile/115556141b1ea2b78ea960493a789953/DB1.STUDENTS.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/mapreduce/InputFormat
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
        at java.security.AccessController.doPrivileged(Native Method)

此类org/apache/hadoop/mapreduce/InputFormat在jar /usr/lib/hadoop-mapreduce/hadoop-mapreduce-client-core-2.6.0-cdh5.7.1.jar中可用,并且变量(export HADOOP_MAPRED_HOME=/usr/lib/hadoop-mapreduce)设置为此路径。

以下是配置变量的方式。

export HADOOP_MAPRED_HOME=/usr/lib/hadoop-mapreduce
export HADOOP_COMMON_HOME=/usr/lib/hadoop
export SQOOP_HOME=/usr/lib/sqoop
export HADOOP_CONF_DIR=/etc/conf/hadoop_dev

0 个答案:

没有答案