1. Home
  2. Docs
  3. Knowledgebase and Tutorials
  4. Linux
  5. Lock a Specific Database Version

Lock a Specific Database Version

Version locking ensures that a specific package version remains unchanged during system updates. It’s useful when you want to maintain stability or avoid unexpected changes due to global package updates like yum update or apt upgrade.

Besides, for database systems like MySQL, MariaDB and Percona, upgrading a database package will usually require additional steps to run the mysql_upgrade script and also to verify the integrity of a database node before an upgrade is complete, similar to other database systems like PostgreSQL/TimescaleDB where you need to perform the pg_upgrade command afterward.

Using APT

To pin to a specific version, one would create a definition file under /etc/apt/preferences.d/ with the following lines on all database nodes.

In this example, suppose we want to pin Percona XtraDB Cluster 5.7 to a specific version “5.7.42-31.65-1.focal”. One would create a definition file called /etc/apt/preferences.d/percona-xtradb-cluster with the following content:

Package: percona-xtradb-cluster-57
Pin: version 5.7.42-31.65-1.focal
Pin-Priority: 999

Package: percona-xtradb-cluster-client-5.7
Pin: version 5.7.42-31.65-1.focal
Pin-Priority: 999

Package: percona-xtradb-cluster-common-5.7
Pin: version 5.7.42-31.65-1.focal
Pin-Priority: 999

Package: percona-xtradb-cluster-server-5.7
Pin: version 5.7.42-31.65-1.focal
Pin-Priority: 999

To double-check if the packages are included in the apt upgrade command, run this:

apt list --upgradable

Make sure percona-xtradb-cluster-*5.7 packages are not listed in the output above.

Using YUM

For yum, you can use the yum-versionlock plugin to lock a package to a specific version. Here’s how:

Install the plugin:

For RHEL 7:

sudo yum install yum-plugin-versionlock

For RHEL 8 and 9:

sudo yum install python3-dnf-plugin-versionlock

Create or lock the version of a package (e.g., gcc group):

sudo yum versionlock gcc-*

Remember that some applications require specific package versions, and updating all packages together may cause issues. Use these commands to manage locked packages:

To display the list of locked packages:

sudo yum versionlock list

To clear the list of locked packages:

sudo yum versionlock clear

To remove the lock on a specific package:

sudo yum versionlock delete package_name

Using DNF

Here is how to pin packages to specific versions using DNF (the package manager commonly used in Fedora, CentOS, and Red Hat Enterprise Linux).

Locking a Specific Version Using DNF:
Install the DNF Plugin: First, ensure you have the necessary plugin installed. The plugin we need is called dnf-command(versionlock).

For RHEL 7:

sudo yum install yum-plugin-versionlock

For RHEL 8 and 9:

sudo yum install python3-dnf-plugin-versionlock

Lock the Currently Installed Version: To lock the currently installed version of a package, use the following command:

sudo dnf versionlock add package_name

Removing the Version Lock: If you need to remove the version lock for a package, use:

sudo dnf versionlock delete package_name

Notes

Note that ClusterControl also supports upgrading the database to another minor version (e.g, MySQL 5.7.13 to MySQL 5.7.20) by using Manage Upgrades. However, you have to unlock/unpin the database packages beforehand.

Was this article helpful to you? Yes No