标签:lang round sql font ace option asio tcp install
MyTop是一个类似Linux下的top命令风格的MySQL监控工具,MyTop采用Perl开发。MyTop可以监控MySQL当前的连接用户和正在执行的命令。
MyTop的项目页面为:http://jeremy.zawodny.com/mysql/mytop/
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum -y install mytop #epel源
-u or -user username
Username to use when logging in to the MySQL server. Default: ‘‘root’’.
-p or -pass or -password password
Password to use when logging in to the MySQL server. Default: none.
-h or -host hostname[:port]
Hostname of the MySQL server. The hostname may be followed by an option port number.
Note that the port is specified separate from the host when using a config file.
Default: ‘‘localhost’’.
-port or -P port
If you’re running MySQL on a non-standard port, use this to specify the port number.
Default: 3306.
-s or -delay seconds
How long between display refreshes. Default: 5
-d or -db or -database database
Use if you’d like mytop to connect to a specific database by default. Default: ‘‘test’’.
-S or -socket /path/to/socket
If you’re running mytop on the same host as MySQL, you may wish to have it use the MySQL
socket directly rather than a standard TCP/IP connection. If you do,just specify one.
-b or -batch or -batchmode
In batch mode, mytop runs only once, does not clear the screen, and places no limit on
the number of lines it will print. This is suitable for running periodically (perhaps
from cron) to capture the information into a file for later viewing. You might use batch
mode in a CGI script to occasionally display your MySQL server status on the web.
默认参数说明:
* database you specified "test" (default is "test")
* username you specified "root" (default is "root")
* password you specified "123456" (default is "")
* hostname you specified "localhost" (default is "localhost")
* port you specified "3306" (default is 3306)
* socket you specified "/data/3306/mysql.sock" (default is "")
命令行运行
[root@db01 ~]# mytop -uroot -p123456 -S /data/3307/mysql.sock -d liangkai
提示:显示颜色说明
Query - Yellow
Sleep - White
Connect - Green
MyTop配置文件在~/.mytop,也可在~/.my.cnf文件中配置用户名和密码。
$ vim ~/.mytop
user=root
pass=mysql
host=localhost
db=wordpress
delay=5
port=3306
socket=/var/lib/mysql//mysql.sock
batchmode=0
header=1
color=1
idle=1
注意:socket设置和my.cnf里的路径一样,一般MyTop和Mysql在同一台机器。
若将MyTop装在另一台机器上时,需要设定MySQL Server上的权限才能远端监控
在MySQL Server上新增一个帐号,并给它Process的权限
$ mysql -u root -p
mysql> grant process on *.* to <REMOTE_USERNAME>@<REMOTE_IP> identified by ‘<PASSWORD>‘;
mysql> flush privileges;
mysql> exit
在安装MyTop的机器上,用参数指定或修改配置文件的设定。
参数指定
$ mytop -u <REMOTE_USERNAME> -p <PASSWORD> -h <MYSQL_SERVER_IP>
修改配置文件
$ vim ~/.mytop
user=<REMOTE_USERNAME>
pass=<PASSWORD>
host=<MYSQL_SERVER_IP>
s:设定更新时间
p:暂停画面更新
q:离开
u:只看某个使用者的thread
o:反转排列顺序
Mytop和Linux下面的top命令展现的结果类似,下面展示了每个线程的当前的状态并且是动态变化。
第一行显示了主机名称,还有至今MySQL的运行时间(以days hour:minutes:seconds为格式)。
第二、三行的显示了Qps:每秒请求书、Slow:慢查询的数量、Se/In/Up/De(%):读写比例。
第四行的Key Efficiency就是Myisam的键值缓存区使用比例(缓存命中率),Bps:目前网络进出流量。
最下方的区域就是目前链接到数据库的各个线程,你可以按k杀死一个线程,或者按f了解特定线程的信息。
标签:lang round sql font ace option asio tcp install
原文地址:http://www.cnblogs.com/kai2016/p/6112924.html