首页 > 其他分享 >archery 中analysis_slow_query.sh

archery 中analysis_slow_query.sh

时间:2023-07-05 15:35:29浏览次数:35  
标签:archery slow -- db analysis sh query digest

pt_query_digest安装

mv pt-query-digest   /usr/bin/

chmod +x  /usr/bin/pt-query-digest

yum -y install perl-Digest-MD5

yum -y install perl-DBI perl-DBD-MySQL

 

 

analysis_slow_query.sh:

#!/bin/bash
DIR="$( cd "$( dirname "$0" )" && pwd )"
cd ${DIR}

#配置Archery数据库的连接地址
archery_db_host="archery db"
archery_db_port=3306
archery_db_user="archery"
archery_db_password="123456"
archery_db_database="archery"

#被分析实例的慢日志位置,建议定期清理日志文件,否则会影响分析效率
slowquery_file="/var/lib/mysql/slow.log"

#pt-query-digest可执行文件路径
pt_query_digest="/usr/bin/pt-query-digest"

#被分析实例的连接信息
hostname="10.10.10.10:3306" # 需要和Archery实例配置中的内容保持一致,用于筛选,配置错误会导致数据无法展示

#获取上次分析时间,初始化时请删除last_analysis_time_$hostname文件,可分析全部日志数据
if [[ -s last_analysis_time_${hostname} ]]; then
last_analysis_time=`cat last_analysis_time_${hostname}`
else
last_analysis_time='1000-01-01 00:00:00'
fi

#收集日志
#RDS需要增加--no-version-check选项
${pt_query_digest} \
--user=${archery_db_user} --password=${archery_db_password} --port=${archery_db_port} \
--review h=${archery_db_host},D=${archery_db_database},t=mysql_slow_query_review \
--history h=${archery_db_host},D=${archery_db_database},t=mysql_slow_query_review_history \
--no-report --limit=100% --charset=utf8 \
--since "$last_analysis_time" \
--filter="\$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$hostname\" and \$event->{client}=\$event->{ip} " \
${slowquery_file} > /tmp/analysis_slow_query.log

if [[ $? -ne 0 ]]; then
echo "failed"
else
echo `date +"%Y-%m-%d %H:%M:%S"`>last_analysis_time_${hostname}
fi

标签:archery,slow,--,db,analysis,sh,query,digest
From: https://www.cnblogs.com/52shaidan/p/17528663.html

相关文章

  • 企业级logstash简单使用(ELK)
    企业级logstash简单使用(ELK)要使用logstash收集到Elasticsearch的方式,需确保logstash版本与es版本一致。由于我也是刚刚研究使用,所以本文暂不会出现原理性的东西。Logstash介绍Logstash是具有实时流水线能力的开源的数据收集引擎。Logstash可以动态统一不同来源的数据,并将数......
  • HashMap的遍历方法
    Map<String,String>myMap=newHashMap<>();myMap.put("key1","value1");myMap.put("key2","value2");//for循环遍历for(Map.Entry<String,String>entry:myMap.entrySet()){Stringkey=entry.getKe......
  • javax.net.ssl.SSLHandshakeException: The server selected protocol version TLS10
    问题:报错:javax.net.ssl.SSLHandshakeException:TheserverselectedprotocolversionTLS10isnotacceptedbyclientpreferences[TLS12]解决方式:1、修改%JAVA_HOME%/jre/lib/security/java.security2、修改内容:jdk.tls.disabledAlgorithms删除TLSv13、删除前: https:......
  • 1.7 完善自定位ShellCode后门
    在之前的文章中,我们实现了一个正向的匿名管道ShellCode后门,为了保证文章的简洁易懂并没有增加针对调用函数的动态定位功能,此类方法在更换系统后则由于地址变化导致我们的后门无法正常使用,接下来将实现通过PEB获取GetProcAddrees函数地址,并根据该函数实现所需其他函数的地址自定位......
  • org.apache.spark.shuffle.FetchFailedException: The relative remote executor(Id:
    问题描述org.apache.spark.shuffle.FetchFailedException:Therelativeremoteexecutor(Id:21),whichmaintainstheblockdatatofetchisdead.最近在做Spark的性能优化,测试使用不同CPU核数和内存对计算性能的影响,由于是在测试集群进行测试的,硬件配置比生产上面的要少和......
  • shiro550
    源码分析:   接收到response传回的参数后先序列化,之后进行aes加密(对称)  上图可以看到使用kPH+bIxk5D2deZiIxcaaaA==解密 最后base64编码 漏洞原理:shiro框架在登录时,如果勾选了RememberMe的功能,关闭浏览器再次访问时便无需再次登录,此时cookie中会增加一个rem......
  • Java源码系列4——HashMap扩容时究竟对链表和红黑树做了什么?
    Photobyhippopx.com我们知道HashMap的底层是由数组,链表,红黑树组成的,在HashMap做扩容操作时,除了把数组容量扩大为原来的两倍外,还会对所有元素重新计算hash值,因为长度扩大以后,hash值也随之改变。如果是简单的Node对象,只需要重新计算下标放进去就可以了,如果是链表和红黑......
  • 太阳得热系数 (SHGC) 与遮阳系数 (SC) 值的关系
    《公共建筑节能设计标准GB50189-2015》条文说明2.0.4(第71页):太阳得热系数(SHGC)不同于本标准2005版中的遮阳系数(SC)值。2005版标准中遮阳系数SC的定义为通过透光围护结构(门窗或透光幕墙)的太阳辐射室内得热量,与相同条件下通过相同面积的标准玻璃(3mm厚的透明玻璃)的......
  • java中concurrentHashMAP和HashTable有什么区别?
    ConcurrentHashMap和HashTable都是Java中用于实现线程安全的哈希表数据结构的类,但它们有一些关键的区别。线程安全性:ConcurrentHashMap是通过使用锁分段技术来实现线程安全的。它将整个哈希表分成了多个段(默认为16个),每个段有自己的锁。这样,在大多数情况下,多个线程可以同时访问不同......
  • powershell profile
    functionwelcome{echo"________|||||||||/_|||||_____|||________......