Mtop,Mysql Top,一个Mysql的监控工具
mtop 实时监控 MySQL
------------ --------------------------------------------------------
Curses http://cpan.linuxforum.net/authors/id/G/GI/GIRAFFED
DBI Distributed as Bundle::DBI: http://www.cpan.org/authors/id/TIMB
DBD::mysql http://www.cpan.org/modules/by-module/DBD
Getopt::Long (Distributed with Perl 5)
Net::Domain Part of libnet: http://www.cpan.org/authors/id/GBARR
# perl -e 'use Curses'
# perl -e 'use DBI'
# perl -e 'use DBD::mysql'
# perl -e 'use Getopt::Long'
# perl -e 'use Net::Domain'
安装所需的 Perl 模块:
# tar zxvf Curses-x.xx.tar.gz
# cd Curses*
# perl Makefile.PL
# make
# make install
/usr/local/mysql/lib/mysql
# ldconfig
# cd DBD-mysql*
# perl Makefile.PL --mysql_config=/usr/local/mysql/bin/mysql_config
# make
# make install
# cd mtop-0.6.6
# perl Makefile.PL
# make
# make install
# mysql -uroot -pPASSWORD
mysql> GRANT RELOAD,PROCESS,SUPER ON *.* TO 'mtop'@'localhost' IDENTIFIED BY 'mtop';
mysql> FLUSH PRIVILEGES;
mysql> exit
MTOP(1p) User Contributed Perl Documentation MTOP(1p)
mtop - Shows top mysql threads
mtop [--host={mysql_host}] [--dbuser={mysql_user}]
[--password={mysqluser_pw}] [--seconds={refresh}] [--[no]idle]
[--filter-user={regex}] [--filter-host={regex}] [--filter-db={regex}]
[--filter-command={regex}] [--filter-state={regex}] [--filter-info={{regex}}]
[--fold-select-columns]
[--user={user}] [--manualrefresh] [--slow={seconds}] [--vs¦veryslow={seconds}]
[--vvs¦veryveryslow={seconds}]
Shows the MySQL commands consuming the greatest time. By default, only non-sleeping threads are
shown, the --idle option shows idle threads. While running several keys will affect the operation of
mtop. Hitting h or ? will show the available options.
they will stay on the screen for a while. However, if you are hunting for short lived queries, run-
ning in the manualrefresh mode with a short refresh time will allow you to catch short lived queries
as well.
? - help
m - toggle manual refresh mode on/off
d - filter display with regular expression (user/host/db/command/state/info)
F - fold/unfold column names in select statement display
h - display process for only one host
u - display process for only one user
i - toggle all/non-Sleeping process display
o - reverse the sort order
e - explain a process; show query optimizer info
z - zoom in on a process; show sql statement detail
f - flush stats (reset show status variables)
t - show mysqld stats (show status/mysqladmin ext)
T - show short/important status
v - show mysqld variables (show variables/mysqladmin vars)
r - show replication status for master/slaves
Main Screen
nations are from the MySQL online manual and references refer to the section in the manual where the
explanation came from):
The n Threads represents how many threads the mysqld has allocated. One thread is allocated for
each user connection. Additional threads are allocated for replication.
The first number is the total number of queries sent to the server since the last ’flush status’
or since server start. The second number is the number of queries that have taken more than
long_query_time. See section 4.9.5 The Slow Query Log.
This is the percentage of times a key read is handled from the key buffer cache. See section
4.5.7.4 SHOW VARIABLES of the MySQL manual for more information.
MySQL has a cache for open tables. If ’opened tables’ is high, your cache may be too small.
Look at the MySQL manual section: 5.4.7 How MySQL Opens and Closes Tables for further informa-
tion.
Number of requests to read the next row in the datafile. This will be high if you are doing a lot
of table scans. Generally this suggests that your tables are not properly indexed or that your
queries are not written to take advantage of the indexes you have. (4.5.7.3)
Number of times a table lock could not be acquired immediately and a wait was needed. If this is
high, and you have performance problems, you should first optimise your queries, and then either
split your table(s) or use replication. Available after 3.23.33. (4.5.7.3)
Number of joins without keys (If this is not 0, you should carefully check the indexes of your
tables). (4.5.7.3)
Number of merges passes the sort algoritm have had to do. If this value is large you should con-
sider increasing sort_buffer. (4.5.7.3)
The total number of sql commands handled by the MySQL server since startup or the last flush sta-
tus command.
Statistics/Variables
will return to the main screen. The bottom of the stats screen is denoted with a line containing
---. If you do not see that line, resize your screen until you do.
number per second since startup or flush. The last is the number per second since the last screen
refresh.
do not change after server startup.
Replication
mysqld. If a master server is found, it then tries to connect to each slave connected to the master.
Replication is shown for all masters and slaves found. Offsets from the master for each of the
slaves is shown. Note: the offset may be less than zero because the slave position is checked after
the master position. The offset shown is the number of queries in the binlog that the slave has to
process before being caught up with the master.
OPTIONS
All options can be abbreviated by their shortest unique abbreviation.
Show the help screen and exit.
Show the version number and exit.
By default, the mysqld on localhost is monitored. Specify an alternate host with this option.
By default, the user ’mysqltop’ is used to connect to the database. Specify an alternate user
with this option.
By default, there is no password associated with the mysqltop user, specify a password with this
option.
The default screen refresh is 5 seconds.
The number of seconds before a slow query is highlighted. The default is the server’s long_query
configuration variable.
The number of seconds before a very slow query is highlighted. The default is the the --slow
option * 2.
The number of seconds before a very very slow query is highlighted. The default is the the
--slow option * 4.
By default, processes in the Sleep command state are not shown. This option turns on display of
idle threads.
Show only threads owned by this user.
-fu {regex_pattern}, --filter-user={regex_pattern}
-fh {regex_pattern}, --filter-host={regex_pattern}
-fd {regex_pattern}, --filter-db={regex_pattern}
-fs {regex_pattern}, --filter-state={regex_pattern}
-fc {regex_pattern}, --filter-command={regex_pattern}
-fi {regex_pattern}, --filter-info={regex_pattern}
Filter the display based on the regex_pattern provided. The regex_pattern is a perl regular
expression. The regular expression match is done with case insensitivity.
escape any special shell characters in the regex.
-m, --manualrefresh
In this mode, the screen only refreshes when the user hits a key on the keyboard. The screen
will refresh automatically until a query is seen and then wait for further input. An uppercase M
will appear in the top right hand corner of the screen to indicate that you are in this mode.
the initialization file(s). The following files are checked for arguments: current direcotry .mto-
prc, home directory .mtoprc, /usr/local/etc/mtoprc, /etc/mtoprc. Options in the former files over-
ride options in the later files.
would be on the command line. They can be abbreviated and use the one or two hyphen syntax. Com-
ments and blank lines are ignored. The following is an exmple .mtoprc file which sets a user filter
to user1 and sets the refresh rate to one second:
-fu user1
--seconds=1 # refresh every one seconds
SETUP
The most convenient way to setup your system to use mtop is to create a database user called mysqltop
which has no password. For security purposes, this user should have all privileges set to N except
Process_priv which must be set to Y.
mysql> grant super, reload, process on *.* to mysqltop@localhost;
mysql> flush privileges;
mysql> grant reload, process on *.* to mysqltop@localhost;
mysql> flush privileges;
the permissions as noted above.
to grant access from. In general, you probably want to limit it to the hosts in your domain.
wish to issue flush commands from mtop. The super privilege is needed if you wish to kill
queries in mysql 4.0.2 versions and above. In 3.x, the process privilege allows a user to termi-
nate a query.
database specific (SHOW FULL PROCESSLIST, SHOW VARIABLES, KILL id). However, when database-specific
commands are needed, mtop will try to connect to the the required database and prompt for a user-
name/password if the default one fails.
To install mtop, run the following shell commands:
make
make install
change this, run:
------------ --------------------------------------------------------
Curses http://www.cpan.org/authors/id/WPS
DBI Distributed as Bundle::DBI: http://www.cpan.org/authors/id/TIMB
DBD::mysql http://www.cpan.org/authors/id/JWIED
Getopt::Long (Distributed with Perl 5)
Net::Domain Part of libnet: http://www.cpan.org/authors/id/GBARR/
Marc Prewitt, Chelsea Networks <mprewitt@chelsea.net>
WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions; see
the COPYING file for details.
The cache hit ratio may look very low if your server receives more than 4 billion key_read_requests.
This is due to a roll-over condition. If that number exceeds 4 billion and change, it rolls over to
1. The cache hit ratio is calculated as: 100 - (key_reads/key_read_requests) * 100.
command to reset both the key_reads and key_read_requests.
doesn’t work well with curses (in my testing on Solaris 8). To work around this, set the terminal
type to vt100. To do this, issue the following command from the telnet prompt before connecting to a
host:
Offer sorts by other columns
Mtop,Mysql Top,一个Mysql的监控工具相关推荐
- python跟php如何共用mysql_Python 3 多个函数共用一个mysql连接
1.本人刚接触Python,环境用的是Python3,使用pymysql模块连接数据库.为了节省资源,我是打算在一个python脚本中的各个函数里共用一个mysql连接, 2.代码如下所示: # co ...
- 使用BIND9+MySql搭建一个智能解析DNS
公司之前就有个所谓的"融合性CND"产品,什么叫CDN可以点这里看下,那什么又叫"融合性CDN",过了一天明白了,就是把第三方成熟的CDN产品给封装成带有自 ...
- PHP+Mysql制作一个学生成绩查询模块
PHP+Mysql制作一个学生成绩查询模块 我不是学PHP的我只是需要用一下PHP要是学又得好长时间,最好的方法就是问,但是问会的,又说让百度,得,我直接自己干吧,便花费了我一整天时间做了一下,从网上 ...
- springboot+jwt+shiro+vue+elementUI+axios+redis+mysql完成一个前后端分离的博客项目(笔记,帮填坑)
根据B站up主MarkerHub视频制作的一个笔记 我的博客 B站博主链接: https://www.bilibili.com/video/BV1PQ4y1P7hZ?p=1 博主的开发文档: http ...
- mysql第三章关系模型_一个MySQL关系模型只有三个关系(二维表)组成。_学小易找答案...
[判断题]DELETE语句功能是对表中所有记录或满足条件的记录进行批量删除. [填空题]The computer's entire ____ was on a single board. [单选题]下 ...
- php mysql多重筛选,如何使用php、html、mysql构建一个多重分类选择列表
不适用javascript,完全通过php实现多级列表选择,列表数据从数据库获取 A very simple way to build and do a hierarchical html categ ...
- mysql 监控语句_做一个mysql监控系统应该掌握的一些基本语句
很多系统需要一个MYSQL的监控,查看MYSQL的一些变量配置,吞吐量,连接数,QPS, TPS,慢查询等.当然有一些开源的工具可以满足这些需求,如果是要自己做呢.下面归纳了一些常用监控的SQL语句, ...
- 如何不停机迁移一个mysql INNODB 数据库?
2019独角兽企业重金招聘Python工程师标准>>> 如何不停机迁移一个mysql INNODB 数据库? http://www.itpub.net/thread-1776724- ...
- 数据由SqlServer2008转移到MySQL的一个方法
数据由SqlServer2008转移到MySQL的一个方法 1.将数据从SqlServer导出到Excel文件中,方法http://www.cnblogs.com/hewenwu/p/3684629. ...
最新文章
- 2021年 第12届 蓝桥杯 第3次模拟赛真题详解及小结【Java版】
- 机器学习集成模型学习——投票集成Voting(二)
- asp.net MVC Views-----Controller传递数据方法
- 字符串转python对象
- JavaScript高级程序设计(第三版)阅读笔记
- 大数据分析技术与应用
- 解决网易云音乐ubuntu客户端播放中无声音
- 转:firefox os 框架解析
- spire.doc.free2.7.3生成目录后修改目录的字体
- 半年内第二块国产全功能GPU,附带首个游戏显卡!摩尔线程造芯神速,张建中“黄”气逼人...
- 登陆163邮箱显示服务器验证失败是什么原因?微信怎么登陆邮箱?
- fastadmin 数据导出,设置excel行高和限制图片大小
- 华硕rt-n16无线打印服务器,华硕无线路由器RT-N16解决无线信号难题
- 除铜、除镍原装进口树脂CH-90
- ldap+samba
- 金蝶K3wise、金蝶KIS旗舰版数据同步到金蝶云星空
- 看到有些手机酷炫的动态壁纸,有没有好奇过他们是如何实现的
- Head First C#中文版 图文皆译 (page17)去掉了图片上的黑框,换了徐静蕾的字体
- PMP中必学的人际关系处理
- [转载]Macropodus自然语言处理(NLP)工具包(Albert+BiLSTM+CRF)