如何测量MySQL服务器当前的负载?

发布于 2024-08-07 00:21:10 字数 94 浏览 3 评论 0原文

如何测量MySQL服务器当前的负载?我知道我可以测量不同的东西,例如 CPU 使用率、RAM 使用率、磁盘 IO 等,但是是否有通用的负载测量,例如服务器负载为 40% 等?

How to measure current load of MySQL server? I know I can measure different things like CPU usage, RAM usage, disk IO etc but is there a generic load measure for example the server is at 40% load etc?

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

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

发布评论

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

评论(7

娇柔作态 2024-08-14 00:21:10
mysql> SHOW GLOBAL STATUS;

找到此处

mysql> SHOW GLOBAL STATUS;

Found here.

公布 2024-08-14 00:21:10

“40% 负载”的概念并没有真正明确的定义。您的特定应用程序可能会对不同资源的限制做出不同的反应。应用程序通常会受到以下三个因素之一的限制:可用(物理)内存、可用 CPU 时间和磁盘 IO。

在 Linux(或可能其他 *NIX)系统上,您可以使用 vmstat 或 iostat(提供有关磁盘 IO 的更多详细信息)获取这些快照。

但是,要将这些连接到“40% 负载”,您需要了解数据库在典型负载下的性能特征。做到这一点的最佳方法是在不同的负载量下使用典型查询进行测试,直到您观察到响应时间急剧增加(这意味着您已经遇到了内存、CPU 或磁盘的瓶颈)。该负载应被视为您的临界水平,您不想超过该水平。

The notion of "40% load" is not really well-defined. Your particular application may react differently to constraints on different resources. Applications will typically be bound by one of three factors: available (physical) memory, available CPU time, and disk IO.

On Linux (or possibly other *NIX) systems, you can get a snapshot of these with vmstat, or iostat (which provides more detail on disk IO).

However, to connect these to "40% load", you need to understand your database's performance characteristics under typical load. The best way to do this is to test with typical queries under varying amounts of load, until you observe response times increasing dramatically (this will mean you've hit a bottleneck in memory, CPU, or disk). This load should be considered your critical level, which you do not want to exceed.

離殇 2024-08-14 00:21:10

是否有通用的负载测量,例如服务器负载为 40%?

是的!有:

SELECT LOAD_FILE("/proc/loadavg")

在Linux机器上工作。它显示过去 1 分钟、5 分钟和 15 分钟的系统负载平均值。

系统平均负载是处于可运行或不可中断状态的进程的平均数量。处于可运行状态的进程要么正在使用CPU,要么正在等待使用CPU。
处于不可中断状态的进程正在等待某些I/O 访问,例如等待磁盘。取三个时间间隔的平均值。负载平均值未针对数量进行归一化
系统中的 CPU 数,因此平均负载为 1 意味着单个 CPU 系统始终处于加载状态,而在 4 CPU 系统上则意味着 75% 的时间处于空闲状态。

因此,如果你想标准化,你还需要计算 cpu 的数量。

你也可以通过

SELECT LOAD_FILE("/proc/cpuinfo")

查看“man proc”来做到这一点

is there a generic load measure for example the server is at 40% load ?

Yes! there is:

SELECT LOAD_FILE("/proc/loadavg")

Works on a linux machine. It displays the system load averages for the past 1, 5, and 15 minutes.

System load averages is the average number of processes that are either in a runnable or uninterruptable state. A process in a runnable state is either using the CPU or waiting to use the CPU.
A process in uninterruptable state is waiting for some I/O access, eg waiting for disk. The averages are taken over the three time intervals. Load averages are not normalized for the number of
CPUs in a system, so a load average of 1 means a single CPU system is loaded all the time while on a 4 CPU system it means it was idle 75% of the time.

So if you want to normalize you need to count de number of cpu's also.

you can do that too with

SELECT LOAD_FILE("/proc/cpuinfo")

see also 'man proc'

肤浅与狂妄 2024-08-14 00:21:10

使用 top 或 htop 可以实时跟踪 Linux 中的使用情况

with top or htop you can follow the usage in Linux realtime

迷离° 2024-08-14 00:21:10

在基于 Linux 的系统上,标准检查通常是正常运行时间,根据描述的指标返回负载指数 在这里

On linux based systems the standard check is usually uptime, a load index is returned according to metrics described here.

白云悠悠 2024-08-14 00:21:10

除了本页上所有好的答案(SHOW GLOBAL STATUS、VMSTAT、TOP...)之外,还有一个由 Jeremy Zawodny 编写的非常简单易用的工具,它非常适合非管理员用户。它被称为“mytop”。更多信息@ http://jeremy.zawodny.com/mysql/mytop/

aside from all the good answers on this page (SHOW GLOBAL STATUS, VMSTAT, TOP...) there is also a very simple to use tool written by Jeremy Zawodny, it is perfect for non-admin users. It is called "mytop". more info @ http://jeremy.zawodny.com/mysql/mytop/

过潦 2024-08-14 00:21:10

嗨,朋友,根据我的研究,我们有一些命令,例如

  • MYTOP:使用 PERL 语言编写的开源程序
  • MTOP:也是一个用 PERL 编写的开源程序,它的工作原理与 MYTOP 相同但它会监视花费较长时间的查询并在特定时间后终止它们。

上述命令详细信息的链接

Hi friend as per my research we have some command like

  • MYTOP: open source program written using PERL language
  • MTOP: also an open source program written on PERL, It works same as MYTOP but it monitors the queries which are taking longer time and kills them after specific time.

Link for details of above command

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