How to use pt-mysql-summary to understand your MySQL database server better?

Virinchi T
Fournine Cloud
Published in
4 min readOct 10, 2023

--

Monitoring and maintaining a MySQL database server is crucial for its optimal performance and reliability. Percona Toolkit is a set of command-line tools that can help database administrators gain valuable insights into their MySQL servers. In this guide, we will focus on one of these tools, pt-mysql-summary, and show you how to install it, run it, and understand its output.

Step 1: Installing Percona Toolkit on Linux

Percona Toolkit can be easily installed on Linux systems using package managers like apt or yum. Here are the steps for installing it:

For Ubuntu/Debian:

sudo apt-get update
sudo apt-get install percona-toolkit

For CentOS/RHEL:

sudo yum install epel-release
sudo yum install percona-toolkit

Step 2: Running pt-mysql-summary

Once Percona Toolkit is installed, you can use pt-mysql-summary to generate a summary report of your MySQL server.

Here's how to run it:

pt-mysql-summary --user=<username> --password=<password> --host=<hostname>

Replace <username>, <password>, and <hostname> with your MySQL server's credentials. This command will connect to your MySQL server and collect various information.

Step 3: Understanding the Output

pt-mysql-summary generates a comprehensive report with valuable information about your MySQL server.

Sample Report:

Here’s a sample pt-mysql-summary report to illustrate what the output might look like:

# Percona Toolkit MySQL Summary Report #######################
System time | 2023-10-08 14:30:00 UTC
(local TZ: EDT -0400)

# Instances ##################################################
Port Data Directory Nice OOM Socket
===== ========================== ==== === ======
3306 /var/lib/mysql 0 0 /var/run/mysqld/mysqld.sock

# Report On Port 3306 #######################################
User | admin@%
Time | 2023-10-08 10:30:00 (EDT)
Hostname | localhost.localdomain
Version | 8.0.27 MySQL Community Server (GPL)
Built On | linux2.6 x86_64
Started | 2023-10-05 19:45 (up 2+18:45:15)
Databases | 5
Datadir | /var/lib/mysql/
Processes | 2 connected, 1 running
Replication | Is not a slave, has 0 slaves connected
Pidfile | /var/run/mysqld/mysqld.pid (exists)

# Processlist ################################################

Command COUNT(*) Working SUM(Time) MAX(Time)
------------------------------ -------- ------- --------- ---------
Binlog Dump 1 1 150000 150000
Query 1 1 0 0

User COUNT(*) Working SUM(Time) MAX(Time)
------------------------------ -------- ------- --------- ---------
msandbox 2 2 150000 150000

Host COUNT(*) Working SUM(Time) MAX(Time)
------------------------------ -------- ------- --------- ---------
localhost 2 2 150000 150000

db COUNT(*) Working SUM(Time) MAX(Time)
------------------------------ -------- ------- --------- ---------
NULL 2 2 150000 150000

State COUNT(*) Working SUM(Time) MAX(Time)
------------------------------ -------- ------- --------- ---------
Master has sent all binlog to 1 1 150000 150000
NULL 1 1 0 0

# Status Counters (Wait 10 Seconds) ##########################
Variable Per day Per second 10 secs
----------------------------------- -------- ------- ---------
Binlog_cache_disk_use 4
Binlog_cache_use 80
Bytes_received 15000000 175 200
Bytes_sent 15000000 175 2000
Com_admin_commands 1
...

# Table cache ################################################
Size | 400
Usage | 15%

# Key Percona Server features ################################
Table & Index Stats | Not Supported
Multiple I/O Threads | Enabled
Corruption Resilient | Not Supported
...

# Plugins ####################################################
InnoDB compression | ACTIVE

# Query cache ################################################
query_cache_type | ON
Size | 0.0
Usage | 0%
HitToInsertRatio | 0%

# Schema #####################################################

Database Tables Views SPs Trigs Funcs FKs Partn
------------------ ------ ----- --- ----- ----- ----- -----
mysql 24 0 5 6 2 17
mydb 5 0 2 0 3 1

...

# Noteworthy Technologies ####################################
Full Text Indexing | Yes
Geospatial Types | No
Foreign Keys | Yes
Partitioning | No
...

# InnoDB #####################################################
Version | 8.0.27
Buffer Pool Size | 16.0M
Buffer Pool Fill | 100%
...

# MyISAM #####################################################
Key Cache | 16.0M
Pct Used | 10%
Unflushed | 0%

# Security ###################################################
Users | 2 users, 0 anon, 0 w/o pw, 0 old pw
Old Passwords | OFF

# Binary Logging #############################################
Binlogs | 1
Zero-Sized | 0
Total Size | 21.8M
binlog_format | STATEMENT
...

# Noteworthy Variables #######################################
Auto-Inc Incr/Offset | 1/1
default_storage_engine | InnoDB
flush_time | 0
...

# Configuration File #########################################
Config File | /etc/mysql/my.cnf

[client]
user = msandbox
password = msandbox
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld]
port = 3306
socket = /var/run/mysqld/mysqld.sock
pid-file = /var/run/mysqld/mysqld.pid
basedir = /usr
datadir = /var/lib/mysql
key_buffer_size = 16M
innodb_buffer_pool_size = 16M
innodb_data_home_dir = /var/lib/mysql
innodb_log_group_home_dir = /var/lib/mysql
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_file_size = 5M
log-bin = mysql-bin
relay_log = mysql-relay-bin
log_slave_updates
server-id = 3306
report-host = 127.0.0.1
report-port = 3306
log-error = mysqld.log
innodb_lock_wait_timeout = 3

# The End ####################################################

Step 4: Interpreting the Report

The report generated by pt-mysql-summary provides you with a snapshot of your MySQL server's health and performance. You can use this information to:

  • Identify hardware limitations (CPU, memory, storage).
  • Spot potential query performance issues.
  • Check if replication is configured.
  • Review InnoDB buffer pool usage.
  • Ensure that server variables are set correctly.

The tool helps you make informed decisions about server maintenance and optimization.

Conclusion:

Percona Toolkit’s pt-mysql-summary is a powerful tool for MySQL database administrators. It simplifies the process of gathering essential information about your MySQL server, making it easier to diagnose issues, optimize performance, and ensure the reliability of your database.

By following the steps outlined in this guide, you can install and run pt-mysql-summary on your Linux system, better understand your MySQL server's behavior, and use the generated reports to keep your database environment healthy and performant.

I hope these steps complete with a sample report, help you learn how to install, use, and interpret pt-mysql-summary effectively. If you have any further questions or need additional information, feel free to ask.

--

--