sqoop 导入从mysql导入数据到hive报类找不到

Posted 北漂-boy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sqoop 导入从mysql导入数据到hive报类找不到相关的知识,希望对你有一定的参考价值。

执行

sqoop  create-hive-table --connect jdbc:mysql://localhost:3306/test --username root --password 123456 --table A --hive-table mysqlToA

报错如下:

20/07/15 14:02:34 ERROR hive.HiveConfig: Could not load org.apache.hadoop.hive.conf.HiveConf. Make sure HIVE_CONF_DIR is set correctly.
20/07/15 14:02:34 ERROR tool.CreateHiveTableTool: Encountered IOException running create table job: 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.CreateHiveTableTool.run(CreateHiveTableTool.java:57)
	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)
	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:349)
	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)
	... 11 more

解决办法:
在 ~/.bashrc文件里面添加如下的信息

export HIVE_CONF_DIR=/data1/hadoop/hive/conf
export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HIVE_HOME/lib/*

source ~/.bashrc


以上是关于sqoop 导入从mysql导入数据到hive报类找不到的主要内容,如果未能解决你的问题,请参考以下文章

sqoop从mysql导入到hive为啥0变成null

使用sqoop从mysql导入数据到hive

Sqoop从本地MySQL导入到Hive为啥要求Sqoop一定要在HDFS中

sqoop把hive表数据导入到mysql中

教程 | 使用Sqoop从MySQL导入数据到Hive和HBase

从 MySQL 到 Hive 的 Sqoop 导入成功,但选择返回所有 NULL 值