1. 下载sqoop1.4.7
cd /home/workspace wget https://mirrors.tuna.tsinghua.edu.cn/apache/sqoop/1.4.7/sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz tar -xzvf sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz cd sqoop-1.4.7.bin__hadoop-2.6.0/conf mv sqoop-env-template.sh sqoop-env.sh
2. 配置sqoop
vim sqoop-env.sh
添加以下内容
export HADOOP_COMMON_HOME=/opt/hadoop-2.7.3 export HADOOP_MAPRED_HOME=/opt/hadoop-2.7.3 export HIVE_HOME=/home/workspace/apache-hive-2.3.4-bin
3. 配置环境变量
vim /etc/profile
添加以下内容
#Sqoop export SQOOP_HOME=/home/workspace/sqoop-1.4.7.bin__hadoop-2.6.0 export PATH=$PATH:$SQOOP_HOME/bin
执行source /etc/profile 让环境变量生效
4. 将mysql驱动包mysql-connector-java-5.1.47.jar 拷贝到sqoop/lib 目录下
jar包可以到mysql官网下载,或者从下面百度云盘的链接下载
https://pan.baidu.com/s/1QiHSW3ccqYjF2rfEacbUZg
FAQ:
1. 在创建job时如果遇到类似NoClassDefFoundError: org/json/JSONObject的错误,详细如下
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONObject
at org.apache.sqoop.util.SqoopJsonUtil.getJsonStringforMap(SqoopJsonUtil.java:43)
at org.apache.sqoop.SqoopOptions.writeProperties(SqoopOptions.java:785)
at org.apache.sqoop.metastore.hsqldb.HsqldbJobStorage.createInternal(HsqldbJobStorage.java:399)
......
原因:sqoop缺少java-json.jar包.
解决:
这是因为sqoop缺少java-json.jar包.
下载java-json.jar包:
http://www.java2s.com/Code/Jar/j/Downloadjavajsonjar.htm
把java-json.jar添加到../sqoop/lib目录:
cp java-json.jar /sqoop/lib