Real-time monitoring of MySQL using mytop under CentOSThe Mytop project page is:HTTP://JEREMY.ZAWODNY.COM/MYSQL/MYTOP/MYTOP Installation
$ yum -y install mytop #epel源
Mytop Command Parameters
$ man mytop-u/--user <username>: Specify USERNAME, Preset is root-p/--pass/--password <PASSWO Rd>: Specify password, preset is none-h/--host
Note: Because .mytop
there is a password for MySQL server, please note the file permissions.
Use of Mytop
$ mytop -uroot -pmysql -d wordpress -h 127.0.0.1
mytop config file in ~/.mytop
, also available in
$ vim ~/.mytopuser=rootpass=mysqlhost=localhostdb=wordpressdelay=5port=3306socket=/var/lib/mysql//mysql.sockbatchmode=0header=1color=1idle=1
Note: The socket setting is the same as the path in MY.CNF, General Mytop and MySQL are on the same machine.
If you install Mytop on another machine, you need to set permissions on the MySQL server to remotely monitor
Add an account to MySQL server and give it process permissions
$ mysql -u root -pmysql> grant process on *.* to <REMOTE_USERNAME>@<REMOTE_IP> identified by ‘<PASSWORD>‘;mysql> flush privileges;mysql> exit
On the machine where mytop is installed, specify or modify the configuration file settings with parameters.
parameter specifies
$ mytop -u <REMOTE_USERNAME> -p <PASSWORD> -h <MYSQL_SERVER_IP>
Modifying a configuration file
$ vim ~/.mytopuser=<REMOTE_USERNAME>pass=<PASSWORD>host=<MYSQL_SERVER_IP>
s:设定更新时间 p:暂停画面更新q:离开u:只看某个使用者的threado:反转排列顺序
The Mytop and Linux top commands show similar results, showing the current state of each thread and dynamic changes.
$ mytop-uroot-pmysql-d wordpress-h 127.0.0.1MySQL on 127.0.0.1 (5.6.29-log) , &NB Sp up 0+05:44:42 [16:51:31] queries:654.0 qps: 0 Slow: 0.0 &NBSP ; Se/in/up/de (%): 00/00/00/00 QPS now: 0 Slow qps:0.0 threads: 1 ( 1/ 0) 00/00/00/00 Key efficiency:100.0% bps in/out: 0.8/160.4 Now In/out: 9.7/2.0k id user HOST/IP & nbsp DB time cmd Query or state , &N Bsp , &NB Sp , &NB Sp , &NB Sp , &NB Sp -- ---- ------- -- ---- ------------- &NBSP ; , &NB Sp , &NB Sp; , &NB Sp , &NB Sp , &NB Sp;8 root localhost wordpress 0 query Sho W Full processlist
The first line shows the host name, and the running time (in format) of MySQL to date days hour:minutes:seconds
.
The second to third line shows the QPS: Requests per second, Slow: number of slow queries, Se/in/up/de (%): Read and write ratios.
The key efficiency in line four is the MyISAM buffer usage ratio (cache hit rate), Bps: The current network in and out of traffic.
The bottom-most area is the individual threads that are currently linked to the database, and you can press to k
kill a thread, or by f
knowing the information for a particular thread.
From for notes (Wiz)
Real-time monitoring of MySQL using mytop under CentOS