Install and Configure Redis on CentOS 8

Install and Configure Redis on CentOS 8

To install and configure Redis on CentOS 8, you can follow these steps. Redis is an in-memory data structure store that can be used as a database, cache, and message broker.

1. Update System:

Ensure that your system packages are up to date:

sudo yum update

2. Install EPEL Repository:

Redis is available in the EPEL repository, so you need to install it:

sudo yum install epel-release

3. Install Redis:

Now, install Redis using the following command:

sudo yum install redis

4. Start and Enable Redis:

Start the Redis service and enable it to start on boot:

sudo systemctl start redis sudo systemctl enable redis

5. Check Redis Status:

Verify that Redis is running without errors:

sudo systemctl status redis

6. Configure Redis:

By default, Redis is configured to bind to localhost (127.0.0.1). If you want to allow connections from external sources, you need to modify the configuration file.

Edit the Redis configuration file:

sudo nano /etc/redis.conf

Find the line that starts with bind and update it to allow connections from all IP addresses:

bind 0.0.0.0

Save and close the file.

7. Firewall Configuration (if applicable):

If you have a firewall enabled, allow traffic on the Redis port (default is 6379):

sudo firewall-cmd --zone=public --add-port=6379/tcp --permanent sudo firewall-cmd --reload

8. Test Redis:

You can test Redis by connecting to it using the Redis command-line client:

redis-cli

You can use Redis commands in the interactive shell to store and retrieve data.

9. Securing Redis (Optional):

If your Redis instance is exposed to the internet, consider securing it. Update the Redis configuration to require authentication.

Edit the Redis configuration file:

sudo nano /etc/redis.conf

Find the line that starts with requirepass and set a strong password:

requirepass your_strong_password

Save and close the file.

Restart the Redis service for the changes to take effect:

sudo systemctl restart redis

Now, you’ll need to provide the password when connecting to Redis.

That’s it! You’ve successfully installed and configured Redis on CentOS 8. Adjust the configuration based on your specific requirements and security considerations.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.