Linux 安装 Sqoop (并连接 mysql 测试)

文章目录

环境描述

软件 版本
操作系统 CentOS 7
sqoop 1.4.6
hadoop 2.7.7
mysql 5.7.26

下载与解压

sqoop下载地址
使用命令:tar -zxvf sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz 解压。

更改配置 sqoop-env.sh

解压之后

[root@centos2020 hadoop-2.7.7]# cd /usr/sqoop/sqoop-1.4.7.bin__hadoop-2.6.0/
[root@centos2020 sqoop-1.4.7.bin__hadoop-2.6.0]# ls
bin            COMPILING.txt  ivy      LICENSE.txt  README.txt             sqoop-test-1.4.7.jar
build.xml      conf           ivy.xml  NOTICE.txt   sqoop-1.4.7.jar        src
CHANGELOG.txt  docs           lib      pom-old.xml  sqoop-patch-review.py  testdata

修改sqoop-env.sh

因为有一个模板配置文件,因此改名之后:

[root@centos2020 sqoop-1.4.7.bin__hadoop-2.6.0]# cd conf
[root@centos2020 conf]# vim sqoop-env.sh 

sqoop-env.sh 增加配置内容如下:

[root@centos2020 conf]# vim sqoop-env.sh 

# limitations under the License.

# included in all the hadoop scripts with source command
# should not be executable directly
# also should not be passed any arguments, since we need original $*

# Set Hadoop-specific environment variables here.

#Set path to where bin/hadoop is available
export HADOOP_COMMON_HOME=/usr/hadoop/hadoop-2.7.7

#Set path to where hadoop-*-core.jar is available
export HADOOP_MAPRED_HOME=/usr/hadoop/hadoop-2.7.7

#set the path to where bin/hbase is available
#export HBASE_HOME=

#Set the path to where bin/hive is available
export HIVE_HOME=/usr/hive/apache-hive-2.3.6-bin

#Set the path for where zookeper config dir is
#export ZOOCFGDIR=

配置环境变量

[root@centos2020 conf]# vim /etc/profile
[root@centos2020 conf]# source /etc/profile

配置的内容是:

#sqoop environment
export SQOOP_HOME=/usr/sqoop/sqoop-1.4.7.bin__hadoop-2.6.0
export PATH=$PATH:$SQOOP_HOME/bin
export CLASSPATH=$CLASSPATH:$SQOOP_HOME/lib

拷贝 mysql 驱动

将 mysql 驱动拷贝到/usr/sqoop/sqoop-1.4.7.bin__hadoop-2.6.0/lib 目录下。
驱动包可以从 maven 仓库、或官网下载。

我这里用的是:
mysql-connector-java-5.1.48.jar

启动mysql

service mysql start

查看 sqoop 版本

[root@centos2020 sqoop-1.4.7.bin__hadoop-2.6.0]# sqoop version
Warning: /usr/sqoop/sqoop-1.4.7.bin__hadoop-2.6.0/../hbase does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
Warning: /usr/sqoop/sqoop-1.4.7.bin__hadoop-2.6.0/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /usr/sqoop/sqoop-1.4.7.bin__hadoop-2.6.0/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
Warning: /usr/sqoop/sqoop-1.4.7.bin__hadoop-2.6.0/../zookeeper does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
20/02/25 05:41:01 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
Sqoop 1.4.7
git commit id 2328971411f57f0cb683dfb79d19d4d19d185dd8
Compiled by maugli on Thu Dec 21 15:59:58 STD 2017

用mysql 进行测试

[root@centos2020 sqoop-1.4.7.bin__hadoop-2.6.0]# sqoop list-databases --connect jdbc:mysql://centos2020:3306/ --username root -P
Warning: /usr/sqoop/sqoop-1.4.7.bin__hadoop-2.6.0/../hbase does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
Warning: /usr/sqoop/sqoop-1.4.7.bin__hadoop-2.6.0/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /usr/sqoop/sqoop-1.4.7.bin__hadoop-2.6.0/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
Warning: /usr/sqoop/sqoop-1.4.7.bin__hadoop-2.6.0/../zookeeper does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
20/02/25 05:42:13 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
Enter password: 
20/02/25 05:42:19 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
Tue Feb 25 05:42:20 EST 2020 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
information_schema
mysql
performance_schema
sys

看到有 mysql 中的表名打印出来了,证明配置成功了。

Linux 安装 Sqoop (并连接 mysql 测试)Linux 安装 Sqoop (并连接 mysql 测试) 你家宝宝 发布了141 篇原创文章 · 获赞 122 · 访问量 3万+ 私信 关注
上一篇:Sqoop从关系型数据库往HDFS上导入及导出文件


下一篇:七,sqoop 安装