Upgrading Redis 5 to Redis 6

Redis 6 on Red Hat, Centos, Rocky Linux, and AlmaLinux

Redis is a powerful open source, in-memory database that can be used to cache objects. As such, it can deliver sub-millisecond response times and serve up millions of requests per second for near real-time applications as well as speed up the responsiveness of websites.

While the default package for Linux distributions, including Red Hat, Centos, Fedora, Rocky Linux and AlmaLinux is Redis 5, it is possible to install Redis 6, which brings with it additional security features as well as even more speed.

Note: While this tutorial outlines the steps to upgrade from Redis 5 to Redis 6 on Red Hat based Linux distributions, the same concepts apply to Debian based distributions such as Ubuntu.

RPM packages and AppStream repositories

In addition to RPM packages, AppStream repositories contain modules, which also contain packages with an application, packages with dependency libraries, packages that contain documentation for the application, and packages that supply helper utilities. Modules can also be subdivided into both streams and profiles. Streams are used to organize content by version, while profiles organize content by its purpose.

These concepts are useful when trying to understand what modules are available for projects like Redis. The dnf command can be used to list the available modules for Redis as follows:

# dnf module list redis
Last metadata expiration check: 0:27:45 ago on Wed 27 Oct 2021 08:39:03 PM EDT.
Rocky Linux 8 - AppStream
Name     Stream    Profiles          Summary
redis    5 [d]     common [d]        Redis persistent key-value database
redis    6         common [d]        Redis persistent key-value database

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

Here we see that Redis 5 is the default [d] module. When upgrading to Redis 6, “dnf module reset” will clear any pre-existing installation information. This is a necessary step if Redis 5 was previously installed. Resetting a module returns all the module’s streams to their initial state – neither enabled nor disabled.

# dnf module reset redis
Last metadata expiration check: 0:35:51 ago on Wed 27 Oct 2021 08:39:03 PM EDT.
Dependencies resolved.
=================================================================================
 Package       Architecture       Version       Repository       Size
=================================================================================
Resetting modules:
 redis

Transaction Summary
=================================================================================

Is this ok [y/N]: y

Complete!

If you want a package version that differs from the default stream, that stream must be enabled before packages provided by it can be installed as shown below. The syntax being “package:version”:

# dnf module enable redis:6
Last metadata expiration check: 0:40:44 ago on Wed 27 Oct 2021 08:39:03 PM EDT.
Dependencies resolved.
=================================================================================
 Package       Architecture       Version       Repository       Size
=================================================================================
Enabling module streams:
 redis                            6

Transaction Summary
=================================================================================

Is this ok [y/N]: y
Complete!

At this point, Redis version 6 is now ready to be installed:

 dnf install redis
Last metadata expiration check: 0:43:16 ago on Wed 27 Oct 2021 08:39:03 PM EDT.
Package redis-5.0.3-5.module+el8.4.0+659+cf535ef1.x86_64 is already installed.
Dependencies resolved.
=================================================================================
 Package       Architecture      Version       Repository       Size
=================================================================================
Upgrading:
 redis         x86_64            6.0.9-5       appstream        1.1 M

Transaction Summary
=================================================================================
Upgrade  1 Package

Total download size: 1.1 M
Is this ok [y/N]: y
Downloading Packages:
redis-6.0.9-5.module+el8.4.0+660+a8447b97.x86_64                                                                            1.5 MB/s | 1.1 MB     00:00
---------------------------------------------------------------------------------
Total                                                                                                                             1.3 MB/s | 1.1 MB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
    Preparing        :                                                                                                                            1/1 Running scriptlet: redis-6.0.9-5.module+el8.4.0+660+a8447b97.x86_64                                                                                         1/1 Running scriptlet: redis-6.0.9-5.module+el8.4.0+660+a8447b97.x86_64                                                                                         1/2 Upgrading        : redis-6.0.9-5.module+el8.4.0+660+a8447b97.x86_64                                                                                         1/2 Running scriptlet: redis-6.0.9-5.module+el8.4.0+660+a8447b97.x86_64                                                                                         1/2 Running scriptlet: redis-5.0.3-5.module+el8.4.0+659+cf535ef1.x86_64                                                                                         2/2 Cleanup          : redis-5.0.3-5.module+el8.4.0+659+cf535ef1.x86_64                                                                                         2/2 Running scriptlet: redis-5.0.3-5.module+el8.4.0+659+cf535ef1.x86_64                                                                                         2/2 Verifying        : redis-6.0.9-5.module+el8.4.0+660+a8447b97.x86_64                                                                                         1/2 Verifying        : redis-5.0.3-5.module+el8.4.0+659+cf535ef1.x86_64                                                                                         2/2 Upgraded         : redis-6.0.9-5.module+el8.4.0+660+a8447b97.x86_64

Complete!

Leave a Comment