hive1.2.2+hadoop2.7.3导入米骑测试日志以及数据优化(五)
来源:互联网 发布:mac 虚拟机 win10 好吗 编辑:程序博客网 时间:2024/06/05 02:08
Hive是hadoop连接数据库的一个组件.是一个数据仓库,提供了Hadoop类sql 的增,删,改,查.
hive的表一般跟hdfs路径下的文件对应.hive 的常用命令如下:
启动:
./bin/hive shell
查看所有表:
show tables;
创建表:
create t_1(a int, b int, c int) row format delimited fields terminated by '\t';
修改表:
alter table t_1 add columns(d String);
导入数据:
load data local inpath '/testdata/words.txt' overwrite into table t_1;
导入hdfs中的文件:
load data inpath 'hdfs://master:9000/testdata/words.txt' overwrite into table t_1;
等等...
下面将米骑测试服务器访问日志统计出来的kpi等数据导入进hive的表中.
(1)统计米骑访问日志kpi程序下载链接:
http://download.csdn.net/detail/cafebar123/9889939
(2)创建hive表
先创建2个表,分别代表访问ip次数表:t_ip,访问的上一个跳转链接次数, t_remote_user
然后导入hadoop统计生成的数据,
load data inpath 'hdfs://master:9000/user/hadoop/ipCountOutput/part-r-00000' overwrite into table t_ip;
如图:
此时,t_ip实际上与ti_ip文件夹互相对应.t_remote_user的处理类似与以上.
(3)表的优化
1)下面试着分区表,并试着把米骑测试服务器的日志全部导入进表中.
重新创建一个表,并添加一个partition:
create table t_log(ip String,remote_user String,block1 String,local_time String,time_field String,tie_zone String,request_type String,request String,req_status String,resp_status int,body_bytes_sent Sttp_referer String,user_agent String,req_language String) partitioned by(req_month String) row formaited fields terminated by ' ';
共有13个字段,req_month为partition.
导入日志数据:
load data inpath 'hdfs://master:9000/user/hadoop/miqiLog10000Input/miqizuche10000.log' overwrite int table t_log partition(req_month=0709);
效果:
错误:
ValidationFailureSemanticException table is not partitioned but partition spec exists
这是没有该分区列导致的.如果在创建表时,没有创建与分区名一样的分区列,新增分区时,就会报这bug.
阅读全文
0 0
- hive1.2.2+hadoop2.7.3导入米骑测试日志以及数据优化(五)
- maven3.5+hadoop2.7.3统计米骑测试日志KPI指标(一)
- maven3.5+hadoop2.7.3统计米骑测试日志KPI指标(二)
- maven3.5+hadoop2.7.3统计米骑测试日志KPI指标(三)
- maven3.5+hadoop2.7.3统计米骑测试日志KPI指标(四)
- CentOS6.9+Hadoop2.7.3+Hive1.2.1+Hbase1.3.1+Spark2.1.1
- hive1.2.1源码导入eclipse阅读以及调试
- hadoop2.6 和hive1.2
- Sqoop-1.4.6安装配置及Mysql->HDFS->Hive数据导入(基于Hadoop2.7.3)
- Hadoop2.7.3 mapreduce(五)详解
- apache sqoop1.99.3+hadoop2.5.2+mysql5.0.7环境构筑以及数据导入导出
- hadoop2.7.3完全分布式安装-docker-hive1.2.1-hiveserver2-weave1.9.3
- Hadoop2.6.4、zookeeper3.4.6、HBase1.2.2、Hive1.2.1、sqoop1.99.7、spark1.6.2安装
- Hive1.1.0+Hadoop2.6.0启动异常
- ubuntu14.04+hadoop2.6.2+hive1.1.1
- hive安装 (hive1.2.1+hadoop2.7+mysql)
- Hadoop2.6.4分布式下安装 hive1.2.1
- hive1.2.1源码导入eclipse
- Java通用工具类方法
- BeanUtils介绍及其使用
- 数字化时代CIO的历史使命与关键任务
- 程序猿需要养成的良好编码习惯
- 起底“心灵法门”:手握300万信徒 靠法会每年敛财数亿
- hive1.2.2+hadoop2.7.3导入米骑测试日志以及数据优化(五)
- js实现禁止浏览器后退
- FFMPEG学习【libavutil】:Crypto and Hashing(四)
- 基于Qt的时钟跟抽奖界面 图片不停转换的哪种
- 服务认证暴力破解工具Crowbar
- 倾斜摄影数据转cesium 3D tiles工具介绍
- linux的简单命令学习
- ajaxSubmit的使用
- .h头文件、 .lib库文件、 .dll动态链接库文件之间的关系