安装Sqoop的前提是已经具备Java和Hadoop的环境。
1、下载并解压
(1)下载地址:http://mirrors.hust.edu.cn/apache/sqoop/1.4.6/
(2)上传安装包sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz到虚拟机中
(3)解压sqoop安装包到指定目录,如:自己解压到: /usr/local/hadoop/module文件目录下:
[root@hadoop105 hadoop]# tar -zxvf sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz -C /usr/local/hadoop/module/
2、修改配置文件
Sqoop的配置文件与大多数大数据框架类似,在sqoop根目录下的conf目录中
(1)重命名配置文件
[root@hadoop105 conf]# mv sqoop-env-template.sh sqoop-env.sh
[root@hadoop105 conf]# ll
total 28
-rw-rw-r--. 1 root root 3895 Apr 27 2015 oraoop-site-template.xml
-rwxr-xr-x. 1 root root 1345 Apr 27 2015 sqoop-env.sh
-rw-rw-r--. 1 root root 1404 Apr 27 2015 sqoop-env-template.cmd
-rw-rw-r--. 1 root root 5531 Apr 27 2015 sqoop-site-template.xml
-rw-rw-r--. 1 root root 5531 Apr 27 2015 sqoop-site.xml
(2) 修改配置文件
sqoop-env.sh
export HADOOP_COMMON_HOME=/usr/local/hadoop/module/hadoop-2.7.2
export HADOOP_MAPRED_HOME=/usr/local/hadoop/module/hadoop-2.7.2
export HIVE_HOME=/usr/local/hadoop/module/hive-1.2.1
export ZOOKEEPER_HOME=/usr/local/hadoop/module/zookeeper-3.4.5
export ZOOCFGDIR=/usr/local/hadoop/module/zookeeper-3.4.5
export HBASE_HOME=/usr/local/hadoop/module/hbase-1.3.1
3、拷贝JDBC驱动
拷贝jdbc驱动到sqoop的lib目录下,如:
4、验证Sqoop
我们可以通过某一个command来验证sqoop配置是否正确:
[root@hadoop105 spoop-1.4.6]# bin/sqoop help
出现一些Warning警告(警告信息已省略),并伴随着帮助命令的输出:
Available commands:
codegen Generate code to interact with database records
create-hive-table Import a table definition into Hive
eval Evaluate a SQL statement and display the results
export Export an HDFS directory to a database table
help List available commands
import Import a table from a database to HDFS
import-all-tables Import tables from a database to HDFS
import-mainframe Import datasets from a mainframe server to HDFS
job Work with saved jobs
list-databases List available databases on a server
list-tables List available tables in a database
merge Merge results of incremental imports
metastore Run a standalone Sqoop metastore
version Display version information
5、测试Sqoop是否能够成功连接数据库
[root@hadoop105 spoop-1.4.6]# bin/sqoop list-databases --connect jdbc:mysql://localhost:3306/ --username root --password 123456
Warning: /usr/local/hadoop/module/spoop-1.4.6/bin/../../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /usr/local/hadoop/module/spoop-1.4.6/bin/../../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
20/01/26 19:34:47 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6
20/01/26 19:34:47 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
20/01/26 19:34:48 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
information_schema
metastore
mysql
performance_schema
sys
[root@hadoop105 spoop-1.4.6]#
来源:CSDN
作者:江湖侠客
链接:https://blog.csdn.net/weixin_39868387/article/details/104088814