In this blog, we continue from where we left off in the previous post, InnoDB Cluster Setup: Building a 3-Node High Availability Architecture, where we demonstrated how to set up a MySQL InnoDB Cluster with three nodes to achieve high availability.

Here, we walk through the step-by-step process of performing a rolling upgrade of that cluster to MySQL version 8.4. This method ensures high availability and minimal disruption by upgrading one node at a time, starting with the secondary nodes and ending with the primary. Along the way, we address key considerations such as managing group replication behavior, monitoring cluster status, handling failovers, and upgrading cluster metadata. 

Step 1: Verify cluster health and identify node roles before upgrade

Before initiating the upgrade process, it is essential to verify the current status of the InnoDB Cluster to ensure everything is functioning correctly. This involves checking the overall health of the cluster and identifying the role of each node specifically, which node is the primary and which ones are the secondary. As a best practice, upgrades should begin with the secondary nodes to minimize the impact on the cluster’s availability. The cluster.status() command provides a clear overview of node roles, replication status, and version details, helping you plan a smooth and controlled upgrade path.

Step 2: Ensure all users are using caching_sha2_password for secure and seamless upgrades

Upgrading all users in an InnoDB Cluster to use the caching_sha2_password plugin is recommended when moving from MySQL 8.0 to 8.4 because it is the default authentication method in newer versions, offering improved security, performance, and compatibility. It ensures seamless operation of MySQL Router, Group Replication, and other cluster components while also avoiding potential issues during upgrades. This plugin uses stronger SHA-256-based hashing and supports faster logins with caching, making it a more secure and efficient choice over the legacy mysql_native_password.

Step 3: Prepare the secondary node (ArunClusterND3) for upgrade by configuring the MySQL APT repository

To begin the upgrade process on a secondary node, you must first configure the official MySQL APT repository. This involves downloading and installing the MySQL APT configuration package, which allows your system to access and install the latest MySQL 8.4 packages directly from Oracle’s trusted repository. According to the official MySQL documentation, this step ensures that all required components, such as MySQL Server, Shell, and Router, are properly registered and updated during the upgrade process.

The server is running Ubuntu 24.04.2 LTS, and the MySQL APT repository configuration has been successfully installed. This indicates that the system is ready to proceed with the upgrade to MySQL 8.4 packages.

Step 4: Upgrading MySQL Shell and performing server upgrade checks on secondary node ArunClusterND3

As the first step in the upgrade process, we begin by upgrading the MySQL Shell on the secondary node, ArunClusterND3. This ensures we have the latest tools compatible with MySQL 8.4. After upgrading MySQL Shell, we run the util.check_for_server_upgrade() utility to verify the current server’s readiness for upgrade. This utility scans the server for compatibility issues, deprecated system variables, changes in default values, and privilege warnings that need attention before proceeding. Addressing these findings helps avoid potential problems during the upgrade and ensures a smoother transition from MySQL 8.0 to 8.4.

  1. Upgrading MySQL Shell to the 8.4 version

  1. Connecting to cluster node 

Connect to the cluster node using the command shell.connect() to initiate a connection to the MySQL server as the innoclusteradmin user.

3. Running upgrade compatibility check

Execute util.check_for_server_upgrade() in MySQL Shell to analyze the current MySQL server (version 8.0.42) for potential compatibility issues before upgrading to MySQL 8.4.5.

Fixing all errors reported by the util.check_for_server_upgrade() utility is crucial because any unresolved issues can cause the upgrade to fail or lead to instability in the cluster. Addressing these errors beforehand ensures a successful and smooth upgrade process.

Step 5: Resolving deprecated variable error

As reported by the upgrade check tool, the MySQL system variable binlog_transaction_dependency_tracking is currently set to WRITESET and persisted; however, it is deprecated and will be removed in MySQL 8.4. If this variable remains set, the MySQL 8.4 server will fail to start. To resolve this issue, verify the current value and persistence of the variable, then reset it. Clearing this persisted setting ensures compatibility with MySQL 8.4 and allows the upgrade process to continue without errors.

Step 6: Disable automatic group replication startup before upgrading

Before upgrading to MySQL 8.4, it’s a good precaution to set group_replication_start_on_boot to OFF. This prevents automatic startup of Group Replication after a server restart, allowing you to manually verify and control the cluster’s behavior post-upgrade.

Step 7: Upgrading to MySQL Server 8.4

  1. Checking available MySQL Server versions

The apt-cache madison mysql-server command lists all available versions of the MySQL server package from configured repositories, showing the source and version numbers for upgrade planning.

  1. Stopping the MySQL service

systemctl stop mysql is used to safely stop the MySQL server service before performing the upgrade task.

  1. Checking MySQL InnoDB cluster status

The cluster.status() command in MySQL Shell shows the current health and topology of the InnoDB cluster, including the roles of nodes, replication status, and any connection issues with cluster members. Since we have stopped the ArunClusterND3 node for an upgrade, its status is reflected as “status”: “(MISSING)”.

  1. Upgrading MySQL Server

To upgrade the MySQL Server, execute the following command:

