3)将MySQL数据导入Hive
sqoop import --connect jdbc:mysql://172.16.100.173:3306/hdb --username root --password oracletest --table htest --fields-terminated-by '\t' --delete-target-dir --num-mappers 1 --hive-import --hive-database hdb --hive-table htest
五、问题处理
1、ERROR hive.HiveConfig: Could not load org.apache.hadoop.hive.conf.HiveConf. Make sure HIVE_CONF_DIR is set correctly.
环境变量中加如
export HIVE_CONF_DIR=/home/hadoop/apache-hive-2.3.6-bin/conf
export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HIVE_HOME/lib/*
2、ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
解决办法:
vim $JAVA_HOME/jre/lib/security/java.policy
在grant{}内部添加如下内容:
permission javax.management.MBeanTrustPermission "register";
3、ERROR exec.TaskRunner: Error in executeTask
java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectMapper.readerFor(Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/ObjectReader
4、ERROR tool.ImportTool: Import failed: java.io.IOException: Hive CliDriver exited with status=-101
5、FAILED: Execution Error, return code -101 from org.apache.hadoop.hive.ql.exec.MoveTask. com.fasterxml.jackson.databind.ObjectMapper.readerFor(Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/ObjectReader;
19/11/01 14:24:14 ERROR ql.Driver: FAILED: Execution Error, return code -101 from org.apache.hadoop.hive.ql.exec.MoveTask. com.fasterxml.jackson.databind.ObjectMapper.readerFor(Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/ObjectReader;
3、4、5都通过将hive $HIVE_HOME/lib/jackson*.jar 拷贝至 $SQOOP_HOME/lib 目录中,解决
将$SQOOP_HOME/lib/jackson*.jar 文件bak,再把$HIVE_HOME/lib/jackson*.jar 拷贝至 $SQOOP_HOME/lib 目录中,重新运行sqoop 作业,导入成功。