sqoop的导入|Hive|Hbase
导入数据(集群为对象)
在Sqoop中“导入”概念指:从非大数据集群(RDBMS)向大数据集群(HDFS,HIVE,HBASE)中传输数据,叫做:导入,即使用import关键字。
1 RDBMS到HDFS
1) 确定Mysql服务开启正常
2) 在Mysql中新建一张表并插入一些数据
$ mysql -uroot -p000000
mysql> create database company;
mysql> create table company.staff(id int(4) primary key not null auto_increment, name varchar(255), sex varchar(255));
mysql> insert into company.staff(name, sex) values('Thomas', 'Male');
mysql> insert into company.staff(name, sex) values('Catalina', 'FeMale');
3) 导入数据
(1)全部导入
$ bin/sqoop import \ --connect jdbc:mysql://hadoop102:3306/company \ --username root \ --password 000000 \ --table staff \ --target-dir /user/company \ --delete-target-dir \ --num-mappers 1 \ --fields-terminated-by "\t"
(2)查询导入
$ bin/sqoop import \ --connect jdbc:mysql://hadoop102:3306/company \ --username root \ --password 000000 \ --target-dir /user/company \ --delete-target-dir \ --num-mappers 1 \ --fields-terminated-by "\t" \ --query 'select name,sex from staff where id <=1 and $CONDITIONS;'
提示:must contain '$CONDITIONS' in WHERE clause,传递参数使用,保证最后写入数据的一致性。
如果query后使用的是双引号,则$CONDITIONS前必须加转移符,防止shell识别为自己的变量。
(3)导入指定列
$ bin/sqoop import \ --connect jdbc:mysql://hadoop102:3306/company \ --username root \ --password 000000 \ --target-dir /user/company \ --delete-target-dir \ --num-mappers 1 \ --fields-terminated-by "\t" \ --columns id,sex \ --table staff
提示:columns中如果涉及到多列,用逗号分隔,分隔时不要添加空格
(4)使用sqoop关键字筛选查询导入数据
$ bin/sqoop import \ --connect jdbc:mysql://hadoop102:3306/company \ --username root \ --password 000000 \ --target-dir /user/company \ --delete-target-dir \ --num-mappers 1 \ --fields-terminated-by "\t" \ --table staff \ --where "id=1"
2 RDBMS到Hive
$ bin/sqoop import \ --connect jdbc:mysql://hadoop102:3306/company \ --username root \ --password 000000 \ --table staff \ --num-mappers 1 \ --hive-import \ --fields-terminated-by "\t" \ --hive-overwrite \ --hive-table staff_hive
提示:该过程分为两步,第一步将数据导入到HDFS,第二步将导入到HDFS的数据迁移到Hive仓库,第一步默认的临时目录是/user/你的用户名/表名
3 RDBMS到Hbase
$ bin/sqoop import \ --connect jdbc:mysql://hadoop102:3306/company \ --username root \ --password 000000 \ --table company \ --columns "id,name,sex" \ --column-family "info" \ --hbase-create-table \ --hbase-row-key "id" \ --hbase-table "hbase_company" \ --num-mappers 1 \ --split-by id
提示:sqoop1.4.6只支持HBase1.0.1之前的版本的自动创建HBase表的功能
解决方案:手动创建HBase表
hbase> create 'hbase_company,'info'
(5) 在HBase中scan这张表得到如下内容
hbase> scan ‘hbase_company’
sqoop的导入|Hive|Hbase的更多相关文章
- Sqoop_具体总结 使用Sqoop将HDFS/Hive/HBase与MySQL/Oracle中的数据相互导入、导出
一.使用Sqoop将MySQL中的数据导入到HDFS/Hive/HBase watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWFyb25oYWRvb3A=/ ...
- sqoop mysql导入hive 数值类型变成null的问题分析
问题描述:mysql通过sqoop导入到hive表中,发现有个别数据类型为int或tinyint的列导入后数据为null.设置各种行分隔符,列分隔符都没有效果. 问题分析:hive中单独将有问题的那几 ...
- Azure 云平台用 SQOOP 将 SQL server 2012 数据表导入 HIVE / HBASE
My name is Farooq and I am with HDinsight support team here at Microsoft. In this blog I will try to ...
- sqoop 数据导入hive
一. sqoop: mysql->hive sqoop import -m 1 --hive-import --connect "jdbc:mysql://127.0.0.1:3306 ...
- sqoop数据导入到Hdfs 或者hive
用java代码调用shell脚本执行sqoop将hive表中数据导出到mysql http://www.cnblogs.com/xuyou551/p/7999773.html 用sqoop将mysql ...
- Mysql 上亿级数据导入Hive思路分享
前提条件: 数据库容量上亿级别,索引只有id,没有创建时间索引 达到目标: 把阿里云RDS Mysql表数据同步到hive中,按照mysql表数据的创建时间日期格式分区,每天一个分区方便查询 每天运行 ...
- sqoop1.4.6从mysql导入hdfs\hive\hbase实例
//验证sqoop是否连接到mysql数据库sqoop list-tables --connect 'jdbc:mysql://n1/guizhou_test?useUnicode=true& ...
- Sqoop使用,mysql,hbase,hive等相互转换
Sqoop 是一款用来在不同数据存储软件之间进行数据传输的开源软件,它支持多种类型的数据储存软件. 安装 Sqoop 1.下载sqoop并加mysql驱动包 http://mirror.bit.edu ...
- Hive/hbase/sqoop的基本使用教程~
Hive/hbase/sqoop的基本使用教程~ ###Hbase基本命令start-hbase.sh #启动hbasehbase shell #进入hbase编辑命令 list ...
随机推荐
- CSIC_716_20191225【HTML基础入门】
HTTP协议 超文本传输协议HyperText Transfer Protocol 四大特性: 1.一次请求一次响应 2.基于TCP/IP协议,作用于应用层 3.无状态 4.无连接 数据格式: 1.请 ...
- es的日期格式
https://www.elastic.co/guide/en/elasticsearch/reference/2.3/mapping-date-format.html 在es中,默认的时间类型为da ...
- 64. 输出字节流(FileOutputStream)
IO分类: 按照数据流向分类: 输入流 输出流 按照处理的单位划分: 字节流:字节流读取的都是文件中的二进制数据,读取到的 ...
- leetcode-162周赛-1253-重构二进制矩阵
题目描述: 自己的提交: class Solution: def reconstructMatrix(self, upper: int, lower: int, colsum: List[int]) ...
- Delphi 打印纸张选项设置参数
{ paper selections } {$EXTERNALSYM DMPAPER_LETTER} DMPAPER_LETTER = 1; { Letter 8 12 x 11 in } {$EXT ...
- Delphi 消息函数 SendMessage函数
Delphi中SendMessage使用说明 SendMessage基础知识 函数功能:该函数将指定的消息发送到一个或多个窗口.此函数为指定的窗口调用窗口程序,直到窗口程序处理完消息再返回.而函数Po ...
- Dart编程实例 算术操作符
Dart编程实例 算术操作符 void main() { var num1 = 101; var num2 = 2; var res = 0; res = num1+num2; print(" ...
- 管理员技术(四): 配置NTP网络时间客户端、 创建一个备份包、 配置用户和组账号、配置一个cron任务
一. 配置NTP网络时间客户端 目标: 本例要求配置虚拟机 server0,能够自动校对系统时间.相关信息如下: 1> NTP服务器位于 classroom.example.com ...
- 炼数成金数据分析课程---14、Logistic回归
炼数成金数据分析课程---14.Logistic回归 一.总结 一句话总结: 大纲+实例快速学习法 主要讲Logistic回归的原理及编程实现 1.事件的优势比(odds)是什么? 记y取1的概率是p ...
- This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its de 错误解决
这是我们开启了bin-log, 我们就必须指定我们的函数是否是1 DETERMINISTIC 不确定的2 NO SQL 没有SQl语句,当然也不会修改数据3 READS SQL DATA 只是读取数据 ...