Sqoop导入数据到Hive报错,java.lang.ClassNotFoundException: org.apache.hadoop.hive.conf.HiveConf

执行命令,如:

sqoop import --connect jdbc:mysql://master:3306/sqoopDB --table employees --username bear --password 123456  --hive-import -m 1

报如下错误:

18/12/05 20:13:31 INFO hive.HiveImport: Loading uploaded data into Hive
18/12/05 20:13:31 ERROR hive.HiveConfig: Could not load org.apache.hadoop.hive.conf.HiveConf. Make sure HIVE_CONF_DIR is set correctly.
18/12/05 20:13:31 ERROR tool.ImportTool: Import failed: java.io.IOException: java.lang.ClassNotFoundException: org.apache.hadoop.hive.conf.HiveConf
	at org.apache.sqoop.hive.HiveConfig.getHiveConf(HiveConfig.java:50)
	at org.apache.sqoop.hive.HiveImport.getHiveArgs(HiveImport.java:392)
	at org.apache.sqoop.hive.HiveImport.executeExternalHiveScript(HiveImport.java:379)
	at org.apache.sqoop.hive.HiveImport.executeScript(HiveImport.java:337)
	at org.apache.sqoop.hive.HiveImport.importTable(HiveImport.java:241)
	at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:537)
	at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:628)
	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)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hive.conf.HiveConf
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at org.apache.sqoop.hive.HiveConfig.getHiveConf(HiveConfig.java:44)
	... 12 more

解决办法:

cp hive-2.3.4/lib/hive-common-2.3.4.jar sqoop-1.4.7/lib/

再次执行,成功:

18/12/05 20:20:29 INFO hive.HiveImport: 
18/12/05 20:20:29 INFO hive.HiveImport: Logging initialized using configuration in jar:file:/home/hadoop/hive-2.3.4/lib/hive-common-2.3.4.jar!/hive-log4j2.properties Async: true
18/12/05 20:20:51 INFO hive.HiveImport: OK
18/12/05 20:20:51 INFO hive.HiveImport: Time taken: 18.063 seconds
18/12/05 20:20:52 INFO hive.HiveImport: Loading data to table default.employees
18/12/05 20:20:56 INFO hive.HiveImport: OK
18/12/05 20:20:56 INFO hive.HiveImport: Time taken: 4.607 seconds
18/12/05 20:20:56 INFO hive.HiveImport: Hive import complete.
18/12/05 20:20:56 INFO hive.HiveImport: Export directory is contains the _SUCCESS file only, removing the directory.

完!

相关推荐
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页