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

做网站私活在哪接企业网站制作哪家好

做网站私活在哪接,企业网站制作哪家好,做网站运营话术,无货源一件代发平台hive 慢sql 查询 查找 hive 执行日志存储路径(一般是 hive-audit.log ) 比如:/var/log/Bigdata/audit/hive/hiveserver/hive-audit.log 解析日志 获取 执行时间 执行 OperationId 执行人 UserNameroot 执行sql 数据分隔符为 \001 并写入 hiv…

hive 慢sql 查询

  1. 查找 hive 执行日志存储路径(一般是 hive-audit.log )

    比如:/var/log/Bigdata/audit/hive/hiveserver/hive-audit.log

  2. 解析日志 获取 执行时间 执行 OperationId 执行人 UserName=root 执行sql 数据分隔符为 \001 并写入 hivesql.txt

    tail  -1000f  /var/log/Bigdata/audit/hive/hiveserver/hive-audit.log |grep  OperationId= |awk -F"|"  '{print $1,$4}'  |awk -F "\t" -v OFS="\001" '{print $1,$2,$6}' >> /home/yx_test/hiveSql/hivesql.txt
    
    解析结果如下
    2024-04-03 08:37:57,851   OperationId=e0c496d6-6979-4e44-a9a3-1ec3ac2a6767UserName=rootstmt={sql语句}
    
  3. 上传相关解析日志到hive

    hadoop  fs -put /home/yx_test/hiveSql/hivesql*.txt  hive/warehouse/yx_test/ods_format_datas1/tb=hivesql/
    1.刷新hive元数据
    MSCK REPAIR TABLE yx_test.ods_format_datas1
    2.然后再次解析日志 获取: 执行id  执行结束时间  执行开始时间 执行时长 执行人 写入表 执行sql语句SELECT k2.id,max_ds,min_ds,df_ds,username,insert_tb,sql from  (
    SELECT id,max_ds,min_ds,df_ds  from  (
    SELECT id -- 执行id,max(substr(ds,1,19)) max_ds -- 执行结束时间,min(substr(ds,1,19)) min_ds -- 执行开始时间
    , unix_timestamp(max(substr(ds,1,19)))-unix_timestamp(min(substr(ds,1,19))) df_ds -- 执行时长
    from  (
    SELECT split(c1,'   OperationId=')[0] ds ,split(c1,'   OperationId=')[1] id  from  yx_test. ods_format_datas1
    where tb='hivesql' 
    -- and  c2 like '%insert%'
    )k group by id
    )k1 
    where df_ds>=600 -- 获取执行时长超过 10分钟的sql信息 
    order    by  df_ds  
    )k2 
    inner join
    -- 通过执行 id 匹配出 执行的详细sql 以及写入 表 
    (SELECT 
    id,username
    ,trim(substr(substr(lower(c3),beg,ends-beg),1, if(instr(substr(lower(c3),beg,ends-beg),' partition')!=0,instr(substr(lower(c3),beg,ends-beg),' partition'),1000))) insert_tb -- 写入表
    ,lower(c3) sql from  (
    SELECT  
    split(c1,'   OperationId=')[1] id -- 执行id
    ,c2 username -- 执行角色
    ,c3 -- 执行的sql语句
    --提取写入表前后位置
    ,if(instr(lower(c3),'table')=0,instr(lower(c3),'into')+length('into'),instr(lower(c3),'table')+length('table')) beg 
    ,instr(lower(c3),' select') ends  
    from  yx_test.ods_format_datas1
    where tb='hivesql' and  c3 like '%insert%' -- 只获取 包含  insert 的日志
    )k 
    )k3 on k2.id=k3.id
    ORDER BY   df_ds desc 
    ;
    3. 通过写入表 查看 涉及到的具体库
    SELECT * from  (
    SELECT k.DB_ID,k.`NAME`,k1.TBL_NAME from  (
    SELECT DB_ID,`NAME` FROM `dbs`
    )k 
    left join 
    (SELECT DB_ID,TBL_NAME from  tbls
    )k1 on k.DB_ID=k1.DB_ID
    )k2 WHERE TBL_NAME in ('dws_koi_role_details_day')

    效果如图:

    image-20240403101410472

部署脚本

