In this blog post, we will cover how to install and use Percona Toolkit on Ubuntu 20.04/18.04. Percona Toolkit is a collection of advanced command-line tools that are created by Percona to help you perform a variety of MongoDB and MySQL administration tasks that can be complex to do manually.
The installation of Percona Toolkit comes with a number of scripts which are well documented, easy to use and doesn’t depend on any external libraries. Percona Toolkit is developed and supported by Percona.
Install Percona Toolkit on Ubuntu 20.04/18.04 LTS
The Percona Toolkit is available on the Percona APT repository which can be added to Ubuntu 20.04/18.04 LTS server. Follow steps below to install Percona Toolkit on Ubuntu 20.04/18.04.
Step 1: Download Percona Repository file
Download the repository file using the commands:
sudo apt update && sudo apt -y install gnupg2 wget
wget https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb
Step 2: Install Percona repository package
Once the repository file is downloaded, install it with the dpkg
command:
sudo dpkg -i percona-release_latest.$(lsb_release -sc)_all.deb
You should get an output similar to below:
Selecting previously unselected package percona-release.
(Reading database ... 104707 files and directories currently installed.)
Preparing to unpack percona-release_latest.focal_all.deb ...
Unpacking percona-release (1.0-27.generic) ...
Setting up percona-release (1.0-27.generic) ...
* Enabling the Percona Original repository
<*> All done!
==> Please run "apt-get update" to apply changes
* Enabling the Percona Release repository
<*> All done!
==> Please run "apt-get update" to apply changes
The percona-release package now contains a percona-release script that can enable additional repositories for our newer products.
For example, to enable the Percona Server 8.0 repository use:
percona-release setup ps80
Note: To avoid conflicts with older product versions, the percona-release setup command may disable our original repository for some products.
For more information, please visit:
https://www.percona.com/doc/percona-repo-config/percona-release.html
Step 3: Install Percona Toolkit on Ubuntu 20.04/18.04
Finally, update your local apt cache and install Percona Toolkit:
sudo apt update
sudo apt install percona-toolkit
Agree to software installation:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libdbd-mysql-perl libdbi-perl libidn11 libio-socket-ssl-perl libmysqlclient21 libnet-libidn-perl libnet-ssleay-perl libterm-readkey-perl mysql-common perl-openssl-defaults
Suggested packages:
libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl
The following NEW packages will be installed:
libdbd-mysql-perl libdbi-perl libidn11 libio-socket-ssl-perl libmysqlclient21 libnet-libidn-perl libnet-ssleay-perl libterm-readkey-perl mysql-common percona-toolkit perl-openssl-defaults
0 upgraded, 11 newly installed, 0 to remove and 71 not upgraded.
Need to get 18.9 MB of archives.
After this operation, 72.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Below is a list of Percona Tools provided by the Toolkit.
- pt-align
- pt-archiver
- pt-config-diff
- pt-deadlock-logger
- pt-diskstats
- pt-duplicate-key-checker
- pt-fifo-split
- pt-find
- pt-fingerprint
- pt-fk-error-logger
- pt-heartbeat
- pt-index-usage
- pt-align
- pt-archiver
- pt-config-diff
- pt-deadlock-logger
- pt-diskstats
- pt-duplicate-key-checker
- pt-fifo-split
- pt-find
- pt-fingerprint
- pt-fk-error-logger
- pt-heartbeat
- pt-index-usage
- pt-ioprofile
- pt-kill
- pt-mext
- pt-mongodb-query-digest
- pt-mongodb-summary
- pt-mysql-summary
- pt-online-schema-change
- pt-pmp
- pt-query-digest
- pt-secure-collect
- pt-show-grants
- pt-sift
- pt-slave-delay
- pt-slave-find
- pt-slave-restart
- pt-stalk
- pt-summary
- pt-table-checksum
- pt-table-sync
- pt-table-usage
- pt-upgrade
- pt-variable-advisor
- pt-visual-explain
- pt-slave-find
- pt-slave-restart
- pt-stalk
- pt-summary
- pt-table-checksum
- pt-table-sync
- pt-table-usage
- pt-upgrade
- pt-variable-advisor
- pt-visual-explain
You now have the Percona Toolkit installed on Ubuntu 18.04. Use the links above to find the Tool description and usage examples.
Example: Pull MySQL Performance summary
pt-mysql-summary conveniently summarizes the status and configuration of a MySQL database server so that you can learn about it at a glance.
pt-mysql-summary --host localhost --user root --ask-pass
When prompted for the MySQL root user password, provide it to get stats.
You can as well redirect the output to a file.
pt-mysql-summary --host localhost --user root --ask-pass > mysql-summary.txt
See sample output below:
# Percona Toolkit MySQL Summary Report ####################### System time | 2018-12-09 07:10:54 UTC (local TZ: EAT +0300) # Instances ################################################## Port Data Directory Nice OOM Socket ===== ========================== ==== === ====== # MySQL Executable ########################################### Path to executable | /usr/sbin/mysqld Has symbols | Yes # Slave Hosts ################################################ No slaves found # Report On Port 3306 ######################################## User | root@localhost Time | 2018-12-09 10:10:54 (EAT) Hostname | centos-db Version | 10.3.10-MariaDB MariaDB Server Built On | Linux x86_64 Started | 2018-12-02 02:01 (up 7+08:08:58) Databases | 8 Datadir | /var/lib/mysql/ Processes | 1 connected, 6 running Replication | Is not a slave, has 0 slaves connected Pidfile | /var/lib/mysql/cnetos-db.pid (exists) # Processlist ################################################ Command COUNT(*) Working SUM(Time) MAX(Time) ------------------------------ -------- ------- --------- --------- Daemon 5 5 0 0 Query 1 1 0 0 User COUNT(*) Working SUM(Time) MAX(Time) ------------------------------ -------- ------- --------- --------- root 1 1 0 0 system user 5 5 0 0 Host COUNT(*) Working SUM(Time) MAX(Time) ------------------------------ -------- ------- --------- --------- 5 5 0 0 localhost 1 1 0 0 db COUNT(*) Working SUM(Time) MAX(Time) ------------------------------ -------- ------- --------- --------- NULL 6 6 0 0 State COUNT(*) Working SUM(Time) MAX(Time) ------------------------------ -------- ------- --------- --------- Init 1 1 0 0 InnoDB purge coordinator 1 1 0 0 InnoDB purge worker 3 3 0 0 InnoDB shutdown handler 1 1 0 0 # Status Counters (Wait 10 Seconds) ########################## .....
Recommended articles: