mtop is a tool for monitoring mysql processes. It is very easy to use. Students who don’t know mtop can search for relevant instructions.
I installed it based on an article I found on Google (the author of the article is unknown);
############################### #################################
##Article quote start
################################################ ###############
Requires the following perl modules:
Module Available At
------------ ----------------------------------------- ------------------
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'
If there is no output, it means that the module has been installed. If there is an error, it means that the corresponding module has not been installed.
The latest version of the corresponding module can be downloaded at the address given above.
Install the required Perl modules:
# tar zxvf Curses-x.xx.tar.gz
# cd Curses*
# perl Makefile.PL
# make
# make install
There is perl-DBI in the yum repository, so install it directly with yum.
# yum -y install perl-DBI
Because MySQL is compiled and installed, you need to add the lib path to ld.so.conf.
# vi /etc/ld.so.conf
/usr/local/mysql/lib/mysql
#ldconfig
Although perl-DBD-MySQL is available in the yum warehouse, it depends on mysql, so it is still compiled and installed.
# tar zxvf DBD-mysql-x.xxxx.tar.gz
# cd DBD-mysql*
# perl Makefile.PL --mysql_config=/usr/local/mysql/bin/mysql_config
# make
# make install
Install mtop:
# tar zxvf mtop-0.6.6.tar.gz
# cd mtop-0.6.6
# perl Makefile.PL
#make
# make install
Add the corresponding MySQL database user:
# mysql -uroot -pPASSWORD
mysql> GRANT RELOAD,PROCESS,SUPER ON *.* TO 'mtop'@'localhost' IDENTIFIED BY 'mtop';
mysql> FLUSH PRIVILEGES;
mysql> exit
run:
Because the location of mysql.sock has been customized, a link to mtop is required to run it.
# ln -s /var/run/mysqld/mysql.sock /tmp/mysql.sock
# mtop --dbuser=mtop --password=mtop
Reference: http://mtop.sourceforge.net/
#################################### ############################
##End of article quote
################################################ ###############
Problems I encountered during actual installation and solutions:
1. If you cannot find relevant download resources on www.cpan.org , you can search under the domain name cpan.linuxforum.net;
2. Since Mysql on my server is installed using the rpm package; I encountered some problems when installing DBD-mysql;
There is no mysql_config file, so perl-DBD-MySQL cannot be configured as mentioned above;
Go take a look at the help file INSTALL.html in the DBD-mysql source package to find a solution;
First install the MySQL-shared and MySQL-devel rpm packages;
Then find the libmysqlclient.so file; create the folder /tmp/mysql-static and copy the libmysqlclient.so file into it;
Use # perl Makefile.PL --libs="-L/tmp/mysql-static -lmysqlclient" to configure perl-DBD-MySQL and you can install it;
After installing perl-DBD-MySQL, delete the temporary folder #rm -rf /tmp/mysql-static
If you encounter similar problems, it is best to read the source code documents or official help files;
Silly Big Cat ^_^