版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 装修最简单合同
- 咖啡馆员工合同
- 拆迁公司合同
- 拉萨租房合同
- 在线签署电子合同
- 《我爱这土地》课件
- 单间出租协议书
- 电炉改造协议书
- 互联网代理商协议书
- 香港地产转让协议书
- 机关安全生产培训内容课件
- 校园小导游 3 小讲堂(课件)数学人教版二年级上册(新教材)
- Shopee东南亚市场2025年跨境电商平台数据分析与消费者洞察报告
- 重庆市南开中学高2025-2026学年高三上学期开学第一次检测英语试卷
- 2024新版2025秋人教版二年级艺术造型美术上册全册教案教学设计(含大单元教学设计)
- 2025年客服经理考试重点突破
- 代签协议免责协议书范本
- 2025年放射工作人员培训考试试题(+答案)
- 联网无人机专业巡检课件
- 消化道出血课件
- 药物破损不良护理事件处理规范
评论
0/150
提交评论