从mysql导入sqoop失败,线程“main”java.lang.noclassdeffounderror中出现异常

dbf7pr2w  于 2021-06-03  发布在  Sqoop
关注(0)|答案(2)|浏览(521)

从mysql导入数据 sqoopdb 从表到hdfs employee 命令
sqoop import --connect jdbc:mysql://localhost:3306/sqoopdb --username sqoop -P --table employee sqoop import --connect jdbc:mysql://localhost:3306/sqoopdb --username sqoop -P --table employee --m 1 两者都会产生以下错误:

Warning: /usr/local/sqoop/../hbase does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
Warning: /usr/local/sqoop/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /usr/local/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
Warning: /usr/local/sqoop/../zookeeper does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
2019-03-24 16:08:19,779 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
Enter password: 
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
            at org.apache.sqoop.tool.BaseSqoopTool.validateHiveOptions(BaseSqoopTool.java:1583)
            at org.apache.sqoop.tool.ImportTool.validateOptions(ImportTool.java:1178)
            at org.apache.sqoop.Sqoop.run(Sqoop.java:137)
            at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76)
            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)
        Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils
            at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
            ... 8 more`
vyswwuz2

vyswwuz21#

请尝试以下命令:

sqoop import --connect jdbc:mysql://localhost:3306/sqoopdb --driver com.mysql.jdbc.Driver --username sqoop -P --table employee --m 1

另外,请确保已使用授予对此数据库的访问权限

% mysql -u root -p 
Enter password:
mysql> GRANT ALL PRIVILEGES ON sqoopdb.* TO ''@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> quit;
Bye
92vpleto

92vpleto2#

下载并复制 commons-lang-2.6.jar/usr/local/sqoop/lib 文件夹和 import 会很好的。
我正在使用 Hadoop - 3.2.0 以及 Sqoop 1.4.7

相关问题