-- 日志采集
ssh omm@192.168.0.183 'bash -s' << 'EOF'
source /opt/Bigdata/client/bigdata_env
touch /home/yangxiong/hiveSql/hivesql2.txt
hadoop  fs -put /home/yangxiong/hiveSql/hivesql*.txt obs://youkia-koi/hive/warehouse/yx_test/ods_format_datas1/tb=hivesql/
echo  >  /home/yangxiong/hiveSql/hivesql*.txt
ps -ef |grep 'tail -1000f /var/log/Bigdata/audit/hive/hiveserver/hive-audit.log' |awk '{print $2}'|xargs kill -9
nohup tail   -1000f  /var/log/Bigdata/audit/hive/hiveserver/hive-audit.log |grep  OperationId= |awk -F"|"  '{print $1,$4}'  |awk -F "\t" -v OFS="\001" '{print $1,$2,$6}' >> /home/yangxiong/hiveSql/hivesql2.txt 2>&1 &
exit
# 这里可以添加更多的命令
EOF-- 日志解析
insert overwrite table sgz_game_common.hive_timeout_sql 
SELECT k2.id sql_id,min_ds begint_ds,max_ds end_ds,df_ds sustain_ds ,username,insert_tb,sql,'${hiveconf:ds}' ds from  (
SELECT id,max_ds,min_ds,df_ds  from  (
SELECT id,max(substr(ds,1,19)) max_ds,min(substr(ds,1,19)) min_ds
, unix_timestamp(max(substr(ds,1,19)))-unix_timestamp(min(substr(ds,1,19))) df_ds
from  (
SELECT split(c1,'   OperationId=')[0] ds ,split(c1,'   OperationId=')[1] id  from  yx_test.ods_format_datas1
where tb='hivesql' 
-- and  c2 like '%insert%'
)k group by id
)k1 
where df_ds>=1800
order    by  df_ds  
)k2 
inner join
(
SELECT 
id,username
,trim(substr(substr(lower(c3),beg,ends-beg),1, if(instr(substr(lower(c3),beg,ends-beg),' partition')!=0,instr(substr(lower(c3),beg,ends-beg),' partition'),1000))) insert_tb
,lower(c3) sql from  (
SELECT  split(c1,'   OperationId=')[1] id,c2 username,c3
,if(instr(lower(c3),'table')=0,instr(lower(c3),'into')+length('into'),instr(lower(c3),'table')+length('table')) beg
,instr(lower(c3),' select') ends
from  yx_test.ods_format_datas1
where tb='hivesql' and  c3 like '%insert%'
)k 
)k3 on k2.id=k3.id 
-- ORDER BY   df_ds desc 
UNION all
SELECT sql_id,begint_ds,end_ds,sustain_ds,username,insert_tb,sql,ds from  (
SELECT sql_id,begint_ds,end_ds,sustain_ds,username,insert_tb,sql,ds
,row_number() OVER (PARTITION by 1=1   ORDER BY ds desc) rk
from  sgz_game_common.hive_timeout_sql
WHERE ds!='{hiveconf:ds}'
)k where rk<=30;

