RHEL BasedRocky Linux

How To Install Redis on Rocky Linux 10

Install Redis on Rocky Linux 10

Redis stands as one of the most powerful in-memory data structure stores available today, serving millions of applications worldwide as a database, cache, and message broker. When paired with Rocky Linux 10’s enterprise-grade stability and performance, Redis becomes an even more formidable solution for high-availability production environments. This comprehensive guide walks you through multiple installation methods, configuration best practices, and security hardening techniques to get Redis running optimally on your Rocky Linux 10 system.

Whether you’re a system administrator, DevOps engineer, or developer looking to implement caching solutions, this tutorial provides everything needed to successfully deploy Redis. We’ll explore four distinct installation approaches, from simple package manager installations to compiling from source code, ensuring you can choose the method that best fits your specific requirements and technical expertise level.

Understanding Redis and Rocky Linux 10

Redis (Remote Dictionary Server) functions as an open-source, in-memory data structure store that supports various data types including strings, hashes, lists, sets, and sorted sets. Its lightning-fast performance stems from keeping data in memory while offering optional persistence to disk, making it ideal for applications requiring sub-millisecond response times.

Common Redis use cases span across multiple domains: web application caching to reduce database load, session management for maintaining user state across distributed systems, real-time analytics for processing streaming data, and message queuing for asynchronous task processing. The versatility of Redis makes it an essential component in modern application architectures.

Rocky Linux 10 represents the latest iteration of this enterprise-focused distribution, built as a community-driven successor to CentOS. It provides binary compatibility with Red Hat Enterprise Linux (RHEL), offering long-term support, enhanced security features, and rock-solid stability. The combination of Redis and Rocky Linux 10 delivers exceptional performance and reliability for production workloads.

Prerequisites and System Requirements

Before proceeding with Redis installation, ensure your Rocky Linux 10 system meets the necessary requirements. Hardware specifications should include a minimum of 1GB RAM (though 4GB or more is recommended for production environments), a dual-core processor, and at least 10GB of available disk space for installation and data storage.

Software prerequisites require a fresh Rocky Linux 10 installation with administrative privileges. You’ll need either root access or a user account configured with sudo capabilities. Network connectivity is essential for downloading packages and dependencies during the installation process.

Firewall considerations involve opening TCP port 6379 (Redis default) for client connections, though this can be customized during configuration. Ensure your system’s firewall rules allow the necessary traffic patterns for your specific use case.

Pre-Installation System Preparation

System Updates and Security Patches

Starting with a fully updated system ensures compatibility and security. Execute the following commands to update your Rocky Linux 10 installation:

sudo dnf update -y
sudo dnf upgrade -y

This process updates all installed packages to their latest versions and applies critical security patches. The system may require a reboot if kernel updates were applied.

Installing Essential Dependencies

Development tools installation becomes crucial for certain installation methods, particularly when compiling from source. Install the development group and essential packages:

sudo dnf groupinstall "Development Tools" -y
sudo dnf install gcc make wget curl -y

EPEL repository setup provides access to additional packages not included in the default Rocky Linux repositories:

sudo dnf install -y epel-release
sudo dnf makecache

Verify the EPEL repository installation by listing available repositories:

dnf repolist enabled

Method 1: Installing Redis from Rocky Linux Repositories

Using DNF Package Manager

The simplest installation approach utilizes Rocky Linux’s built-in package manager. This method ensures automatic dependency resolution and seamless integration with the system’s package management:

sudo dnf search redis
sudo dnf install redis -y

Check the installed Redis version to confirm successful installation:

redis-server --version

Advantages of this method include quick installation, automatic security updates through the system’s update mechanism, and guaranteed compatibility with Rocky Linux 10. However, limitations may include older Redis versions compared to the latest releases.

Module-Based Installation

Rocky Linux 10 supports modular package installation, allowing selection of specific Redis versions:

dnf module list redis
sudo dnf module reset redis -y
sudo dnf module enable redis:6 -y
sudo dnf install redis -y

This approach provides more control over the Redis version while maintaining package management benefits. Module streams allow switching between different versions as needed for compatibility requirements.

Method 2: Installing Redis from EPEL Repository

EPEL Repository Configuration

