解决Sqoop将mysql表数据导入到Hive时报错HiveConf和derby driver问题

执行sqoop import 语句将mysql表数据导入到Hive表

$ sqoop import --connect jdbc:mysql://localhost:3306/ua1  --username root --password 123 --table EMP --fields-terminated-by '\t'  --num-mappers 1  --hive-database default --hive-import --hive-table hive_zhangsan

 

出现如下HiveConf报错:

19/11/29 19:20:04 ERROR hive.HiveConfig: Could not load org.apache.hadoop.hive.conf.HiveConf. Make sure HIVE_CONF_DIR is set correctly.
19/11/29 19:20:04 ERROR tool.ImportTool: Import failed: java.io.IOException: java.lang.ClassNotFoundException: org.apache.hadoop.hive.conf.HiveConf

 

解决办法:

复制hive-common-2.3.6.jar到sqoop/lib目录下

$ cp $HIVE_HOME/lib/hive-common-2.3.6.jar $SQOOP_HOME/lib

 

 

再次执行sqoop import导入语句,报错变化为:

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.apache.derby.jdbc.AutoloadedDriver40

 

解决办法:复制derby jar包到sqoop的lib目录下

$ cp $HIVE_HOME/lib/derby-10.10.2.0.jar $SQOOP_HOME/lib

 

再次执行sqoop import导入语句,成功!

 

完成!enjoy it!

 

你可能感兴趣的:(问题,sqoop)