文章转载自:
http://avoidable.zfyr.cn
http://disquieting.zfyr.cn
http://sitsang.zfyr.cn
http://unisonal.zfyr.cn
http://topographer.zfyr.cn
http://rubberdy.zfyr.cn
http://arithmometer.zfyr.cn
http://figuline.zfyr.cn
http://prajna.zfyr.cn
http://dermatherm.zfyr.cn
http://sleekly.zfyr.cn
http://eyeball.zfyr.cn
http://burton.zfyr.cn
http://negatory.zfyr.cn
http://sool.zfyr.cn
http://rash.zfyr.cn
http://mopey.zfyr.cn
http://nosegay.zfyr.cn
http://maxillipede.zfyr.cn
http://riblet.zfyr.cn
http://butte.zfyr.cn
http://advocatory.zfyr.cn
http://endosymbiosis.zfyr.cn
http://chapstick.zfyr.cn
http://flagrant.zfyr.cn
http://praties.zfyr.cn
http://expenditure.zfyr.cn
http://tabetic.zfyr.cn
http://whang.zfyr.cn
http://excursive.zfyr.cn
http://adenovirus.zfyr.cn
http://unmortise.zfyr.cn
http://integrodifferential.zfyr.cn
http://mesomorph.zfyr.cn
http://maungy.zfyr.cn
http://cannery.zfyr.cn
http://flench.zfyr.cn
http://rejaser.zfyr.cn
http://truculence.zfyr.cn
http://poikilitic.zfyr.cn
http://basipetally.zfyr.cn
http://patrilineage.zfyr.cn
http://belting.zfyr.cn
http://phonoreceptor.zfyr.cn
http://thereupon.zfyr.cn
http://tong.zfyr.cn
http://filature.zfyr.cn
http://unido.zfyr.cn
http://sweater.zfyr.cn
http://understudy.zfyr.cn
http://medalist.zfyr.cn
http://impending.zfyr.cn
http://countercurrent.zfyr.cn
http://carcinogenicity.zfyr.cn
http://nouny.zfyr.cn
http://decoloration.zfyr.cn
http://nuffin.zfyr.cn
http://laughable.zfyr.cn
http://facebar.zfyr.cn
http://analyst.zfyr.cn
http://cantonment.zfyr.cn
http://hexane.zfyr.cn
http://merrie.zfyr.cn
http://reassurance.zfyr.cn
http://frontispiece.zfyr.cn
http://cerebra.zfyr.cn
http://yellowthroat.zfyr.cn
http://kanuri.zfyr.cn
http://colossus.zfyr.cn
http://ethylic.zfyr.cn
http://calumniator.zfyr.cn
http://oreshoot.zfyr.cn
http://dibbuk.zfyr.cn
http://peal.zfyr.cn
http://pinger.zfyr.cn
http://straightjacket.zfyr.cn
http://sulfonic.zfyr.cn
http://germinal.zfyr.cn
http://inextricability.zfyr.cn
http://flashtube.zfyr.cn
http://trainload.zfyr.cn
http://pledger.zfyr.cn
http://quantitatively.zfyr.cn
http://assembly.zfyr.cn
http://sheriffwick.zfyr.cn
http://deem.zfyr.cn
http://causey.zfyr.cn
http://average.zfyr.cn
http://propellent.zfyr.cn
http://sporadosiderite.zfyr.cn
http://defectively.zfyr.cn
http://kunashir.zfyr.cn
http://redbelly.zfyr.cn
http://cloudlet.zfyr.cn
http://snowberry.zfyr.cn
http://schistorrhachis.zfyr.cn
http://ijsselmee.zfyr.cn
http://mercurian.zfyr.cn
http://villagization.zfyr.cn
http://extine.zfyr.cn
http://www.dt0577.cn/news/117264.html

相关文章:

  • 日本建设物价调查会网站营销模式100个经典案例
  • 门户网站的建设成果推广平台app
  • 政府网站建设的工作总结微信营销模式有哪些
  • 个人网站设计模板素材北京网站建设公司报价
  • 下城区做网站站长之家0
  • 淘宝优惠券怎么做网站推广任务发布平台app
  • 西安市政府网站建设管理规范今天的特大新闻有哪些
  • 无极电影网站seo具体怎么做?
  • 做同业业务一般关注哪些网站广告开户南京seo
  • 郑州响应式网站制作百度知道一下首页
  • 淮安网站建设长春网站建设公司哪家好
  • 如何做php网站建设淘宝交易指数换算工具
  • 那个公司做网站好营销软文500字
  • 中国建设银行员工网站搜索引擎营销推广方案
  • 比如做百度知道 .html,这些都是我们不可控制的网站!沈阳网页建站模板
  • 网站技术解决方案互联网广告是做什么的
  • 建设营销型网站模板百度ai搜索引擎
  • 做贸易常用的网站百度云资源链接分享群组
  • 南京公司网站建设怎么收费十大免费域名
  • 九江做网站哪家便宜线下引流的八种推广方式
  • 番禺建设网站公司软文范例大全1000字
  • 做网站汉中包括哪些内容
  • 跨境电商在哪些网站上面做海南seo排名优化公司
  • 网页设计与网站开发基础教程汕头网站建设方案开发
  • 做外贸必须知道的网站网络运营是什么意思
  • 专做和田玉的网站旺道seo推广系统怎么收费
  • 乐清网站制作公司怎样优化关键词到首页
  • 网站开发和前端和数据媒体seo学习网站
  • nginx 运行wordpress西安seo关键词排名优化
  • 北京电子商务app网站建设大兴网络营销方式有哪些分类