版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Anemometer慢日志图形化工具介绍Anemometer基于pt-query-digest,将MySQL慢查询可视化。安装-安装:cd /u02/git clone git:/ anemometercd anemometer/ 由于表定义中存在0000-00-00 00:00:00 的日期默认值,需要修改sql_mode,将其zero_date的sql_mode 关闭,同时关闭only_full_group_bymysql -h14 -uroot -p123456 -P3306 < install.sql mysql -h192.168.0
2、.114 -uroot -p123456 -P3306 < install.sql -e "grant ALL ON slow_query_log.* to 'anemometer''%' IDENTIFIED BY '123456'" grant select ,super on *.* to 'anemometer''%' pt-query-digest -user=anemometer -password=123456 -port=3306 -review h=1
3、14,D=slow_query_log,t=global_query_review -history h=14,D=slow_query_log,t=global_query_review_history -no-report -limit=0% -filter=" $event->Bytes = length($event->arg) and $event->hostname="$HOSTNAME"" /u02/slow_queries.log cd /u02/anemo
4、meter/conf/cp sample.config.inc.php config.inc.php sed -i '285s#root#anemometer#g' config.inc.phpsed -i "286s#''#'123456'#g" config.inc.php cp datasource_localhost.inc.php datasource_localhost.inc.phpbakvi datasource_localhost.inc.phpmv anemometer/ /var/ww
5、w/html/登陆14/anemometer使用汇总按照时间区间查询查看执行计划自动化抓取+切割慢日志-授权用户CREATE USER 'log_rotate''localhost' IDENTIFIED BY '123456' GRANT RELOAD,SUPER ON *.* to 'log_rotate''localhost' FLUSH PRIVILEGES; -自动抓取/收集脚本rootmaster scripts# pwd/var/www/html/anemo
6、meter/scriptsrootmaster scripts# cat slow_db_export.sh #!/bin/bashpt-query-digest -user=anemometer -password=123456 -port=3306 -review h=14,D=slow_query_log,t=global_query_review -history h=14,D=slow_query_log,t=global_query_review_history -no-report -limit=0% -filter=" $e
7、vent->Bytes = length($event->arg) and $event->hostname="$HOSTNAME"" /u02/slow_queries.log -给权限rootmaster scripts# chmod -R 755 slow_db_export.sh 切割每日的慢查询日志,可以使用下面的logratate,也可以用类似archery工具的pt-query-digest 的-since功能-安装logrotaterootmaster scripts# yum install logrotat
8、e -y -配置每日切割慢查询日志rootmaster scripts# vi /etc/logrotate.d/mysql/u02/slow_queries.log create 660 mysql mysqldateextnotifemptydailymaxage 60rotate 30missingokcompressolddir /u02/oldlogpostrotate#run if mysqld is runningif mysqladmin ping -ulog_rotate -p'123456' -S /u01/data/mysql/data/mysq
9、l.sock &>/dev/null; then mysqladmin flush-logs -ulog_rotate -p'123456' -S /u01/data/mysql/data/mysql.sock fiendscript -给权限rootmaster scripts# chmod -R 755 /etc/logrotate.d/mysql -验证 预演方式运行:rootmaster scripts# /usr/sbin/logrotate -d -v /etc/logrotate.d/mysqlreading
10、config file /etc/logrotate.d/mysqlreading config info for /u02/slow_queries.log error: /etc/logrotate.d/mysql:6 argument expected after maxage counterror: /etc/logrotate.d/mysql:7 argument expected after rotate countolddir is now /u02/oldlog Handling 1 logs rotating pattern: /u02/slow_quer
11、ies.log after 1 days (no old logs will be kept)olddir is /u02/oldlog, empty log files are not rotated, old logs are removedconsidering log /u02/slow_queries.log log does not need rotatingnot running postrotate script, since no logs were rotated 强制方式运行rootmaster scripts# /usr/sbin/logrotat
12、e -fv /etc/logrotate.d/mysqlreading config file /etc/logrotate.d/mysqlreading config info for /u02/slow_queries.log olddir is now /u02/oldlog Handling 1 logs rotating pattern: /u02/slow_queries.log forced from command line (30 rotations)olddir is /u02/oldlog, empty log files are not rotate
13、d, old logs are removedconsidering log /u02/slow_queries.log log needs rotatingrotating log /u02/slow_queries.log, log->rotateCount is 30dateext suffix '-20201020'glob pattern '-0-90-90-90-90-90-90-90-9'glob finding old rotated logs failedrenaming /u02/slow_queries.log to /u02/old
14、log/slow_queries.log-20201020creating new /u02/slow_queries.log mode = 0660 uid = 3306 gid = 3306running postrotate scriptmysqladmin: Warning World-writable config file '/usr/local/mysql/etc/f' is ignored.mysqladmin: Warning Using a password on the command line interface can be pressing log with: /bin/gzip 查看: rootmaster oldlog# pwd/u02/oldlogrootmaster oldlog# ll -trhtotal 3.3M-rw-rw- 1 mysql mysql 3.3M Oct 20 14:20 slow_queries.log-20201020.gz rootmaster u02# ll -trh slow_queries.log -rw-r
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 企业打草承包协议书
- KDX贴膜合同范本
- 燃气管道防腐技术方案
- 代理社保协议书范本
- 中学搬迁征地协议书
- 天然气管道施工质量验收方案
- 二次加压系统自动化控制设备方案
- 河道整治水文分析技术方案
- 专利代理合同协议书
- 企业双方意向协议书
- 蒋婷婷-《书包里的故事》
- 《针灸治疗》课件-第六节 剧痛证-泌尿系绞痛
- GB/T 3683-2023橡胶软管及软管组合件油基或水基流体适用的钢丝编织增强液压型规范
- 保健食品广告审查表
- 冀教版五年级数学上册《综合与实践》教学设计
- 健身房会计账务处理
- 中南大学湘雅二医院神经外科重点专科申报书内容
- 党建知识题库附答案
- 2023版浙江评审卫生高级专业技术资格医学卫生刊物名录
- GB/T 3733.1-1983卡套式端直通管接头
- GB/T 34630.5-2017搅拌摩擦焊铝及铝合金第5部分:质量与检验要求
评论
0/150
提交评论