当前位置: 首页 > news >正文

诸城网站建设定制app网页制作软件

诸城网站建设定制,app网页制作软件,做网站能挣多少钱,哈尔滨市信息网1. 问题 如果是采用hdfs上传加载的表、或者是flume直接写hdfs的表空间通常看hive的属性是不准确的。 2. 思路 为了使结果更精确#xff0c;我们直接使用linux下命令统计hive仓库目录下的每个表对应的文件夹目录占用空间的大小。 3. 解决方法 这里建立三层表结构 ods: 原始…1. 问题 如果是采用hdfs上传加载的表、或者是flume直接写hdfs的表空间通常看hive的属性是不准确的。 2. 思路 为了使结果更精确我们直接使用linux下命令统计hive仓库目录下的每个表对应的文件夹目录占用空间的大小。 3. 解决方法 这里建立三层表结构 ods: 原始数据采集 ods.ods_hive_tablelist ods.ods_hive_tablespace dw清洗整合 dw.dw_hive_metadata mdl: 统计 mdl.mdl_hive_metadata_stat 3.1 ODS层数据采集 在ods层建立文件路径列表和每个路径占用空间大小。 create table ods.ods_hive_tablelist( path string comment 表路径, update_time string comment 更新时间 ) comment hive表更新时间 partitioned by (pk_day string) row format delimited fields terminated by , lines terminated by \n stored as textfile;create table ods.ods_hive_tablespace( path string comment 表路径, size string comment 表占用大小(byte), blocksize string comment 副本占用大小(byte) ) comment hive表空间占用统计 partitioned by (pk_day string) row format delimited fields terminated by , lines terminated by \n stored as textfile;这里的数据采集使用shell命令格式我是使用pySpark里面直接执行的。 tableList os.popen(hdfs dfs -ls /user/hive/warehouse/*.db |awk {print $8,$6 $7}) tablespaceList os.popen(hadoop fs -du /user/hive/warehouse/*.db|awk {print $3,$1,$2})new_tableList [] for table in tableList:arr table.replace(\n,).split(,)new_tableList.append((arr[0],arr[1]))new_tablespaceList [] for tablespace in tablespaceList:arr tablespace.replace(\n,).split(,)new_tablespaceList.append((arr[0],arr[1],arr[2]))#----ods---- current_dt date.today().strftime(%Y-%m-%d) print(current_dt) spark.createDataFrame(new_tableList,[path,update_time]).registerTempTable(tablelist) spark.createDataFrame(new_tablespaceList,[path,size,blocksize]).registerTempTable(tablespacelist) tablelistdf spark.sql((select path,update_time,current_date() as pk_day from tablelist where path ! ) ) tablelistdf.show(10)tablelistdf.repartition(2).write.insertInto(ods.ods_hive_tablelist,True)tablespacelistdf spark.sql((select path,size,blocksize,current_date() as pk_day from tablespacelist where path ! )) tablespacelistdf.show(10) tablespacelistdf.repartition(2).write.insertInto(ods.ods_hive_tablespace,True)经过简单的清洗后落表。 ods.ods_hive_tablelist表的显示如下 在ods.ods_hive_tablespace中显示的如下 3.2 清洗整合入仓 接下来在dw层进行整合对应的表结构如下 create table dw.dw_hive_metadata( dbname string comment 数据库名, tblname string comment 表名, path string comment 表路径, update_date string comment 更新日期, update_time string comment 更新时间, mb double comment 表占用大小(MB), gb double comment 表占用大小(GB), size double comment 表占用大小(byte), blocksize double comment 副本占用大小(byte), blocksize_gb double comment 副本占用大小(gb) ) comment hive表元数据统计 partitioned by (pk_day string) stored as textfile;这里整合ods层的两张表关联就可以拼接出每个表占用的空间大小 #----dw---- dwdf spark.sql(( selectsplit(a.path,/)[4] as dbname,split(a.path,/)[5] as tblname,a.path,substr(a.update_time,1,10) as update_date,a.update_time,nvl(round(b.size/1000/1000,2),0) as mb,nvl(round(b.size/1000/1000/1000,2),0) as gb,nvl(round(b.size,2),0) as size,nvl(round(b.blockSize,2),0) as blocksize,nvl(round(b.blockSize/1000/1000/1000,2),0) as blocksize_gb,a.pk_day from(select * from ods.ods_hive_tablelist where pk_day current_date()) aleft join(select * from ods.ods_hive_tablespace where pk_day current_date()) b on a.path b.path and a.pk_day b.pk_day where a.path is not null and a.path ! ))我们可以看到这个明细数据展示如下 3.3 统计分析 这里可以根据需要自己增加统计逻辑我这里按照db层级统计每天的增量大小。 统计层表结构如下 create table mdl.mdl_hive_metadata_stat( dbname string comment 数据库名, tblcount int comment 表个数, dbspace double comment 数据库空间(GB), dbspace_incr double comment 数据库空间日增量(GB), blockspace_incr double comment 服务器空间日增量(GB) ) comment hive元数据db统计 partitioned by (pk_day string) stored as textfile;实现方式 #----mdl---- spark.sql((select pk_day,dbname,count(tblname) as tblCount,round(sum(gb),2) as dbspace,round(sum(blocksize_gb),2) as blockSpacefrom dw.dw_hive_metadatawhere pk_day date_sub(current_date(),7)group by pk_day,dbname)).createTempView(tmp_a)spark.sql((selectpk_day,dbname,tblCount,dbspace,blockSpace,lag(dbspace,1,0) over(partition by dbname order by pk_day) as lagSpace,lag(blockSpace,1,0) over(partition by dbname order by pk_day) as lagBlockSpacefrom tmp_a )).createTempView(tmp_b)mdldf spark.sql(( select dbname,tblCount,dbspace, round((dbspace-lagSpace),2) as dbspace_incr, round((blockSpace-lagBlockSpace),2) as blockspace_incr, pk_day from tmp_b where pk_day current_date() )) mdldf.show(10) mdldf.repartition(1).write.insertInto(mdl.mdl_hive_metadata_stat,True)最后看看统计层的内容如下
http://www.hkea.cn/news/14373962/

