1、下载sqoop
wget https://mirrors.tuna.tsinghua.edu.cn/apache/sqoop/1.4.7/sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz
2、解压和重命名文件
mkdir /usr/local/sqoop
tar -zxvf sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz -C /usr/local/sqoop
cd /usr/local/sqoop
mv sqoop-1.4.7.bin__hadoop-2.6.0 sqoop-1.4.7
3、进入sqoop的配置目录
cd /usr/local/sqoop/sqoop-1.4.7/conf/
# 将sqoop-env-template.sh复制一份并命名为sqoop-env.sh
cp sqoop-env-template.sh sqoop-env.sh
4、编辑sqoop-env.sh 加入安装了组件的对应路径
vim sqoop-env.sh
#Set path to where bin/hadoop is available
export HADOOP_COMMON_HOME=/usr/local/hadoop/hadoop-3.1.3
#Set path to where hadoop-*-core.jar is available
export HADOOP_MAPRED_HOME=/usr/local/hadoop/hadoop-3.1.3
#set the path to where bin/hbase is available
export HBASE_HOME=/usr/local/hbase/hbase-2.1.7
#Set the path to where bin/hive is available
export HIVE_HOME=/usr/local/hive/hive-3.1.2
#Set the path for where zookeper config dir is
export ZOOCFGDIR=/usr/local/zookeeper/zookeeper-3.4.14
5、配置环境变量
vim /etc/profile
#sqoop config
export SQOOP_HOME=/usr/local/sqoop/sqoop-1.4.7
export PATH=$PATH:$SQOOP_HOME/bin
# 刷新配置文件
source /etc/profile
6、启动MySQL
systemctl start mysqld.service
7、测试连接MySQL
sqoop list-databases --connect jdbc:mysql://192.168.0.51:3306/ --username root -P
# 没有配置环境变量时,使用下面的命令
/usr/local/sqoop/sqoop-1.4.7/bin/sqoop list-databases --connect jdbc:mysql://192.168.0.51:3306/ --username root -P