1.下载文件,并解压
http://archive.apache.org/dist/sqoop/
下面是解压之后的:

2.文件配置
进入conf文件,将sqoop-env-template.sh命名为sqoop-env.sh,并修改sqoop-env.sh:

[root@hadoop001 software]# cat /opt/sqoop/conf/sqoop-env.sh
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# 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=/opt/hadoop/hadoop-2.8.0/#Set path to where hadoop-*-core.jar is available
export HADOOP_MAPRED_HOME=/opt/hadoop/hadoop-2.8.0/#set the path to where bin/hbase is available
#export HBASE_HOME=#Set the path to where bin/hive is available
export HIVE_HOME=/opt/hive/apache-hive-2.3.3-bin#Set the path for where zookeper config dir is
export ZOOCFGDIR=/opt/zookeeper/

3.将mysql驱动包加入到sqoop下lib中

[root@hadoop001 software]# ll /opt/sqoop/lib/...
-rw-r--r-- 1 root root 2428320 3月  29 13:20 mysql-connector-java-8.0.25.jar...

4.配置环境变量:

[root@hadoop001 software]# cat ~/.bashrc
#Sqoop
export SQOOP_HOME=/opt/sqoop
export PATH=$PATH:$SQOOP_HOME/binsource ~/.bashrc

5.验证是否成功

 sqoop-version 或者 sqoop version

6.查看基本命令

sqoop help

7.对mysql简单操作
(1)查看mysql有哪些数据库

[root@hadoop001 software]# sqoop list-databases --connect jdbc:mysql://hadoop001:3306/  --username root --password 000000
Warning: /opt/sqoop/../hbase does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
Warning: /opt/sqoop/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /opt/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
22/04/08 16:58:06 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
22/04/08 16:58:06 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
22/04/08 16:58:06 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
hive
information_schema
mysql
performance_schema

(2)查看mysql有哪些表

[root@hadoop001 software]# sqoop list-tables --connect jdbc:mysql://hadoop001:3306/mysql  --username root --password 000000
Warning: /opt/sqoop/../hbase does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
Warning: /opt/sqoop/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /opt/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
22/04/08 17:01:04 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
22/04/08 17:01:04 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
22/04/08 17:01:04 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
columns_priv
db
event
func
general_log
help_category
help_keyword
help_relation
help_topic
host
ndb_binlog_index

8.sqoop数据导入
(1)将mysql数据导入到hdfs中(未指定hdfs地址,选择默认路径)

sqoop import --connect jdbc:mysql://hadoop001:3306/mysql --username root  --password 000000  --table user   -m 1

查看结果:

[root@hadoop001 software]# hadoop fs -ls /user/root/user
Found 2 items
-rw-r--r--   2 root supergroup          0 2022-04-08 17:26 /user/root/user/_SUCCESS
-rw-r--r--   2 root supergroup        631 2022-04-08 17:26 /user/root/user/part-m-00000
[root@hadoop001 software]# hadoop fs -cat /user/root/user/part-m-00000
localhost,root,*032197AE5731D4664921A6CCAC7CFCE6A0698693,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,,,,,0,0,0,0,,
hadoop001,root,*032197AE5731D4664921A6CCAC7CFCE6A0698693,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,,,,,0,0,0,0,,
127.0.0.1,root,*032197AE5731D4664921A6CCAC7CFCE6A0698693,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,,,,,0,0,0,0,,
::1,root,*032197AE5731D4664921A6CCAC7CFCE6A0698693,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,,,,,0,0,0,0,,
%,root,*032197AE5731D4664921A6CCAC7CFCE6A0698693,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,N,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,,,,,0,0,0,0,,

(2)将mysql数据导入到hdfs中(指定hdfs地址和分隔符)

sqoop import  --connect jdbc:mysql://hadoop001:3306/mysql  --username root --password root  --table help_keyword  --target-dir /user/root/user/user_table  --fields-terminated-by '&' -m 2

查看结果:

root@hadoop001 software]# hdfs dfs -cat /user/root/user/user_table/part-m-00000
0&JOIN
1&HOST
2&REPEAT
3&SERIALIZABLE
4&REPLACE
5&AT
6&SCHEDULE
7&RETURNS
8&STARTS
9&MASTER_SSL_CA
10&NCHAR
11&COLUMNS
12&COMPLETION
13&WORK
14&DATETIME

