i have a busy web server with LAMP installed, and i was wondering, is there any way to count how many queries per second (mysql) are executed in the server ?
我有一个安装了LAMP的繁忙的Web服务器,我想知道,有没有办法计算服务器中每秒执行多少查询(mysql)?
Thank you.
谢谢。
6 个解决方案
#1
8
SELECT s1.variable_value / s2.variable_value
FROM information_schema.global_status s1, information_schema.global_status s2
WHERE s1.variable_name='queries'
AND s2.variable_name ='uptime';
#2
6
Try Jeremy Zawodny's excellent utility mytop.
试试Jeremy Zawodny的优秀实用mytop。
If you have the Perl module Time::HiRes installed, mytop will automatically use it to generate high-resoution query per second information.
如果安装了Perl模块Time :: HiRes,mytop将自动使用它来生成每秒高分辨率的查询信息。
#3
3
There's useful information to be mined from the SHOW GLOBAL STATUS; command, including the number of queries executed (if your MySQL is 5.0.76 or later).
从SHOW GLOBAL STATUS中挖掘出有用的信息;命令,包括执行的查询数(如果你的MySQL是5.0.76或更高版本)。
See http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html
请参阅http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html
#4
2
You can use:
您可以使用:
mysqladmin -u root -p status
which will return output like:
这将返回如下输出:
Uptime: 17134 Threads: 2 Questions: 1245 Slow queries: 0 Opens: 49 Flush tables: 1 Open tables: 42 Queries per second avg: 0.072
Here queries per second is: 0.072, which is questions/uptime
.
这里每秒查询次数为:0.072,这是问题/正常运行时间。
#5
1
When you use the "STATUS" command (not SHOW STATUS), MySQL will calculate the queries per second since server start for you.
当您使用“STATUS”命令(不显示状态)时,MySQL将计算自服务器启动以来每秒的查询数。
Tested with MySQL 5.1.63.
用MySQL 5.1.63测试。
#6
0
We can have a small script for this. It will be some thing like the below.
我们可以有一个小脚本。这将是下面的一些事情。
declare -i a
declare -i b
declare -i c
a=`mysql -uroot -pxxxxx -e "show status like 'Queries'" |
tail -1 | awk '{print $2}'`
echo "$a"
sleep 1
b=`mysql -uroot -pxxxxx -e "show status like 'Queries'" |
tail -1 | awk '{print $2}'`
echo "$b"
c=$b-$a
echo "Number of Queries per second is: $c"
#1
8
SELECT s1.variable_value / s2.variable_value
FROM information_schema.global_status s1, information_schema.global_status s2
WHERE s1.variable_name='queries'
AND s2.variable_name ='uptime';
#2
6
Try Jeremy Zawodny's excellent utility mytop.
试试Jeremy Zawodny的优秀实用mytop。
If you have the Perl module Time::HiRes installed, mytop will automatically use it to generate high-resoution query per second information.
如果安装了Perl模块Time :: HiRes,mytop将自动使用它来生成每秒高分辨率的查询信息。
#3
3
There's useful information to be mined from the SHOW GLOBAL STATUS; command, including the number of queries executed (if your MySQL is 5.0.76 or later).
从SHOW GLOBAL STATUS中挖掘出有用的信息;命令,包括执行的查询数(如果你的MySQL是5.0.76或更高版本)。
See http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html
请参阅http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html
#4
2
You can use:
您可以使用:
mysqladmin -u root -p status
which will return output like:
这将返回如下输出:
Uptime: 17134 Threads: 2 Questions: 1245 Slow queries: 0 Opens: 49 Flush tables: 1 Open tables: 42 Queries per second avg: 0.072
Here queries per second is: 0.072, which is questions/uptime
.
这里每秒查询次数为:0.072,这是问题/正常运行时间。
#5
1
When you use the "STATUS" command (not SHOW STATUS), MySQL will calculate the queries per second since server start for you.
当您使用“STATUS”命令(不显示状态)时,MySQL将计算自服务器启动以来每秒的查询数。
Tested with MySQL 5.1.63.
用MySQL 5.1.63测试。
#6
0
We can have a small script for this. It will be some thing like the below.
我们可以有一个小脚本。这将是下面的一些事情。
declare -i a
declare -i b
declare -i c
a=`mysql -uroot -pxxxxx -e "show status like 'Queries'" |
tail -1 | awk '{print $2}'`
echo "$a"
sleep 1
b=`mysql -uroot -pxxxxx -e "show status like 'Queries'" |
tail -1 | awk '{print $2}'`
echo "$b"
c=$b-$a
echo "Number of Queries per second is: $c"