Sqoop全量导入mysql表数据到HDFS

2023-05-16

                  我是在三个节点运行的,主节点只有namenode和mysql数据库

1.开启服务

具有NameNode和DataNode

start-all.sh

2.进入sqoop的目录下并且输入代码

下面的命令用于从 MySQL 数据库服务器中的 emp 表导入 HDFS。
bin/sqoop import \
--connect jdbc:mysql://Master:3306/userdb \
--username root \
--password 000000 \
--delete-target-dir \
--target-dir /sqoopresult \
--table emp --m 1





/*
这里的sqoop import是固定搭配

Master是主节点,如果本地可以写localhost,  userdb是mysql所选数据库

username/password 是mysql的账号和密码

delete-target-dir 它的意思是查看hdfs上是否有所创的文件夹,如果有就删去重新覆盖

target-dir /sqoopresult 是在hdfs上创一文件夹sqoopresult,将emp表导入hdfs

emp 是mysql数据库的表名

--m 1 是运行map操作的一个进程

*/

 3.运行错误点

这里有时会报错例如:

ERROR manager.SqlManager: Error reading from database: java.sql.SQLException: Streaming result set com.mysql.jdbc.RowDataDynamic@291ae is still active. No statements may be issued when any streaming result sets are open and in use on a given connection. Ensure that you have called .close() on any active streaming result sets before attempting more queries.
java.sql.SQLException: Streaming result set com.mysql.jdbc.RowDataDynamic@291ae is still active. No statements may be issued when any streaming result sets are open and in use on a given connection. Ensure that you have called .close() on any active streaming result sets before attempting more queries.

可以检查MySQL驱动和更新connection

4.运行展示