相关文章:

  • 做网站看百度脸色银河互联网电视有限公司
  • 帮助做ppt的网站python做视频网站
  • 用织梦做的网站怎么管理系统自动成交型网站建设
  • 企业网站建设需要多少钱做网站前台用什么软件
  • 微网站怎么做的4p营销策略分析
  • 音乐网站模板免费源码网站中页面链接怎么做
  • WordPress阿里云安装做网站优化好的网络公司
  • 怎么做公司网站推广科技公司网站建设
  • 河南郑州做网站减肥推广
  • 照片网站模版wordpress 邮件发布
  • 网站设计建设网站网站的运行环境万网
  • 免费网站友情链接logo在线查询
  • 物流网站 源码怎么做网站网站吗
  • 高端网站设计官网html做企业门户网站
  • 连江建设局网站wordpress 点评插件
  • 厦门官方网站建设科技公司企业网站建设
  • 慈溪住房和城乡建设部网站常州市金坛区网站建设
  • 已备案网站注册网站申请了如何上传到服务器
  • 安庆什么网站好小事做平湖模板网站建设公司
  • 网站左侧树形导航怎么做网站开发的背景与环境
  • 扬州天猫网站建设微信网页版app
  • 中英文对照网站怎么做注册域名怎么建设网站
  • 深圳做网站三网合一做网站建设最好的公司是
  • php做电商网站怎样做seo搜索引擎优化
  • 响应式企业网站好的竞价推广托管
  • 网站的在线支付怎么做那个平台能免费做网站
  • 云主机添加网站xp asp 网站建设
  • 国内网站搭建南宁网站建设接单
  • 潍坊优化网站排名合肥集团网站建设公司
  • 中石化工建设宁波分公司网站字节跳动小程序开发者平台