(Last Updated On: December 9, 2018)

In this blog post, we will cover how to install and use Percona Toolkit on Ubuntu 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 18.04 LTS

The Percona Toolkit is available on the Percona APT repository which can be added to Ubuntu 18.04 LTS server. Follow steps below to install Percona Toolkit on Ubuntu 18.04.

Step 1: Download Percona Repository file

Download the repository file using the commands:

sudo apt install wget
wget https://repo.percona.com/apt/percona-release_0.1-6.$(lsb_release -sc)_all.deb

Step 2: Install Percona repository package

Once the repository file is downloaded, install it with the dpkgcommand:

sudo dpkg -i percona-release_0.1-6.$(lsb_release -sc)_all.deb

You should get an output similar to below:

Selecting previously unselected package percona-release.
(Reading database ... 105206 files and directories currently installed.)
Preparing to unpack percona-release_0.1-6.bionic_all.deb ...
Unpacking percona-release (0.1-6.bionic) ...
Setting up percona-release (0.1-6.bionic) ...

Step 3: Install Percona Toolkit on Ubuntu 18.04

Finally, update your  local apt cache and install Percona Toolkit

sudo apt update
sudo apt-get install percona-toolkit

Below is a list of Percona Tools provided by the Toolkit.

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 | [email protected]
                     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:

Monitoring MySQL / MariaDB with Prometheus in five minutes

Monitoring MySQL and MongoDB with Prometheus and Grafana – PMM

How to install and use mycli on Ubuntu 18.04 – MySQL client with AutoCompletion and Syntax Highlighting