Percona
This is only for Core-Managed Linux servers, Not compatible with cPanel!!
Installing Percona on a core-managed server
This guide walks you through installing Percona Server for MySQL, a high-performance, drop-in replacement for MySQL. It offers significant performance and monitoring improvements, especially for InnoDB, without requiring extensive configuration changes.
❗️ Warning: This documentation is for Core-Managed Linux servers only and is NOT compatible with cPanel. Attempting this on a cPanel server will break your MySQL installation.
Prerequisite: GPG key issues
If you encounter a GPG key error while using the Percona repository, it usually means the keys on your system are outdated.
Bash
The GPG keys listed for the "Percona-Release YUM repository - x86_64" repository are already installed but they are not correct for this package.
To fix this, simply update the percona-release package to fetch the latest keys:
For CentOS/AlmaLinux:
Bash
yum update percona-release
Upgrading from MySQL to Percona
If you’re switching from an existing MySQL or MariaDB installation, follow these steps carefully.
1. Back up your databases
Before you begin, always create a backup of your existing databases. You can use mysqldump to create SQL files or, with the database service stopped, use rsync to copy the entire data directory (/var/lib/mysql).
If you’re upgrading to a similar or newer version (e.g., MySQL 5.5 to Percona 5.5 or Percona 8.0), you can typically leave the data directory in place. For a downgrade, the data directory must be removed and restored from a backup.
2. Remove existing MySQL/MariaDB packages
You must remove the old database server packages before installing Percona.
On AlmaLinux / Rocky Linux / CentOS 8+:
Bash
dnf remove mysql-server mysql mariadb-server
On CentOS 7:
Bash
yum remove mysql-server mysql mariadb-server
If you installed MySQL from the community repository, you might need to run:
Bash
yum remove MySQL-*
On Ubuntu / Debian:
Bash
apt-get autoremove --purge mysql-server*
Installing Percona Server
Now you’re ready to install Percona. The first step is to add the official Percona software repository.
1. Add the Percona Repository
The percona-release tool makes it easy to manage the repository configuration.
On AlmaLinux / CentOS:
Bash
dnf install -y https://repo.percona.com/yum/percona-release-latest.noarch.rpm
On Ubuntu / Debian:
Bash
# Download the repository package
curl -O https://repo.percona.com/apt/percona-release_latest.generic_all.deb
# Install the package
apt install gnupg2 lsb-release ./percona-release_latest.generic_all.deb
# Update the local cache
apt-get update
2. Configure the repository
Next, use the percona-release command to enable the repositories for the specific version you want to install.
First, enable the main repository for Percona Server and the repository for its powerful tools.
Bash
# Enable the main software repository
percona-release enable original release
# Enable the repository for tools like XtraBackup and Percona Toolkit
percona-release enable tools release
Now, enable the specific version of Percona Server you wish to install. For example, to install Percona Server 8.0:
Bash
# Enable the Percona Server 8.0 repository
percona-release setup ps80
You can replace ps80 with other versions like ps-84-lts for version 8.4.
3. Install Percona packages
With the repository configured, you can now install the Percona Server packages.
On AlmaLinux / CentOS:
Bash
# Install the Percona server
dnf install percona-server-server
# (Optional) Install the Percona Toolkit and MySQL Shell
dnf install percona-toolkit percona-mysql-shell
On Ubuntu / Debian:
If this is a brand new server that has never had MySQL or a variant installed, you must first install mysql-common.
Bash
# Only for fresh servers!
apt-get install mysql-common
Now, install Percona Server.
Bash
# Install the Percona server
apt install percona-server-server
# (Optional) Install the Percona Toolkit and MySQL Shell
apt install percona-toolkit percona-mysql-shell
4. Start the database server
After a successful installation, start the MySQL service.
Bash
systemctl start mysql
systemctl enable mysql # To start on boot
systemctl status mysql # To check its status
On a fresh installation, Percona will generate a temporary root password. You can find it in the error log:
Bash
grep 'temporary password' /var/log/mysqld.log
Log in and change the root password immediately.
Fun with Percona: Performance features
Percona includes unique features that provide deeper insights and performance enhancements.
Query response time statistics
This feature provides a histogram of query execution times, helping you identify performance bottlenecks.
To enable it, add the following line to your my.cnf file (usually /etc/my.cnf or /etc/mysql/my.cnf) under the [mysqld] section:
Ini, TOML
[mysqld]
user_response_time_stats = ON
After restarting MySQL, you can query the information_schema:
SQL
SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
Example Output:
+------------+-------+------------+
| time | count | total |
+------------+-------+------------+
| 0.000001 | 372 | 0.000000 |
| 0.000010 | 9577 | 0.011632 |
| 0.000100 | 10325 | 0.650819 |
| 0.001000 | 8684 | 4.597265 |
| 0.010000 | 876 | 4.301845 |
| 0.100000 | 470 | 9.036130 |
| 1.000000 | 16 | 2.476812 |
+------------+-------+------------+
This output shows that 16 queries took between 0.1 and 1.0 seconds to execute, while 470 queries took between 0.01 and 0.1 seconds.
XtraDB storage engine
XtraDB is Percona’s enhanced, drop-in replacement for the InnoDB storage engine. If you use InnoDB tables with Percona Server, you are automatically using XtraDB’s performance and reliability improvements. To get the most out of it, ensure your InnoDB settings are properly tuned.
Performance tuning recommendations
Fine-tuning your server’s configuration file (my.cnf) can unlock significant performance gains.
innodb_buffer_pool_size
This is one of the most important settings for any database using InnoDB/XtraDB. It defines the amount of memory used to cache table data and indexes. On a dedicated database server, this can be set to 70-80% of the server’s total RAM.
Ini, TOML
# For a dedicated server with 8GB of RAM, a 5-6GB buffer pool is a good start.
innodb_buffer_pool_size = 6G
For servers with large buffer pools (over 1GB), you should also set innodb_buffer_pool_instances to improve concurrency. A good rule of thumb is one instance per GB of buffer pool, up to 64.
Ini, TOML
# Split the 6GB pool into 6 instances.
innodb_buffer_pool_instances = 6
innodb_lazy_drop_table
When innodb_file_per_table is enabled, dropping a table can cause a server stall as MySQL scans the entire buffer pool to purge pages. Percona’s lazy drop feature defers this work, preventing stalls.
This feature is enabled by default in Percona Server 5.6+ when innodb_file_per_table is ON. You can verify it is enabled:
Ini, TOML
innodb_lazy_drop_table = 1
innodb_adaptive_flushing_method
Percona improves upon MySQL’s default I/O flushing behavior, which can cause performance spikes. Percona’s adaptive flushing adjusts to your workload automatically. The default method is estimate, which works well for most workloads.
However, if you are using SSD storage, you should switch to the keep_average method, which is designed for low-latency drives.
Ini, TOML
innodb_adaptive_flushing_method = keep_average
Monitoring with SHOW ENGINE INNODB STATUS
This command provides a wealth of real-time information about your XtraDB engine, including buffer pool usage, I/O, logs, and transaction status. It is an invaluable tool for diagnosing performance issues.
SQL
SHOW ENGINE INNODB STATUSG
The output is extensive but provides critical insights for advanced troubleshooting. The Percona blog offers an excellent walkthrough of its output.