sqoop搭建配置使用相关推荐

  1. 基于认证的代理平台搭建配置squid-20130730

    基于认证的代理平台搭建配置squid-20130730 功能:通过squid代理实现 (1)基于用户名密码认证的出口ip路由选择 (2)基于client源ip的出口ip路由选择 (3)基于连接本机ip ...

  2. Linux下svn搭建配置流程

    Linux下svn搭建配置流程     一.    源文件编译安装.源文件共两个,为: 1.   下载subversion源文件 subversion-1.6.1.tar.gz http://d136 ...

  3. Linux下的NFS搭建配置

    Linux下的NFS搭建配置 一.NFS介绍 1.NFS简介 2.NFS特点 二.环境介绍 三.服务端配置 1.创建共享目录 2.检查NFS包是否安装 3.安装nfs相关包 4.编辑配置文件 5.重启 ...

  4. linux下本地的源的格式,[Linux]CentOS7搭建/配置:YUM仓库/源[本地源/HTTP源/自建源仓库...

    [Linux]CentOS7搭建/配置:YUM仓库/源[本地源/HTTP源/自建源仓库 1 本地YUM源 1.1 [YUM仓库/服务端] 获取:软件包资源 1.2 [YUM仓库/服务端] 挂载/搭建: ...

  5. Linux下svn搭建配置

    Linux下svn搭建配置 1.安装svn客户端    yum install subversion    svnserve --version                       :如果成功 ...

  6. DreamweaverCS6搭建配置php本地站点(图文教程)- 教程篇

    通过Dreamweaver.exe 配置PHP本地服务站点 一.软件安装说明: Dreamweaver_CS6.exe 二.步骤图解: 第一步: 第二步: 第三步: 第四步: 三.其他版本: Drea ...

  7. PyQt5 环境搭建+配置+怎样运行生成的.py程序

    PyQt5 环境搭建+配置+怎样运行生成的.py程序 PyQt5安装及配置 安装 配置 Error while finding module specification for 'PyQt5.uic. ...

  8. Linux下svn 安装搭建配置流程

    Linux下svn搭建配置流程     一.    源文件编译安装.源文件共两个,为: 1.   下载subversion源文件 subversion-1.6.1.tar.gz http://d136 ...

  9. Redis高可用集群-哨兵模式(Redis-Sentinel)搭建配置教程【Windows环境】

    ================================================= 人工智能教程.零基础!通俗易懂!风趣幽默!大家可以看看是否对自己有帮助! 点击查看高清无码教程 == ...

最新文章

  1. 【预告】腾讯移动分析 MTA 即刻登陆 2017 GMTC 全球移动技术大会
  2. 1.1.3 以类为单位的编程思想
  3. SpringBoot集成MybatisPlus 涵盖了目前流行的知识点!!!即用即cv即可!!!学过的同学,也可以存储作为工具!!
  4. Azure上用API成功创建Lambda Function的截图
  5. redis5 外部不能连接_【硬见小百科】PCB连接的方法
  6. 这样实现分布式锁,才叫优雅!
  7. 传奇霸业维护服务器,37传奇霸业6月21日部分区服维护计划
  8. Weblogic java生成wlfullclient.jar
  9. 美媒:中国可能引领“物联网”的进步
  10. python循环习题
  11. 饭店计算机软件系统FIDlLIL,【万迅千里马餐饮管理系统_饭店餐厅管理软件】免费试用_餐饮软件_选软件网...
  12. glsurfaceview 和 open gl
  13. matlab求多元函数微积分,中北大学高等数据MATLAB验证性实验7多元函数微积分学MATLAB实验报告格式...
  14. html图片逆时针转换,css3怎样做出逆时针旋转倒计时
  15. 无法完成windows正版认证
  16. 供应链金融业务如何脱颖而出?
  17. MAC清除Launchpad 应用程序 图标
  18. 如何用手机快捷设计品牌宣传的海报图片和视频
  19. mysql 批量查询
  20. 高手帮忙啊!关于插入数据库的问题!急急!菜鸟提问!

热门文章

  1. 看图详解各种跳线的定义
  2. 【ansys workbench】怎么修改mechanical的单位?
  3. 自学考试——信息系统开发与管理
  4. 射频天线设计-阻抗匹配
  5. 【万字箴言】技术焦虑的减法与解法
  6. matlab产生正弦数组,matlab生成正弦系数表
  7. Flutter嵌入swift混合开发
  8. C# 四种九九乘法表
  9. 解决2bizbox怎么设置付款周期
  10. oracle里的listagg,oracle中的listagg函数