hdfs数据到hive中,以及hdfs数据隐身理解
hdfs数据到hive中:
假设hdfs中已存在好了数据,路径是hdfs:/localhost:9000/user/user_w/hive_g2park/user_center_enterprise_info/*
1.提前(在hive中)准备好表, user_center_enterprise_info2 ,用于接收hdfs数据。
CREATE TABLE user_center_enterprise_info2 (
`id`string ,
`name` string
);
2.使用load data方式,加载数据,(已执行数据库选择命令 hive>use testdb;)
以下 相对/绝对 两种路径加载都行
hive>load data inpath 'hive_g2park/user_center_enterprise_info/*' into table user_center_enterprise_info2; hive>load data inpath '/user/user_w/hive_g2park/user_center_enterprise_info/*' into table user_center_enterprise_info2;
此时:
hdfs dfs -ls /user/user_w/hive_g2park/user_center_enterprise_info 发现里面内容没了
3.把数据从hive写回hdfs,让数据出现在hdfs
数据是从hdfs的 hive_g2park/user_center_enterprise_info 写到hive的,
现在写道 hive_g2park/user_center_enterprise_info3 路径下
-- 设置task数 set mapred.reduce.tasks = ; 结果数据平均分区(分区数等于task数);
set mapred.reduce.tasks = ; insert overwrite directory 'hive_g2park/user_center_enterprise_info3'
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'='\t',
'serialization.format'= '',
'serialization.null.format'=''
) STORED AS TEXTFILE
select * from user;
此时在hdfs下生成了新路径,
hive_g2park/user_center_enterprise_info3
并且有数据在其文件夹下
我的理解数据消失:
hive本质是map-reduce,即操作hdfs数据的方式有:spark,mr,pig,hive。
而hive只是在mr上包了一层,hive操作的时候,本质上,是直接操作的hdfs数据,也就是说hdfs数据load后,和hive数据是同一份数据
而且load data inpath '/user/hive/os.txt' into table os;这种方式loca数据到hive辣么快,应该是修改了指针而已,而不是复制了一份数据到hive。
hdfs数据到hive就隐藏不见,这么设计,就是为了避免数据在被hive改动的同时,又被mr直接操作hdfs数据,删除移动什么的,造成数据的不一致,所以数据丢hive里hdfs里就看不见了
sqoop export --connect jdbc:mysql://127.0.0.1:3306/parkdb --username xiaoming --password '' --table t_vip_user --export-dir 'hive_g2park/vip/*' --fields-terminated-by "\t"
附录:
sqoop的导出参数中,hive-import作用:本次导入到hive中
导入看得到hdfs文件夹范例
sqoop import --connect jdbc:mysql://localhost:3306/user --username h --password '123' \
--fields-terminated-by "\t" --table enterprise_info --delete-target-dir --target-dir 'hive_g2park/user_center_enterprise_info' \
--create-hive-table --hive-table g2park.user_center_enterprise_info
导入看不到hdfs文件夹范例
sqoop import --connect jdbc:mysql://localhost:3306/user --username h --password '123'
--fields-terminated-by "\t" --table enterprise_info --delete-target-dir
--hive-import --target-dir 'hive_g2park/user_center_enterprise_info'
--create-hive-table --hive-table g2park.user_center_enterprise_info
hdfs数据到hive中,以及hdfs数据隐身理解的更多相关文章
- Hive中导入Oracle数据错误:Listener refused the connection with the following error: ORA-12505
问题: 今天往Hive中导入Oracle数据的时候碰到了如下错误:Listener refused the connection with the following error: ORA-12505 ...
- (转)原始图像数据和PDF中的图像数据
比较原始图像数据和PDF中的图像数据,结果见表1.1.表1.1中各种“解码器”的解释见本文后续的“PDF支持的图像格式”部分,“PDF中的图像数据”各栏中的数据来自开源的PdfView.如果您有兴趣查 ...
- 一个I/O线程可以并发处理N个客户端连接和读写操作 I/O复用模型 基于Buf操作NIO可以读取任意位置的数据 Channel中读取数据到Buffer中或将数据 Buffer 中写入到 Channel 事件驱动消息通知观察者模式
Tomcat那些事儿 https://mp.weixin.qq.com/s?__biz=MzI3MTEwODc5Ng==&mid=2650860016&idx=2&sn=549 ...
- 使用sqoop1.4.4从oracle导入数据到hive中错误记录及解决方案
在使用命令导数据过程中,出现如下错误 sqoop import --hive-import --connect jdbc:oracle:thin:@192.168.29.16:1521/testdb ...
- sqoop导oracle数据到hive中并动态分区
静态分区: 在hive中创建表可以使用hql脚本: test.hql USE TEST; CREATE TABLE page_view(viewTime INT, userid BIGINT, pag ...
- hive 之 将excel数据导入hive中 : excel 转 txt
一.需求: 1.客户每月上传固定格式的excel文件到指定目录.每月上传的文件名只有结尾月份不同,如: 10月文件名: zhongdiangedan202010.xlsx , 11月文件名: zh ...
- sqoop 从oracle导数据到hive中,date型数据时分秒截断问题
oracle数据库中Date类型倒入到hive中出现时分秒截断问题解决方案 1.问题描述: 用sqoop将oracle数据表倒入到hive中,oracle中Date型数据会出现时分秒截断问题,只保留了 ...
- sqoop1.4.4从oracle导数据到hive中
sqoop从oracle定时增量导入数据到hive 感谢: http://blog.sina.com.cn/s/blog_3fe961ae01019a4l.htmlhttp://f.dataguru. ...
- 在hive中查询导入数据表时FAILED: SemanticException [Error 10096]: Dynamic partition strict mode requires at least one static partition column. To turn this off set hive.exec.dynamic.partition.mode=nonstrict
当我们出现这种情况时 FAILED: SemanticException [Error 10096]: Dynamic partition strict mode requires at least ...
随机推荐
- 在Vue中的load或ready的加载时机
在Vue中的load或ready的加载时机 1.我们来插入一段代码来分析: Js代码如下 <script type="text/javascript"> var app ...
- linux批量替换文件内容3种方法(perl,sed,shell)
方法1:perl 这两天在构建一个应用的使用用到了maven,由于project很大,足足有700多个 pom.xml文件,更郁闷的是在很多pom.xml文件里都单独指定了资源库的url,我需要把 ...
- noi.ac 集合
A.集合 --- 题面 不知道有没有用的传送门[滑稽 就是给你一个 包含 1~n 的集合,让你求它的大小为 k 的子集 s 的 \(T^{min(s)}\) 的期望值, T 为给出值, min(s) ...
- $Django 发送邮件--django封装模块和python内置SMTP模块
一 使用SMTP模块发送邮件 import smtplib from email.mime.text import MIMEText from email.header import Header m ...
- Solidworks设计电路外形导入AltiumDesigner
将实际设计好的三维电路图的底板(单个零件模式下)轮廓另存为dwf或者dwg 这时候会出现一个选项框,需要进行一些设置 单位选择mm,这个按照自己的需求选择单位 单位映射选择为1mm,也就是1:1的比例 ...
- Mysql按条件计数的几种方法
最近在给某网站的后台添加一系列的统计功能,遇到很多需要按条件计数的情况.尝试了几种方法,下面简要记录,供大家参考. 问题描述 为使讨论简单易懂,我将问题稍作简化,去掉诸多的背景. 从前有一个皇帝,他有 ...
- 一种简单的生产环境部署Node.js程序方法
最近在部署Node.js程序时,写了段简单的脚本,发觉还挺简单的,忍不住想与大家分享. 配置文件 首先,本地测试环境和生产环境的数据库连接这些配置信息是不一样的,需要将其分开为两个文件存储 到conf ...
- python序列(列表,元组,字典)的常用排序
列表 正向排序 sort() >>> list=[1,6,3,4,5,2] >>> list.sort() >>> list [1, 2, 3, ...
- 【原创】大叔经验分享(41)hdfs开启kerberos之后报错Encryption type AES256 CTS mode with HMAC SHA1-96 is not supported/enabled
hdfs开启kerberos之后,namenode报错,连不上journalnode 2019-03-15 18:54:46,504 WARN org.apache.hadoop.security.U ...
- MySQL按字段排序后取序号
1 前言 项目中排行榜刚好需要查数据库表然后给出编号,方案一,可以按条件查找出来,然后再按数组序号给编号,但是如果要查表出来直接看,就不太够用了:方案二,就是用代码帮忙编号.参考了网上一些代码,然后发 ...