mysql慢查询日志分析工具使用_MySQL
1.mysql-log-filter工具脚本使用说明:
google code上找到的一个分析工具.提供了 python 和 php 两种可执行的脚本。http://code.google.com/p/mysql-log-filter/ (需要搬梯子爬墙),51cto下载链接:http://down.bitsCN.com/data/2123725
使用方法:(这里只介绍python的使用方法)
python mysql_filter_slow_log.py ./mysql1-slow.log --no-duplicates --sort-execution-count --top=10 >> mysql_slow_test.txt
备注:mysql1-slow.log 慢查询日志名称
--no-duplicates
--sort-execution-count
--top=10 取前十位
mysql_slow_test.txt 输出分析报告
附录:
官方给出的使用方法举例:
=====================================
# Filter slow queries executed for at least 3 seconds not from root, remove duplicates, # apply execution count as first sorting value and save first 10 unique queries to file. # In addition, remember last input file position and statistics. php mysql_filter_slow_log.php -T=3 -eu=root --no-duplicates --sort-execution-count --top=10 --incremental linux-slow.log > mysql-slow-queries.log # Start permanent filtering of all slow queries from now on: at least 3 seconds or examining 10000 rows, exclude users root and test tail -f -n 0 linux-slow.log | python mysql_filter_slow_log.py -T=3 -R=10000 -eu=root -eu=test & # (-n 0 outputs only lines generated after start of tail) # Stop permanent filtering kill `ps auxww | grep 'tail -f -n 0 linux-slow.log' | egrep -v grep | awk '{print $2}'`
====================================
官方给出的命令参数:
==================================
-T=min_query_time -R=min_rows_examined -ih, --include-host -eh, --exclude-host -iu, --include-user -eu, --exclude-user -iq, --include-query --date=date_first-date_last Include only queries between date_first (and date_last). Input: Date Range: 13.11.2006 -> 13.11.2006 - 14.11.2006 (exclusive) 13.11.2006-15.11.2006 -> 13.11.2006 - 16.11.2006 (exclusive) 15-11-2006-11/13/2006 -> 13.11.2006 - 16.11.2006 (exclusive) >13.11.2006 -> 14.11.2006 - later 13.11.2006- -> 13.11.2006 - later <13.11.2006 -> earlier - 13.11.2006 (exclusive) -13.11.2006 -> earlier - 14.11.2006 (exclusive) Please do not forget to escape the greater or lesser than symbols (><, i.e. '--date=>13.11.2006'). Short dates are supported if you include a trailing separator (i.e. 13.11.-11/15/). --incremental Remember input file positions and optionally --no-duplicates statistics between executions in mysql_filter_slow_log.sqlite3 --no-duplicates Powerful option to output only unique query strings with additional statistics: Execution count, first and last timestamp. Query time: avg / max / sum. Lock time: avg / max / sum. Rows examined: avg / max / sum. Rows sent: avg / max / sum. --no-output Do not print statistics, just update database with incremental statistics Default ordering of unique queries: --sort-sum-query-time [ 1. position] --sort-avg-query-time [ 2. position] --sort-max-query-time [ 3. position] --sort-sum-lock-time [ 4. position] --sort-avg-lock-time [ 5. position] --sort-max-lock-time [ 6. position] --sort-sum-rows-examined [ 7. position] --sort-avg-rows-examined [ 8. position] --sort-max-rows-examined [ 9. position] --sort-execution-count [10. position] --sort-sum-rows-sent [11. position] --sort-avg-rows-sent [12. position] --sort-max-rows-sent [13. position] --sort=sum-query-time,avg-query-time,max-query-time,... You can include multiple sorting values separated by commas. --sort=sqt,aqt,mqt,slt,alt,mlt,sre,are,mre,ec,srs,ars,mrs Every long sorting option has an equivalent short form (first character of each word). --top=max_unique_query_count Output maximal max_unique_query_count different unique queries --details Enables output of timestamp based unique query time lines after user list (i.e. # Query_time: 81 Lock_time: 0 Rows_sent: 884 Rows_examined: 2448350). --help Output this message only and quit [multiple] options can be passed more than once to set multiple values. [position] options take the position of their first occurrence into account. The first passed option will replace the default first sorting, ... Remaining default ordering options will keep their relative positions.
====================================
官方给出的配置文件中管理慢日志参数的配置
====================================
# I.e. you could add the following lines under the [mysqld] section of your my.ini or my.cnf configuration file: # Log all queries taking more than 3 seconds long_query_time=3 # minimum: 1, default: 10 # MySQL >= 5.1.21 (or patched): 3 seconds = 3000000 microseconds # long_query_time=3.000000 # minimum: 0.000001 (1 microsecond) # Activate the Slow Query Log slow_query_log # >= 5.1.29 # log-slow-queries # deprecated since 5.1.29 # Write to a custom file name (>= 5.1.29) # slow_query_log_file=file_name # default: /data_dir/host_name-slow.log # Log all queries without indexes # log-queries-not-using-indexes # Log only queries which examine at least N rows (>= 5.1.21) # min_examined_row_limit=1000 # default: 0 # Log slow OPTIMIZE TABLE, ANALYZE TABLE, and ALTER TABLE statements # log-slow-admin-statements # Log slow queries executed by replication slaves (>= 5.1.21) # log-slow-slave-statements # MySQL 5.1.6 through 5.1.20 had a default value of log-output=TABLE, so you should force # Attention: logging to TABLE only includes whole seconds information log-output=FILE ## Admin query for online activation is possible since MySQL 5.1 (without server restart) ## SET @@global.slow_query_log=1 ## SET @@global.long_query_time=1 ## Show current variables related to the Slow Query Log ## SHOW GLOBAL VARIABLES WHERE Variable_name REGEXP 'admin|min_examined|log_output|log_queries|log_slave|long|slow_quer'
======================================
注意:在执行脚本的时候会报数据类型的错误,具体错误指定469行,经过查看,实际慢查询日志中的query_time是float类型,而在这个脚本工具中定义的确实int类型。于是自行修改!
默认:
======================
query_time = (int(numbers[1].split()[0]), int(numbers[2].split()[0]),
int(numbers[3].split()[0]), int(numbers[4]))
======================
修改为:
======================
query_time = (float(numbers[1].split()[0]), float(numbers[2].split()[0]),
float(numbers[3].split()[0]), float(numbers[4]))

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

本文推荐十个知名的虚拟币相关APP推荐网站,涵盖币安学院(Binance Academy)、OKX Learn、CoinGecko、CryptoSlate、CoinDesk、Investopedia、CoinMarketCap、火币大学(Huobi University)、Coinbase Learn和CryptoCompare。这些网站不仅提供虚拟货币市场数据、价格走势分析等信息,还提供丰富的学习资源,包括区块链基础知识、交易策略、以及各个交易平台APP的使用教程和评测,帮助用户更好地了解和使

本文基于市场数据和常见评估标准,盘点了2025年十大正规Web3交易平台APP。榜单涵盖币安、OKX、Gate.io、火币(现名HTX)、Crypto.com、Coinbase、Kraken、Gemini、BitMEX和Bybit等知名平台。这些平台在用户规模、交易量、安全性、合规性、产品创新等方面各有优势,例如币安以其庞大的用户基础和丰富的产品服务着称,而Coinbase则专注于安全性和合规性。 选择合适的平台需根据自身需求和风险承受能力进行综合考量。

数字货币滚仓,即利用借贷放大交易杠杆以提高收益的投资策略。 本文详解数字货币滚仓流程,包括选择支持滚仓的交易平台(如Binance、OKEx、gate.io、Huobi、Bybit等),开通杠杆账户,设置杠杆倍数,借入资金进行交易,以及实时监控市场并调整仓位或追加保证金以避免爆仓等关键步骤。 然而,滚仓交易风险极高,投资者需谨慎操作并制定完善的风险管理策略。 了解更多数字货币滚仓技巧,请继续阅读。

本文盘点十大知名Web3交易平台,包括币安(Binance)、欧易(OKX)、Gate.io(芝麻开门)、Kraken、Bybit、Coinbase、KuCoin、Bitget、Gemini和Bitstamp。 文章详细对比了各平台的特色,例如币种数量、交易类型(现货、期货、期权、NFT等)、手续费、安全性、合规性、用户群体等,旨在帮助投资者选择最合适的交易平台。无论是高频交易者、合约交易爱好者,还是注重合规性和安全性的投资者,都能从中找到参考信息。

这篇文章为币圈新手提供了详细的交易所推荐和入门教程。推荐了Coinbase、币安、Kraken、欧易和芝麻开门等常用交易所,并介绍了注册、身份验证、安全设置、充值和交易等步骤。文章还强调了安全意识、风险控制和持续学习的重要性,旨在帮助新手安全、理性地进入数字资产领域。

免费观看行情软件网站有六个:1. 币安(Binance)平台,适合数字资产投资者;2. 欧易(OKX)平台,提供丰富行情数据;3. 芝麻开门(Gate.io)平台,适合在Gate.io交易的用户;4. TradingView,提供专业图表工具;5. CoinMarketCap,覆盖广泛的数字资产数据;6. CoinGecko,提供项目基本面评估。选择平台时,需考虑投资对象、图表功能需求、数据全面性和用户体验。

本文为2025年进入币圈的新手推荐了几个常用且相对安全的虚拟币交易所,包括币安、欧易、Coinbase和芝麻开门等。文章提供了详细的注册、身份验证、安全设置和交易流程教程,并强调了风险控制、安全意识和持续学习的重要性,旨在帮助新手安全入门数字资产交易。