[root@master sqoop]# bin/sqoop import \
> --connect jdbc:mysql://Master:3306/userdb \
> --username root \
> --password 000000 \
> --delete-target-dir \
> --target-dir /sqoopresult \
> --table emp --m 1
Warning: /usr/local/src/sqoop/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /usr/local/src/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
22/10/21 12:47:30 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
22/10/21 12:47:30 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using
22/10/21 12:47:30 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
22/10/21 12:47:30 INFO tool.CodeGenTool: Beginning code generation
Fri Oct 21 12:47:30 CST 2022 WARN: Establishing SSL connection without server's identity verification is not reconnection must be established by default if explicit option isn't set. For compliance with existing applicationsneed either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for ser
22/10/21 12:47:31 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `emp` AS t LIMIT 1
22/10/21 12:47:31 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `emp` AS t LIMIT 1
22/10/21 12:47:31 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /usr/local/src/hadoop-2.6.0
注: /tmp/sqoop-root/compile/376a663c8523374b2cfb22cf997e628c/emp.java使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
22/10/21 12:47:33 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-root/compile/376a663c8523374b2cfb22c
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/src/hadoop-2.6.0/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/o
SLF4J: Found binding in [jar:file:/usr/local/src/hbase/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerB
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
22/10/21 12:47:34 INFO tool.ImportTool: Destination directory /sqoopresult is not present, hence not deleting.
22/10/21 12:47:34 WARN manager.MySQLManager: It looks like you are importing from mysql.
22/10/21 12:47:34 WARN manager.MySQLManager: This transfer can be faster! Use the --direct
22/10/21 12:47:34 WARN manager.MySQLManager: option to exercise a MySQL-specific fast path.
22/10/21 12:47:34 INFO manager.MySQLManager: Setting zero DATETIME behavior to convertToNull (mysql)
22/10/21 12:47:34 INFO mapreduce.ImportJobBase: Beginning import of emp
22/10/21 12:47:34 INFO Configuration.deprecation: mapred.jar is deprecated. Instead, use mapreduce.job.jar
22/10/21 12:47:34 INFO Configuration.deprecation: mapred.map.tasks is deprecated. Instead, use mapreduce.job.map
22/10/21 12:47:34 INFO client.RMProxy: Connecting to ResourceManager at Master/10.7.75.205:8032
Fri Oct 21 12:47:42 CST 2022 WARN: Establishing SSL connection without server's identity verification is not reconnection must be established by default if explicit option isn't set. For compliance with existing applicationsneed either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for ser
22/10/21 12:47:42 INFO db.DBInputFormat: Using read commited transaction isolation
22/10/21 12:47:43 INFO mapreduce.JobSubmitter: number of splits:1
22/10/21 12:47:43 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1666320636626_0001
22/10/21 12:47:44 INFO impl.YarnClientImpl: Submitted application application_1666320636626_0001
22/10/21 12:47:44 INFO mapreduce.Job: The url to track the job: http://master:8088/proxy/application_16663206366
22/10/21 12:47:44 INFO mapreduce.Job: Running job: job_1666320636626_0001
22/10/21 12:47:51 INFO mapreduce.Job: Job job_1666320636626_0001 running in uber mode : true
22/10/21 12:47:51 INFO mapreduce.Job:  map 0% reduce 0%
22/10/21 12:47:53 INFO mapreduce.Job:  map 100% reduce 0%
22/10/21 12:47:53 INFO mapreduce.Job: Job job_1666320636626_0001 completed successfully
22/10/21 12:47:53 INFO mapreduce.Job: Counters: 32
	File System Counters
		FILE: Number of bytes read=0
		FILE: Number of bytes written=0
		FILE: Number of read operations=0
		FILE: Number of large read operations=0
		FILE: Number of write operations=0
		HDFS: Number of bytes read=100
		HDFS: Number of bytes written=133393
		HDFS: Number of read operations=131
		HDFS: Number of large read operations=0
		HDFS: Number of write operations=9
	Job Counters 
		Launched map tasks=1
		Other local map tasks=1
		Total time spent by all maps in occupied slots (ms)=1678
		Total time spent by all reduces in occupied slots (ms)=0
		TOTAL_LAUNCHED_UBERTASKS=1
		NUM_UBER_SUBMAPS=1
		Total time spent by all map tasks (ms)=1678
		Total vcore-seconds taken by all map tasks=1678
		Total megabyte-seconds taken by all map tasks=1718272
	Map-Reduce Framework
		Map input records=5
		Map output records=5
		Input split bytes=87
		Spilled Records=0
		Failed Shuffles=0
		Merged Map outputs=0
		GC time elapsed (ms)=31
		CPU time spent (ms)=520
		Physical memory (bytes) snapshot=172040192
		Virtual memory (bytes) snapshot=3014025216
		Total committed heap usage (bytes)=60882944
	File Input Format Counters 
		Bytes Read=0
	File Output Format Counters 
		Bytes Written=151
22/10/21 12:47:53 INFO mapreduce.ImportJobBase: Transferred 130.2666 KB in 19.0367 seconds (6.8429 KB/sec)
22/10/21 12:47:53 INFO mapreduce.ImportJobBase: Retrieved 5 records.

 可以到hdfs的web页面查看

 

 这里的_SUCCESS是MR运行成功标志

part-m-0000就是只运行了m操作没有r操作

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Sqoop全量导入mysql表数据到HDFS 的相关文章

随机推荐

  • TCP发送数据、接受数据及TCP通信程序练习

    目录 一 TCP发送数据 二 TCP接收数据 三 TCP通信程序练习 一 TCP发送数据 Java中的TCP通信 xff1a Java对于基于TCP协议的网络提供了良好的封装 xff0c 使用Socket对象来代表两端的通信端口 xff0c
  • slam学习笔记

    ubuntu20 04 使用vs code编写 现放cmake文件 xff08 记得链接库文件和配置C 43 43 版本 xff09 cmake minimum required VERSION 2 8 project learingMat
  • SLAM学习笔记

    编译环境ubuntu20 04 vs code xff08 李群 李代数 xff09 先是CMakeLists txt cmake minimum required VERSION 3 0 project learning sophus s
  • SLAM学习笔记

    编译环境ubuntu20 04 xff0c vs code 先cmake文件 cmake minimum required VERSION 2 8 project image set CMAKE BUILD TYPE 34 Release
  • SLAM学习笔记

    编译环境ubuntu20 04 vscode ceres库2 0 0 g2o库同gaoxiang12 slambook2中的版本号一致 cmake文件 cmake minimum required VERSION 2 8 project c
  • 数据结构之C语言单链表操作

    实验目的 xff1a 1 xff0e 创建一个带头结点的单链表 2 xff0e 插入元素操作 xff1a 将新元素x插入到单链表head的头部 将新元素x插入到单链表head的尾部 将新元素x插入到单链表head中第i个元素之后 3 xff
  • DBUS入门与C编程

    https blog csdn net weixin 45566765 article details 125028296 一 D Bus简介 1 D Bus是什么 D Bus最主要的用途是在 Linux 桌面环境为进程提供通信 xff0c
  • 模拟IIC——关于模拟IIC的IO口的配置选取推挽输出还是开漏输出,以及是否需要更改IO口输入输出模式和是否需要对IO配置上拉

    在使用模拟IIC的时候 xff0c 观看别人的程序的时候发现了程序之间的一些不一样的地方 代码1 IO方向设置 define SDA IN GPIOB gt MODER amp 61 3 lt lt 9 2 GPIOB gt MODER 6
  • C语言——链表

    C语言 链表 链表是一种基础的数据结构类型 xff0c 一种能够动态维护数据的线性数据表 链表的数据以结点形式存储信息 xff0c 并通过结点之间的指针实现结点之间的衔接 为什么要用链表 xff1f 链表和数组类似 xff0c 但是功能比数
  • 学习记录 | ZigBee协议栈工作流程

    第一次来CSDN记录一下学习过程 xff0c 其实就是笔记啦 之前用Typora 的 但前几天电脑出问题重装系统后打开笔记文件发现照片都打不开了 xff0c 索性想换一种记笔记方式 好啦 以下是正文 xff01 xff01 xff01 对了
  • 学习记录 | ZigBee协议栈实践——串口收发数据

    上次的理论知识学的有点杂乱 今天来跟着例程实践看一看 目录 一 ZigBee协议栈的安装 编译和下载 二 协议栈工作流程 三 串口通信主要代码 1 串口打印 2 串口打印收到的数据 四 实现 五 总结 一 ZigBee协议栈的安装 编译和下
  • 第一次画异形板后的总结感悟

    目录 画原理图前的准备 画PCB的一些好方法 蜂鸣器电路 供电电路 其他电路 杂七杂八的随记要点 总结 像这样的异形板是通过solidworks扫描实物生成的 画原理图前的准备 当然是选购元器件 一般习惯在嘉立创进行选购 选择符合要求 有库
  • 自学物联网ESP第一天

    先简单的使用串口通信AT指令 刚开始不知道用什么开发好 在博客找了很久本来打算用 eclipse 不过突然发现可以用Arduino 不过下载真的好慢 于是开始看一下函数准备一下 一 基本函数 1 setup 函数 Arduino控制器通电或
  • stm32串口发送+接收

    本文章转自B站江科大自化协 一发送 接线图 目标结构 Serial c include 34 stm32f10x h 34 include lt stdio h gt 1移植printf函数 封装sprintf include lt std
  • vscode配置C/C++环境(超详细保姆级教学)

    大一上学期被学长安利了vscode xff0c 但是下载安装后不会配置 xff0c 自己连查带问搞了七八个小时终于配置好了 后面身边很多同学也不会配 xff0c 都来找我帮忙配 xff0c 加上之前自己摸索着配的时候感觉网上没有详细又靠谱的
  • 路由器接口解析

    ensp 接口解析 路由器的CON和AUX con是串口 xff0c 接口电脑串口可以进路由器的命令行查看和设置 一般为设备的控制端口 xff0c Console端口使用配置专用连线直接连接至计算机的串口 xff0c 利用终端仿真程序进行路
  • 解决VSCode写html文件时<!+Enter导入模板快捷键没办法使用的问题

    好久没有写前端了 xff0c 先是用模板快捷键 lt 43 Enter导入模板 xff0c 发现没有办法使用 找到网上一些资料 xff0c VSCode使用 html 5 取代了之前的生成模板快捷键 示例 xff1a 在空白html文本里逐
  • LVGL 之 windows 上 lvgl 模拟器 基于 Visual Studio 搭建方法的简单整理

    mark GUI Guider与lvgl联合仿真 xff08 结合stm32实验进行演示 xff0c 含触摸屏实验计数器与计算器 xff09 https blog csdn net gudao07 article details 12752
  • 初认识stm32 ————每日小总结(串口通信初始化基础操作)

    留下代码 xff0c 日后复习 c文件 include 34 my uart h 34 void my uart init NVIC PriorityGroupConfig NVIC PriorityGroup 2 设置中断优先级分组 RC
  • Sqoop全量导入mysql表数据到HDFS

    我是在三个节点运行的 xff0c 主节点只有namenode和mysql数据库 1 开启服务 具有NameNode和DataNode start all sh 2 进入sqoop的目录下并且输入代码 下面的命令用于从 MySQL 数据库服务