The Extra Packages for Enterprise Linux (EPEL) repository often contains more recent Redis versions than the default repositories. Confirm EPEL installation and update the package cache:

sudo dnf install -y epel-release
sudo dnf clean all
sudo dnf makecache

Redis Installation Process

Install Redis from the EPEL repository with enhanced package availability:

sudo dnf --enablerepo=epel install redis -y

EPEL advantages include access to newer Redis versions, additional Redis modules, and community-maintained packages with frequent updates. Verify the installation by checking the Redis configuration file location:

ls -la /etc/redis*

Version benefits of EPEL installations often include improved performance optimizations, bug fixes, and new features not available in standard repository versions.

Method 3: Installing Latest Redis from Remi Repository

Remi Repository Setup

Remi repository provides cutting-edge versions of various software packages, including the latest Redis releases. Install the Remi repository configuration:

sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-10.rpm
sudo dnf makecache

Import the repository’s GPG key for package verification:

sudo rpm --import https://rpms.remirepo.net/RPM-GPG-KEY-remi

Redis 7.x Installation

Access the latest Redis version through Remi’s modular approach:

dnf module list redis --disablerepo="*" --enablerepo="remi-modular"
sudo dnf module reset redis -y
sudo dnf module enable redis:remi-7.0 -y
sudo dnf install redis -y

Redis 7.x features include enhanced performance, improved memory efficiency, Redis Functions for server-side scripting, and advanced security capabilities. The latest version provides significant improvements in clustering, replication, and data persistence mechanisms.

Performance enhancements in Redis 7.x deliver up to 50% better performance in certain workloads while reducing memory consumption through optimized data structures and algorithms.

Method 4: Compiling Redis from Source Code

Development Environment Setup

Source code compilation offers maximum control over Redis features and optimizations. Install comprehensive build dependencies:

sudo dnf groupinstall "Development Tools" -y
sudo dnf install gcc gcc-c++ make wget tar openssl-devel systemd-devel -y

Download the latest Redis source from the official repository:

cd /tmp
wget https://download.redis.io/redis-stable.tar.gz
tar -xzf redis-stable.tar.gz
cd redis-stable

Compilation Process

Configure compilation options for optimal performance and feature enablement:

make BUILD_TLS=yes USE_SYSTEMD=yes

The BUILD_TLS=yes parameter enables SSL/TLS support for encrypted connections, while USE_SYSTEMD=yes provides native systemd integration.

Execute the build process and run comprehensive tests:

make test
sudo make install

Installation completion involves creating necessary directories and setting appropriate permissions:

sudo mkdir -p /etc/redis /var/lib/redis /var/log/redis
sudo useradd -r -M -d /var/lib/redis -s /sbin/nologin redis
sudo chown redis:redis /var/lib/redis /var/log/redis

Custom Configuration for Source Installation

Create a systemd service file for source-compiled Redis:

sudo tee /etc/systemd/system/redis.service << EOF
[Unit]
Description=Redis In-Memory Data Store
After=network.target

