Menu

How to Install Redis on CentOS Stream 9: A Step-by-Step Tutorial

Install Redis on CentOS Stream 9 from AppStream with DNF, start the service, verify it with redis-cli, and locate its configuration file.

Posted on By Updated on
On this page

CentOS Stream 9 provides the Redis server package in its AppStream repositories. Package availability and version can vary by architecture and enabled repository state, so check the candidate on your system before installing. The CentOS Stream 9 AppStream mirror provides architecture-specific package indexes.

Prerequisites

Before you begin, make sure you have the following:

  1. A CentOS Stream 9 server with root or sudo access.
  2. An SSH client for connecting to your server.
  3. Basic familiarity with Linux command-line operations.

Step 1: Check the Redis package

Check which Redis package and version are available from the enabled repositories:

sudo dnf info redis

This guide uses the Redis package provided by CentOS Stream 9 AppStream; it does not require enabling EPEL. Apply general operating-system updates separately according to the server’s maintenance plan.

Step 2: Install Redis

Install the available redis package:

sudo dnf install redis

DNF installs Redis and its dependencies from the enabled CentOS repositories.

Step 3: Start and Enable Redis

To ensure that Redis starts automatically when your server boots up and is currently running, enable and start the Redis service with the following commands:

sudo systemctl start redis
sudo systemctl enable redis

To check the status of the Redis service, use:

sudo systemctl status redis

If Redis is functioning without issues, you should see “active (running)” in the output.

Step 4: Configure Redis (Optional)

If you need to change Redis settings, edit /etc/redis/redis.conf, the configuration file supplied by the CentOS Stream 9 package:

Use your preferred text editor, such as Nano or Vim, to edit the configuration file:

sudo nano /etc/redis/redis.conf

Make the necessary changes, save the file, and then restart the Redis service for the changes to take effect:

sudo systemctl restart redis

Redis is designed for trusted clients. If remote access is required, bind it only to an appropriate private interface and restrict the firewall to trusted clients. Do not expose port 6379 directly to the public internet. See Redis’s network security guidance.

Step 5: Test Redis

To test if Redis is working correctly, use the redis-cli tool to connect to the Redis server:

redis-cli

You should see a Redis prompt. From here, you can start executing Redis commands and interacting with the server. For example, you can set a key-value pair:

set mykey "Hello, Redis!"

To retrieve the value, use:

get mykey

If everything is set up correctly, you will see “Hello, Redis!” as the output.

Conclusion

You’ve successfully installed Redis on your CentOS Stream 9 server, and you’re now ready to leverage this high-performance data store for various applications. Redis offers a wide range of use cases, including caching, real-time analytics, and more. To make the most of this powerful tool, consider securing your Redis server and configuring it according to your specific requirements. Enjoy using Redis on CentOS Stream 9!