1.下载sqoop
http://archive.apache.org/dist/sqoop/1.4.6/
2.解压,配置环境变量
tar -zxvf sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz -C /home/dzh/opt/module/
vi /etc/profile,添加
export SQOOP_HOME=/home/dzh/opt/module/sqoop export PATH=$PATH:$SQOOP_HOME/bin
source /etc/profile
激活配置
3.修改配置文件sqoop-env.sh
进入到sqoop/conf目录下,也就是执行命令:
将sqoop-env-template.sh复制一份,并取名为sqoop-env.sh,也就是执行命令:
cp sqoop-env-template.sh sqoop-env.sh
vi sqoop-env.sh 添加
export HADOOP_COMMON_HOME=/home/dzh/opt/module/hadoop-2.6.0 export HADOOP_MAPRED_HOME=/home/dzh/opt/module/hadoop-2.6.0 export HIVE_HOME=/home/dzh/opt/module/hive
4.将mysql驱动包拷贝到$SQOOP_HOME/lib
下载地址:https://dev.mysql.com/downloads/connector/j/
cp mysql-connector-java-5.1.40/mysql-connector-java-5.1.40-bin.jar /home/dzh/opt/module/sqoop/lib
测试sqoop与MySQL之间的连接是否成功:
sqoop list-databases --connect jdbc:mysql://127.0.0.1:3306/ --username root -P
如下图,测试成功