目录
1:安装包准备
2:添加环境变量
3:配置部署
3.1) 修改sqoop-env.sh
3.2) 验证安装是否成功
3.3) 测试Sqoop是否能够成功连接数据库
报错:Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
报错2:与hive交互报错 hive.HiveConfig: Could not load org.apache.hadoop.hive.conf.HiveConf. Make sure HIVE_CONF_DIR is set correctly
报错3:在命令中使用localhost问题
报错4:从hive导入到mysql数据包含表情包问题
说明:Sqoop1.4.7,和HBase2.3.6 兼容性有些问题。将HBase的版本更换成HBase1.3.1
本文所有文件:
链接:https://pan.baidu.com/s/16woOtqv8H8wATgu00iR5fA?pwd=yyds
提取码:yyds
1:安装包准备
http://archive.apache.org/dist/sqoop/ 这里选用的是1.4.7
cd /tmp
# 下载安装包
$ wget http://archive.apache.org/dist/sqoop/1.4.7/sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz
# 解压
sudo tar -zxvf /tmp/sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz -C /usr/local
sudo mv /usr/local/sqoop-1.4.7.bin__hadoop-2.6.0 /usr/local/sqoop-1.4.7
配置Mysql JDBC驱动包到 Sqoop的lib目录下
Java Mysql驱动 mysql-connector-java-5.1.40.jar
cd /tmp
sudo wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.40/mysql-connector-java-5.1.40.jar
# 拷贝到sql依赖库
# cp /tmp/mysql-connector-java-5.1.40.jar /usr/local/sqoop-1.4.7/lib/
cp /tmp/mysql-connector-java-8.0.27.jar /usr/local/sqoop-1.4.7/lib/
注意:mysql-connector-java-8.0.27.jar可以解决表情存储问题
2:添加环境变量
sudo vim /etc/profile.d/sqoop.sh
export SQOOP_HOME=/usr/local/sqoop-1.4.7
export PATH=.:$PATH:$SQOOP_HOME/bin
source让环境变量生效
source /etc/profile
3:配置部署
3.1) 修改sqoop-env.sh
[sqoop-1.4.7]$ cp /usr/local/sqoop-1.4.7/conf/sqoop-env-template.sh /usr/local/sqoop-1.4.7/conf/sqoop-env.sh
vim /usr/local/sqoop-1.4.7/conf/sqoop-env.sh
export HADOOP_COMMON_HOME=/usr/local/hadoop-3.2.2
export HADOOP_MAPRED_HOME=/usr/local/hadoop-3.2.2
export HIVE_HOME=/usr/local/hive-3.1.2
-- 下面看需要
export HBASE_HOME=/usr/local/hbase-2.3.6
export ZOOKEEPER_HOME=/usr/local/zookeeper-3.5.7
export ZOOCFGDIR=/usr/local/zookeeper-3.5.7/conf
3.2) 验证安装是否成功
[root@worker213 ~]$ sqoop help
[root@worker213 ~]$ sqoop-version
出现一些Warning警告(警告信息已省略),并伴随着帮助命令的输出:
3.3) 测试Sqoop是否能够成功连接数据库
sqoop list-databases \
--connect jdbc:mysql://192.168.5.114:3306/ \
--username hive \
--password hive_pw
报错:Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
把commons-lang-2.6.jar上传到/usr/local/sqoop-1.4.7/lib目录
文件在文章顶部网盘
报错2:与hive交互报错 hive.HiveConfig: Could not load org.apache.hadoop.hive.conf.HiveConf. Make sure HIVE_CONF_DIR is set correctly
cd $HIVE_HOME/lib
cp $HIVE_HOME/lib/hive-common-3.1.2.jar /usr/local/sqoop-1.4.7/lib/ -- 这一个也行
cp $HIVE_HOME/lib/hive-exec-3.1.2.jar /usr/local/sqoop-1.4.7/lib/
报错3:在命令中使用localhost问题
mysql使用localhost连接
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications
link failure
改成ip地址连接
报错4:从hive导入到mysql数据包含表情包问题
java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\x8BMo...' for column 'title' at row 4
如果mysql里有表情,5.1.40版本无法存储,这里使用mysql-connector-java-8.0.27.jar解决问题