This command refreshes the package list and upgrades the installed MySQL server package to the latest version available from the configured MySQL APT Repository, ensuring your node runs the most recent MySQL release.

Here, the node ArunClusterND3 has successfully upgraded to version 8.4.5.

  1. Verify the cluster status after upgrade with group replication disabled

The output of cluster.status() shows ArunClusterND3 in the cluster with “version”: “8.4.5”, but its “memberState” is “OFFLINE” and “status” is “(MISSING)”. This is expected because we previously set group_replication_start_on_boot to OFF for safety, preventing the automatic startup of group replication and allowing manual control after the upgrade. We can confirm that the node ArunClusterND3 has been successfully upgraded to version 8.4.5.

  1. Re-enabling group replication startup

After verifying the upgrade, we re-enable automatic Group Replication startup to ensure the node automatically rejoins the cluster after reboots.

7. Restart the MySQL service

Restart the MySQL service, applying the persisted configuration change and allowing the upgraded node to rejoin the cluster.

8. Verifying full cluster health post-upgrade
Running cluster.status() now shows that ArunClusterND3 is “ONLINE” and fully integrated into the cluster with version 8.4.5. The cluster status is “OK”, confirming it is healthy and tolerant to one member failure — a successful upgrade and reintegration.

To continue the rolling upgrade process, follow the same sequence of steps for the second secondary node in the cluster, ArunClusterND2. This includes stopping the MySQL service, upgrading the MySQL server to version 8.4.5, verifying and clearing any deprecated persisted variables (if any), ensuring group_replication_start_on_boot is set to OFFbefore upgrade, and then setting it back to ON after a successful restart. Once the node is restarted, it should automatically rejoin the cluster. Finally, use cluster.status() to confirm that ArunClusterND2 is back ONLINE, now running version 8.4.5, and the cluster remains healthy and tolerant.

Step 8: Upgrading the primary node (ArunClusterND1) to MySQL 8.4.5

Now that both secondary nodes have been successfully upgraded to MySQL 8.4.5 and rejoined the cluster, it’s time to upgrade the primary node, ArunClusterND1. This step follows the same upgrade procedure: stop the MySQL service, perform the package upgrade, check and clear any deprecated persisted variables if necessary, and ensure that group_replication_start_on_boot is set to OFF before restarting. After the upgrade, set the variable back to ON and restart the service. Once the node comes back online, verify with cluster.status() to ensure that ArunClusterND1 is now running version 8.4.5 and that the cluster is fully ONLINE and tolerant to failures.

Step 9: Observing automatic primary re-election during upgrade

When the primary node ArunClusterND1 was gracefully shut down for upgrade, the MySQL InnoDB Cluster automatically detected the unavailability and marked its status as “(MISSING)”. As part of the built-in high availability mechanism, the cluster elected a new primary node, and ArunClusterND3, which was already upgraded to MySQL 8.4.5, was promoted to “memberRole”: “PRIMARY”. This seamless promotion ensures continued write availability and cluster functionality during the upgrade process. It demonstrates the cluster’s fault-tolerant design and the importance of upgrading secondary nodes first to support a smooth primary failover.

Step 10: Final node upgrade and cluster validation

After successfully upgrading the ArunClusterND1 node to MySQL 8.4.5, we have now completed the upgrade process for all nodes in the InnoDB Cluster. A quick check using MySQL Shell confirms that each node ArunClusterND1, ArunClusterND2, and ArunClusterND3 is ONLINE, with ArunClusterND3 currently acting as the PRIMARY. The cluster status shows “OK” with fault tolerance for up to one failure, indicating a healthy and fully operational cluster running on the latest version. This concludes the rolling upgrade to MySQL 8.4.5 with no downtime or service disruption.

Step 11: Notice: Metadata version mismatch warning

While reconnecting to the cluster after the upgrade, you might encounter the following warning in MySQL Shell:

Solution: Upgrading cluster metadata

This message indicates that the cluster metadata schema is outdated and needs to be upgraded to match the requirements of the MySQL Shell version 8.4.5.

To resolve the warning and restore full AdminAPI functionality, upgrade the metadata schema from version 2.1.0 to 2.2.0. This process also automatically updates the grants for any MySQL Router accounts created during bootstrapping and then cleans up a backup of the metadata to ensure a safe upgrade.

Conclusion: Upgrading a MySQL InnoDB cluster to version 8.4

Upgrading a MySQL InnoDB cluster to version 8.4 requires careful planning and execution to ensure minimal downtime and maintain cluster stability. You can achieve a smooth transition by following the step-by-step process—safely upgrading secondary nodes first, controlling group replication startup, and finally upgrading the primary node. Additionally, addressing deprecations, adjusting configuration variables, and upgrading cluster metadata are crucial to fully leverage the new version’s features and maintain cluster health. With these best practices, your MySQL cluster will be robust, up-to-date, and ready to support your applications reliably. To dive deeper into MySQL upgrade testing, especially using tools like pt-upgrade and checkForServerUpgrade, check out this detailed post.

InnoDB Cluster Upgrade

 

Subscribe
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments