sqoop执行命令
[root@kynode3 server]# sqoop list-databases --connect jdbc:mysql://kynode1:3306 --username root --password 123456
2023-02-19 11:18:40,514 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
2023-02-19 11:18:40,596 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
2023-02-19 11:18:40,682 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.<init>(SqlManager.java:89)
at com.cloudera.sqoop.manager.SqlManager.<init>(SqlManager.java:33)
at org.apache.sqoop.manager.GenericJdbcManager.<init>(GenericJdbcManager.java:51)
at com.cloudera.sqoop.manager.GenericJdbcManager.<init>(GenericJdbcManager.java:30)
at org.apache.sqoop.manager.CatalogQueryManager.<init>(CatalogQueryManager.java:46)
at com.cloudera.sqoop.manager.CatalogQueryManager.<init>(CatalogQueryManager.java:31)
at org.apache.sqoop.manager.InformationSchemaManager.<init>(InformationSchemaManager.java:38)
at com.cloudera.sqoop.manager.InformationSchemaManager.<init>(InformationSchemaManager.java:31)
at org.apache.sqoop.manager.MySQLManager.<init>(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:76)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:183)
解决方案
1)根据参考,下载驱动包:commons-lang-2.6.jar
下载地址:https://mirrors.tuna.tsinghua.edu.cn/apache//commons/lang/binaries/commons-lang-2.6-bin.zip
下载地址可能存在失效,只需要找到commons-lang-2.6.jar
(2)上述下载压缩包:commons-lang-2.6-bin.zip,须解压,然后将其中的“commons-lang-2.6.jar”拷贝至Sqoop中lib中。
(3)再次测试:
[root@kynode3 lib]# sqoop list-databases --connect jdbc:mysql://kynode1:3306 --username root --password 123456
2023-02-19 11:22:13,466 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
2023-02-19 11:22:13,528 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
2023-02-19 11:22:13,611 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
information_schema
hive
mysql
performance_schema
sys
问题剖析
原因是:笔者所安装的Sqoop版本为sqoop-1.4.7,缺少驱动包:commons-lang-2.6.jar,已存在commons-lang3-3.4.jar不合适。
因此需要另外下载驱动包:commons-lang-2.6.jar。