sqoop连接MYSQL报错处理

Sqoop远程连接MYSQL数据库报/apache/commons/lang/StringUtils错误,如下:

[root@manager ~]# sqoop list-databases --connect jdbc:mysql://10.100.81.207:3306/ --username root --password 123
Warning: /home/bigdata/sqoop//../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /home/bigdata/sqoop//../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
Warning: /home/bigdata/zookeeper does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
2023-10-27 17:21:07,607 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
2023-10-27 17:21:07,637 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
2023-10-27 17:21:07,755 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
        at org.apache.sqoop.manager.MySQLManager.initOptionDefaults(MySQLManager.java:73)
        at org.apache.sqoop.manager.SqlManager.(SqlManager.java:89)
        at com.cloudera.sqoop.manager.SqlManager.(SqlManager.java:33)
        at org.apache.sqoop.manager.GenericJdbcManager.(GenericJdbcManager.java:51)
        at com.cloudera.sqoop.manager.GenericJdbcManager.(GenericJdbcManager.java:30)
        at org.apache.sqoop.manager.CatalogQueryManager.(CatalogQueryManager.java:46)
        at com.cloudera.sqoop.manager.CatalogQueryManager.(CatalogQueryManager.java:31)
        at org.apache.sqoop.manager.InformationSchemaManager.(InformationSchemaManager.java:38)
        at com.cloudera.sqoop.manager.InformationSchemaManager.(InformationSchemaManager.java:31)
        at org.apache.sqoop.manager.MySQLManager.(MySQLManager.java:65)
        at org.apache.sqoop.manager.DefaultManagerFactory.accept(DefaultManagerFactory.java:67)
        at org.apache.sqoop.ConnFactory.getManager(ConnFactory.java:184)
        at org.apache.sqoop.tool.BaseSqoopTool.init(BaseSqoopTool.java:272)
        at org.apache.sqoop.tool.ListDatabasesTool.run(ListDatabasesTool.java:44)
        at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:82)
        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)
        ... 20 more

解决办法:
在apache 上下载commons-lang-2.6.jar包并上传到sqoop的lib下即可,下载地址:

点击下载


[root@manager ~]# sqoop list-databases --connect jdbc:mysql://10.100.81.207:3306/ --username root --password 123
Warning: /home/bigdata/sqoop//../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /home/bigdata/sqoop//../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
Warning: /home/bigdata/zookeeper does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
2023-10-27 17:28:17,875 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
2023-10-27 17:28:17,909 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
2023-10-27 17:28:18,032 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
Fri Oct 27 17:28:18 CST 2023 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
information_schema
hive
mysql

执行成功

你可能感兴趣的:(sqoop,mysql,hadoop)