MySQL:慢日志;追加CPU使用率

发布于 2024-12-26 17:11:23 字数 264 浏览 1 评论 0原文

我启用了 MySQL 慢日志功能: http:// dev.mysql.com/doc/refman/5.1/en/slow-query-log.html

但有时 query_times 很高仅仅是因为 CPU 负载高。

如何将当前 CPU 负载附加到 MySQL 慢速日志中的每个条目(它写入文件)?

I have the MySQL slow log feature enabled: http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html

But sometimes the query_times are high simply due to high CPU load.

How can I append the current CPU load to each entry in the MySQL slow log (it writes to a file)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

久光 2025-01-02 17:11:23

由于查询速度慢,CPU 可能会很高。

MySQL 不会监控您的 CPU,因此您将需要第 3 方监控工具,并将 CPU 较高的时间与查询(已记录)运行的时间进行比较。

我使用 AWS,它有一些很好的监控功能,当 CPU 较高时我会收到警报,然后我可以追踪慢查询日志并查看哪些日志导致了它。

希望对一些人有所帮助。但我的猜测是 CPU 因查询而高,而不是查询因 CPU 而慢。只是一个猜测。

The CPU may be high due to the slow query.

MySQL does not monitor your CPU, so you are going to need a 3rd party monitoring tool and compare the times that CPU is high to the times the query (that is logged) is running.

I use AWS, which has some nice monitoring, and I get an alert when the CPU is high, then I can tail the Slow Query Log and see which ones are causing it.

Hope that helps some. But my guess is the CPU is high due to the query and not that the query is slow due to the CPU. Just a guess tho.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文