1. 上传并解压安装包

tar -zxvf sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz -C ../server/

重命名:mv sqoop-1.4.7.bin__hadoop-2.6.0 sqoop

2. 配置环境变量

sudo vim /etc/profile

# 配置sqoop的环境变量

export SQOOP_HOME=/export/server/sqoop

export PATH=$PATH:$SQOOP_HOME/bin

source /etc/profile

3. 修改sqoop的配置文件

cp /$SQOOP_HOME/conf/sqoop-env-template.sh  /$SQOOP_HOME/conf/sqoop-env.sh

vim sqoop-env.sh

#Set path to where bin/hadoop is available

export HADOOP_COMMON_HOME=/export/server/hadoop

#Set path to where hadoop-*-core.jar is available

export HADOOP_MAPRED_HOME=/export/server/hadoop

#set the path to where bin/hbase is available

export HBASE_HOME=/export/server/hbase

#Set the path to where bin/hive is available

export HIVE_HOME=/export/server/hive

#Set the path for where zookeper config dir is

export ZOOCFGDIR=/export/server/ zookeeper/conf

4.上传相关jar包

# 上传

#mysql驱动下载地址:Maven Repository: JDBC Drivers (mvnrepository.com)

mysql-connector-java-8.0.8-dmr-bin.jar  

hive/lib目录下

commons-lang-2.6.jar

hive-common-2.3.9.jar

protobuf-java-3.22.2.jar

# 到sqoop/lib目录

5.测试

连接MySQL查看数据库列表

sqoop list-databases --username root --password 1234 --connect jdbc:mysql://node1:3306/

可见安装的sqoop可用。

6.问题解决

(1)报错Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils

解决办法:cp /export/server/apache-hive-3.1.3-bin/lib/commons-lang-2.6.jar /export/server/sqoop-1.4.7/lib/ 在hive中把相关包复制到sqoop的lib目录

(2)报错:ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.RuntimeException: Could not load db driver class: com.mysql.jdbc.Driver

解决办法:上传MySQL驱动到sqoop/lib目录

 #mysql驱动下载地址:

Maven Repository: JDBC Drivers (mvnrepository.com)icon-default.png?t=N7T8https://mvnrepository.com/open-source/jdbc-drivers

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部