设为首页 收藏本站
查看: 1223|回复: 0

[经验分享] hadoop的Hive实战操作sogou的日志

[复制链接]

尚未签到

发表于 2018-10-29 11:15:08 | 显示全部楼层 |阅读模式
  动手实战操作搜狗日志文件
  本节中所用到的内容是来自搜狗实验室,网址为:
  http://www.sogou.com/labs/dl/q.html
  用户可以根据自己的Spark机器实际的内存配置等情况选择下载不同的数据版本,为了让所有的学习者都可以成功操作日志,我们使用的是迷你版本的tar.gz格式的文件,其大小为384K,下载地址:http://www.sogou.com/labs/resource/q.php
  日志格式如下:
  单挑记录:
  00:00:002982199073774412[360安全卫士]8 3download.it.com.cn/softweb/software/firewall/antivirus/20067/17938.html
  该文件的格式如下所示:
  访问时间\t用户ID\t查询词\t该URL在返回结果中的排名\t用户点击的顺序号\t用户点击的URL
  在hive中创建表格:
  create table sogou(sTime string,userId string,Keyword string,Paiming int,Dianji int,URL string) row format delimited
  fields terminated by '\t' lines terminated by '\n' stored as textfile
  结果如下:
  hive> create table sogou(sTime string,userId string,Keyword string,Paiming int,Dianji int,URL string) row format delimited
  > fields terminated by '\t' lines terminated by '\n' stored as textfile;
  OK
  Time taken: 4.422 seconds
  导入数据:
  load data local inpath  '/home/dyq/Documents/SogouQ.sample' overwrite into table sogou;
  结果显示:
  hive> load data local inpath  '/home/dyq/Documents/SogouQ.sample' overwrite into table sogou;
  Loading data to table default.sogou
  OK
  Time taken: 3.567 seconds
  查看表的建立情况:
  hive> desc sogou;
  OK
  stime               string
  userid              string
  keyword             string
  paiming             int
  dianji              int
  url                 string
  Time taken: 2.515 seconds, Fetched: 6 row(s)
  查看数据导入情况:
  查看记录条数:
  select count(*) from sogou;
  可以看到查询过程很漫长,效率不高的说
  hive> select count(*) from sogou;

  WARNING: Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. tez, spark) or using Hive 1.X>
  Query>  Total jobs = 1
  Launching Job 1 out of 1
  Number of reduce tasks determined at compile time: 1
  In order to change the average load for a reducer (in bytes):
  set hive.exec.reducers.bytes.per.reducer=
  In order to limit the maximum number of reducers:
  set hive.exec.reducers.max=
  In order to set a constant number of reducers:
  set mapreduce.job.reduces=
  Starting Job = job_1472347049416_0004, Tracking URL = http://ubuntu:8088/proxy/application_1472347049416_0004/
  Kill Command = /opt/hadoop-2.6.2/bin/hadoop job  -kill job_1472347049416_0004
  Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 1
  2016-08-28 11:47:28,067 Stage-1 map = 0%,  reduce = 0%
  2016-08-28 11:48:09,628 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 8.1 sec
  2016-08-28 11:48:35,383 Stage-1 map = 100%,  reduce = 100%, Cumulative CPU 10.68 sec
  MapReduce Total cumulative CPU time: 10 seconds 680 msec
  Ended Job = job_1472347049416_0004
  MapReduce Jobs Launched:
  Stage-Stage-1: Map: 1  Reduce: 1   Cumulative CPU: 10.68 sec   HDFS Read: 906303 HDFS Write: 105 SUCCESS
  Total MapReduce CPU Time Spent: 10 seconds 680 msec
  OK
  10000
  Time taken: 109.492 seconds, Fetched: 1 row(s)
  导出数据到外部文件
  insert overwrite local directory '/home/dyq/Documents/SogouQdept' select a.Keyword,a.URL from sogou a;
  只导出2个字段,看看情况
  hive> insert overwrite local directory '/home/dyq/Documents/SogouQdept' select a.Keyword,a.URL from sogou a;

  WARNING: Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. tez, spark) or using Hive 1.X>
  Query>  Total jobs = 1
  Launching Job 1 out of 1
  Number of reduce tasks is set to 0 since there's no reduce operator
  Starting Job = job_1472347049416_0005, Tracking URL = http://ubuntu:8088/proxy/application_1472347049416_0005/
  Kill Command = /opt/hadoop-2.6.2/bin/hadoop job  -kill job_1472347049416_0005
  Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 0
  2016-08-28 11:51:54,594 Stage-1 map = 0%,  reduce = 0%
  2016-08-28 11:52:06,398 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 3.14 sec
  MapReduce Total cumulative CPU time: 3 seconds 140 msec
  Ended Job = job_1472347049416_0005
  Moving data to local directory /home/dyq/Documents/SogouQdept
  MapReduce Jobs Launched:
  Stage-Stage-1: Map: 1   Cumulative CPU: 3.14 sec   HDFS Read: 901894 HDFS Write: 178503 SUCCESS
  Total MapReduce CPU Time Spent: 3 seconds 140 msec
  OK
  Time taken: 28.859 seconds
  查看sogouQdept文件的内容:


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-627934-1-1.html 上篇帖子: hadoop的Hive操作hdfs文件第一天 下篇帖子: Hadoop的相关资料
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表