§ Percona Toolkit
Percona Toolkit (abbreviated as PT tools) is a set of advanced command-line tools for managing MySQL/GreatSQL. It can be used to perform various MySQL/GreatSQL and system tasks that are difficult to perform manually. Its functions include checking the data consistency of source-replica replication, checking duplicate indexes, locating table files with high I/O usage, online DDL, etc. DBAs who are familiar with and master the PT tools will greatly improve work efficiency.
Tip
$ is the command prompt, and greatsql> is the GreatSQL database prompt.
§ Installing with a Package Manager
For Debian or Ubuntu:
sudo apt-get install percona-toolkit1For RHEL or CentOS:
sudo yum install percona-toolkit1
§ Installing with the TAR Package
Download Percona Toolkit (opens new window) by selecting the appropriate version and specification.
Tip
Select the Percona Toolkit package that suits your CPU architecture and operating system version.
Create the pt folder and save the downloaded installation package there.
mkdir /usr/local/pt
And check the sha256sum code to ensure integrity.
sha256sum -c percona-toolkit-3.5.7_x86_64.tar.gz.sha256sum
View the result
$ sha256sum -c percona-toolkit-3.5.7_x86_64.tar.gz.sha256sum
percona-toolkit-3.5.7_x86_64.tar.gz: OK
2
Decompress the percona-toolkit file.
tar -xvf percona-toolkit-3.5.7_x86_64.tar.gz
Add percona-toolkit to the environment variables.
echo 'export PATH=/usr/local/pt/percona-toolkit-3.5.7/bin:$PATH' >> ~/.bash_profile
Make the environment variables take effect.
source ~/.bash_profile
Select a tool to view the version number to confirm the installation is successful.
pt-online-schema-change --version
View the result
$ pt-online-schema-change --version
pt-online-schema-change 3.5.7
2
§ Installing with the RPM Package
The demonstration environment below is Centos7 - X86_64 architecture - ldd (GNU libc) 2.17.
Download the Percona Toolkit 3.5.7 version CentOS 7.x RPM package.
$ ls
percona-toolkit-3.5.7-1.el7.x86_64.rpm
2
Install Percona Toolkit with the rpm command. If there are missing dependency errors at this time, install them with YUM.
rpm -ivh --nodeps percona-toolkit-3.5.7-1.el7.x86_64.rpm
Select a tool to view the version number to confirm the installation is successful.
pt-online-schema-change --version
View the result
$ pt-online-schema-change --version
pt-online-schema-change 3.5.7
2
§ Tools Included in Percona Toolkit
Percona Toolkit version 3.5.7 has 39 tools. These 39 tools are divided into seven categories (practical, configuration, monitoring, system, development, replication, performance)
$ ls
pt-align pt-fingerprint pt-mext pt-query-digest pt-summary
pt-archiver pt-fk-error-logger pt-mongodb-index-check pt-secure-collect pt-table-checksum
pt-config-diff pt-galera-log-explainer pt-mongodb-query-digest pt-show-grants pt-table-sync
pt-deadlock-logger pt-heartbeat pt-mongodb-summary pt-sift pt-table-usage
pt-diskstats pt-index-usage pt-mysql-summary pt-slave-delay pt-upgrade
pt-duplicate-key-checker pt-ioprofile pt-online-schema-change pt-slave-find pt-variable-advisor
pt-fifo-split pt-k8s-debug-collector pt-pg-summary pt-slave-restart pt-visual-explain
pt-find pt-kill pt-pmp pt-stalk
2
3
4
5
6
7
8
9
§ Practical
| Tool Command | Tool Purpose |
|---|---|
| pt-align | Align the output of other tools with columns |
| pt-archiver | Archive rows in a table to another table or file |
| pt-find | Find tables and execute commands |
| pt-fingerprint | Convert queries to ciphertext |
| pt-kill | Kill SQL statements that meet the conditions |
| pt-k8s-debug-collector | Collect debug data (logs, resource status, etc.) from k8s/OpenShift clusters |
| pt-secure-collect | Collect, clean, package, and encrypt data |
§ Configuration
| Tool Command | Tool Description |
|---|---|
| pt-config-diff | Compare database configuration files and parameters |
| pt-mysql-summary | Summarize MySQL/GreatSQL configuration and STATUS |
| pt-variable-advisor | Analyze parameters and make suggestions |
§ Monitoring
| Tool Command | Tool Description |
|---|---|
| pt-deadlock-logger | Extract and record MySQL/GreatSQL deadlocks |
| pt-fk-error-logger | Extract and record foreign key information |
| pt-mext | View STATUS sample information in parallel |
| pt-query-digest | Analyze query logs and generate reports |
| pt-mongodb-summary | Collect information about MongoDB clusters |
| pt-pg-summary | Collect information about PostgreSQL clusters |
§ System
| Tool Command | Tool Description |
|---|---|
| pt-diskstats | View system disk status |
| pt-fifo-split | Simulate splitting files and output |
| pt-ioprofile | Query process I/O and print an I/O activity table |
| pt-sift | Browse files created by pt-stalk |
| pt-stalk | Collect diagnostic data when problems occur |
| pt-summary | Collect and display system overview |
§ Development
| Tool Command | Tool Description |
|---|---|
| pt-duplicate-key-checker | List and delete duplicate indexes and foreign keys |
| pt-online-schema-change | Modify table structure online |
| pt-show-grants | Normalize and print grants |
| pt-upgrade | Execute queries on multiple servers and compare differences |
§ Replication
| Tool Command | Tool Description |
|---|---|
| pt-heartbeat | Monitor MySQL/GreatSQL replication delay |
| pt-slave-delay | Set the time the replica lags behind the source |
| pt-slave-find | Find and print all MySQL/GreatSQL replication hierarchy relationships |
| pt-slave-restart | Monitor Slave errors and try to restart the Slave |
| pt-table-checksum | Verify source-replica replication consistency |
| pt-table-sync | Efficiently synchronize table data |
| pt-galera-log-explainer | Filter, aggregate, and summarize multiple Galera logs |
§ Performance
| Tool Command | Tool Description |
|---|---|
| pt-index-usage | Analyze index usage in logs and produce reports |
| pt-pmp | Track query results and summarize tracking results |
| pt-table-usage | Analyze queries in logs and analyze table usage |
| pt-visual-explain | Format the execution plan |
| pt-mongodb-index-check | Perform MongoDB index checks |
| pt-mongodb-query-digest | Report query usage statistics by aggregating queries from the MongoDB query analyzer |
Scan the QR code to follow our WeChat Official Account
