Hive
主要介绍Hive数据库的使用方式
Drgom
多做事,少说话
展开
-
hive的Caused by: org.apache.hadoop.hdfs.BlockMissingException: Could not obtain block: BP-572947236
早上起来去跑个hive的sql,稍微复杂点sql,就会报错如 Caused by: org.apache.hadoop.hdfs.BlockMissingException: Could not obtain block: BP-572947236 等,经过一个一个小时的排查,我觉得可能是我虚拟机的配置不行,刚好有一台华为鲲鹏的学生机,把配置导进去,sql跑起来丝滑的不行,好吧,是我不配,心累。...原创 2021-10-29 14:28:48 · 727 阅读 · 0 评论 -
Hive提取小时内,分组排名前3的sql
表的结构是这样的,时间的范围我是提取了几个小时内的数据create table `alibaba.user_bea` (user_id bigint, item_id bigint, cate_id bigint, times string, bea int )PARTITIONED BY (dt STRING)ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' STORED AS orc;提原创 2021-10-29 14:01:23 · 561 阅读 · 0 评论 -
Hive的schematool: command not found
切换到bin目录下,让schematool拥有可执行权限chmod 777 schematool原创 2021-10-29 09:45:12 · 2276 阅读 · 0 评论 -
Hive的分区和分桶
为了避免全表扫描,优化查询性能,我们可以使用分区和分桶表将数据细化,分桶表是分区表的进阶阶段,分桶表是使用表的字段进行进一步细分数据,分区则是指定外部的字段来分区分区表create table `alibaba.orders` ( order_id bigint, user_id bigint, item_id bigint, times string, name string, address string, phone string, key原创 2021-10-25 17:09:41 · 129 阅读 · 0 评论 -
Hive数据持久化到Mysql
首先确保安装了mysql并启动正常,由于我的Hive安装目录在/export/servers/hive-1.2.1使用hive之前需要将mysql连接所需的jar包放到hive路径下的lib文件夹中#启动并进入mysql执行如下命令update user set host='%' where host='localhost';flush privileges;进入hive的conf目录创建 hive-site.xml<?xml version="1.0"?><?xml-s原创 2020-08-20 15:56:36 · 305 阅读 · 0 评论 -
hive的升降序语句
这是我的数据集#降序排列select *from emp order by desc;#升序排列select *from emp order by asc;#设置Map阶段排序set mapreduce.job.reduces=3;原创 2020-08-21 21:21:53 · 1803 阅读 · 1 评论 -
hive的导入,导出数据几个方式
#从本地文件导入load data local inpath '路径' into table x#从hdfs导入文件load data inpath '路径' into table x#从hive将文件导入hdfs中dfs -put 本地路径 hdfs路径#重写覆盖之前的数据load data inpath '路径' overwrite into table x...原创 2020-08-20 21:38:39 · 128 阅读 · 0 评论 -
Linux下的hive的安装
#我采用的是hive1.2.1的版本先检查hadoop和java的环境是否配置好#该命令查看java的安装目录echo $JAVA_HOME#查看hadoop的安装目录echo $HADOOP_HOME具体的配置如下若没有安装hadoop的可参考这篇文章https://blog.csdn.net/id__39/article/details/104647642将hive的压缩包上传到虚拟机上并解压到 /export/servers/的目录下在/etc/profile 中添加HIV原创 2020-08-20 15:35:37 · 137 阅读 · 0 评论 -
hive删除表和数据,以及删除库
#hive删除表和数据ALTER TABLE table_name SET TBLPROPERTIES('EXTERNAL'='False'); drop table xxx;#删除表分区alter table table_name drop partition (partition_name='分区名')#只删除表不删除数据truncate table table_name #删除库前必须先删除库里面所有的数据drop database if exists...原创 2021-08-10 21:24:43 · 725 阅读 · 1 评论 -
pandas读取hive配置教程
之所以要使用pandas读取hive的数据,是在于pandas的数据处理能力很强,当然也可以使用sparksql处理,但如果要使用结果图表展示的话,建议还是使用pandas,当然如果上到集群的层面,sparksql是比较好的选择废话少说,上代码**@[toc] 1. 安装依赖`**pip install pyhivepip install thriftpip install saslpip install thrift_sasl如果你是就会发现sasl安装失败,如果你在windows平台原创 2021-08-03 00:03:28 · 1824 阅读 · 1 评论 -
hive的建表,及分区表和分桶表的基本操作
几条hive常用命令#查询数据库详细信息desc database extended db_hive;#强制删除数据库drop database db_hive cascade;#hive的数据导入create table test(name string,friends array<string>,children map<string, int>,address struct<street:string, city:string>)row f原创 2020-08-20 20:58:50 · 459 阅读 · 0 评论