[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always

[Install]
WantedBy=multi-user.target
EOF

Post-Installation Configuration

Service Management

Start and enable Redis service for automatic startup:

sudo systemctl start redis
sudo systemctl enable redis
sudo systemctl status redis

Service verification confirms Redis is running correctly:

sudo systemctl is-active redis
sudo systemctl is-enabled redis

Troubleshoot service issues by examining logs:

sudo journalctl -u redis -f

Basic Configuration Setup

Redis configuration file location varies by installation method but typically resides at /etc/redis.conf or /etc/redis/redis.conf. Key configuration parameters include:

# Memory management
maxmemory 2gb
maxmemory-policy allkeys-lru

# Persistence settings
save 900 1
save 300 10
save 60 10000

# Network configuration
bind 127.0.0.1
port 6379

# Logging
loglevel notice
logfile /var/log/redis/redis-server.log

Essential configuration modifications optimize Redis for your specific workload requirements. Memory limits prevent system resource exhaustion, while persistence options ensure data durability.

Security Configuration and Hardening

Authentication Implementation

Password protection adds a crucial security layer:

# Edit Redis configuration
sudo vim /etc/redis.conf

# Add authentication
requirepass your_strong_password_here

Advanced user management in Redis 6.x+ provides granular access control:

redis-cli
AUTH your_password
ACL SETUSER myapp on >app_password ~* +@all -FLUSHDB -FLUSHALL
ACL SAVE

Network Security Configuration

Firewall rules restrict access to authorized clients only:

sudo firewall-cmd --permanent --add-port=6379/tcp --source=192.168.1.0/24
sudo firewall-cmd --reload

Binding configuration limits network interfaces:

# Bind to specific interfaces only
bind 127.0.0.1 192.168.1.100

SSL/TLS encryption secures data in transit:

tls-port 6380
tls-cert-file /etc/redis/tls/redis.crt
tls-key-file /etc/redis/tls/redis.key
tls-ca-cert-file /etc/redis/tls/ca.crt

Testing Redis Installation

Connection and Functionality Testing

Basic connectivity verification uses the Redis CLI:

redis-cli ping
# Expected output: PONG

Command execution testing validates Redis functionality:

redis-cli
127.0.0.1:6379> SET test "Hello Redis"
127.0.0.1:6379> GET test
127.0.0.1:6379> DEL test
127.0.0.1:6379> EXIT

Performance Benchmarking

Benchmark testing measures Redis performance capabilities:

redis-benchmark -h 127.0.0.1 -p 6379 -n 100000 -c 50

Memory usage monitoring tracks resource consumption:

redis-cli INFO memory
redis-cli MEMORY USAGE mykey

Monitor system resources during Redis operation:

htop
free -h
iostat -x 1

Common Issues and Troubleshooting

Installation Problems Resolution

Repository conflicts can cause package installation failures. Resolve by disabling conflicting repositories:

sudo dnf install redis --disablerepo=repository_name

Dependency errors require manual resolution of missing packages:

sudo dnf install missing-package-name
dnf provides "*/missing-file"

Permission issues often stem from incorrect user configurations:

sudo chown -R redis:redis /var/lib/redis
sudo chmod 750 /var/lib/redis

Runtime Issue Diagnostics

Service startup failures require systematic troubleshooting:

sudo systemctl status redis -l
sudo journalctl -u redis --no-pager

Connection problems may indicate network or firewall issues:

netstat -tlnp | grep 6379
sudo ss -tlnp | grep 6379
telnet localhost 6379

Performance issues often relate to memory or configuration problems:

redis-cli --latency -i 1
redis-cli INFO stats
redis-cli SLOWLOG GET 10

Best Practices and Optimization

Performance Tuning Strategies

Memory configuration optimization prevents system instability:

# Set appropriate memory limits
maxmemory 75% of available RAM
maxmemory-policy volatile-lru

# Optimize for specific workloads
hash-max-ziplist-entries 512
set-max-intset-entries 512

Persistence configuration balances performance and data safety:

# RDB snapshots
save 900 1
save 300 10
save 60 10000

# AOF persistence
appendonly yes
appendfsync everysec

Maintenance Procedures

Regular backup strategies protect against data loss:

# Create automated backup script
#!/bin/bash
redis-cli BGSAVE
cp /var/lib/redis/dump.rdb /backup/redis-$(date +%Y%m%d-%H%M%S).rdb

Update procedures maintain system security:

# Check for updates
sudo dnf check-update redis

# Backup before updates
redis-cli BGSAVE

# Apply updates
sudo dnf update redis
sudo systemctl restart redis

Monitoring implementation tracks system health:

# Monitor key metrics
redis-cli INFO replication
redis-cli INFO persistence
redis-cli CLIENT LIST

Production Deployment Considerations

Clustering preparation enables horizontal scaling:

# Enable cluster mode
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000

High availability configuration implements Redis Sentinel:

# Sentinel configuration
sentinel monitor mymaster 127.0.0.1 6379 2
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 10000

Resource monitoring ensures optimal performance:

# Set up monitoring alerts
redis-cli INFO memory | grep used_memory_human
redis-cli INFO stats | grep keyspace_hits

Congratulations! You have successfully installed Redis. Thanks for using this tutorial for installing Redis on your Rocky Linux 10 system. For additional help or useful information, we recommend you check the official Redis website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button