Enable and optimize Redis 7 Lua scripting capabilities, install custom modules, and implement advanced data processing scripts with performance monitoring for high-throughput applications.
Prerequisites
- Redis 7.x installed
- Root or sudo access
- Basic understanding of Redis commands
- Development tools (gcc, make, git)
What this solves
Redis 7 provides powerful Lua scripting capabilities and module support for complex data processing operations that go beyond basic key-value operations. This tutorial shows you how to enable Lua scripting, install Redis modules like RedisJSON and RedisTimeSeries, create custom data processing scripts, and monitor performance for production workloads.
Step-by-step configuration
Install Redis 7 with module support
Start by installing Redis 7 and development tools needed for module compilation.
sudo apt update
sudo apt install -y redis-server redis-tools build-essential git cmake python3-dev
Configure Redis for Lua scripting
Enable Lua scripting and configure memory limits for script execution in the Redis configuration.
# Enable Lua scripting
lua-time-limit 5000
Configure script cache
lua-replicate-commands yes
Set memory limits for Lua scripts
maxmemory-policy allkeys-lru
maxmemory 2gb
Enable module loading
loadmodule /opt/redis-modules/rejson.so
loadmodule /opt/redis-modules/redistimeseries.so
Configure logging for debugging
loglevel notice
logfile /var/log/redis/redis-server.log
Security settings
requirepass your_secure_password_here
protected-mode yes
bind 127.0.0.1 ::1
Install RedisJSON module
Download and compile the RedisJSON module for advanced JSON data processing capabilities.
sudo mkdir -p /opt/redis-modules
cd /tmp
git clone --recursive https://github.com/RedisJSON/RedisJSON.git
cd RedisJSON
make
sudo cp bin/linux-x64-release/rejson.so /opt/redis-modules/
sudo chown redis:redis /opt/redis-modules/rejson.so
sudo chmod 644 /opt/redis-modules/rejson.so
Install RedisTimeSeries module
Install the RedisTimeSeries module for time-series data processing and analytics.
cd /tmp
git clone --recursive https://github.com/RedisTimeSeries/RedisTimeSeries.git
cd RedisTimeSeries
make
sudo cp bin/linux-x64-release/redistimeseries.so /opt/redis-modules/
sudo chown redis:redis /opt/redis-modules/redistimeseries.so
sudo chmod 644 /opt/redis-modules/redistimeseries.so
Create Lua script directory and set permissions
Set up a dedicated directory for Lua scripts with proper ownership and permissions.
sudo mkdir -p /opt/redis-lua-scripts
sudo chown redis:redis /opt/redis-lua-scripts
sudo chmod 755 /opt/redis-lua-scripts
Restart Redis with new configuration
Restart Redis to load the modules and apply the Lua scripting configuration.
sudo systemctl restart redis-server
sudo systemctl status redis-server
Create advanced data processing Lua script
Create a Lua script for batch data processing with error handling and performance optimization.
-- Advanced batch data processor with error handling
local function process_batch(keys, args)
local batch_size = tonumber(args[1]) or 100
local operation = args[2] or 'increment'
local results = {}
local errors = {}
-- Validate input
if #keys == 0 then
return redis.error_reply('No keys provided')
end
-- Process keys in batches
for i = 1, #keys, batch_size do
local batch_end = math.min(i + batch_size - 1, #keys)
local batch_results = {}
for j = i, batch_end do
local key = keys[j]
local success, result = pcall(function()
if operation == 'increment' then
return redis.call('INCR', key)
elseif operation == 'decrement' then
return redis.call('DECR', key)
elseif operation == 'expire' then
local ttl = tonumber(args[3]) or 3600
return redis.call('EXPIRE', key, ttl)
else
return redis.call('GET', key)
end
end)
if success then
table.insert(batch_results, {key, result})
else
table.insert(errors, {key, result})
end
end
table.insert(results, batch_results)
end
-- Return results and error count
return {
processed = #keys,
errors = #errors,
results = results,
error_details = errors
}
end
return process_batch(KEYS, ARGV)
Create JSON data aggregation script
Create a Lua script that uses RedisJSON for complex data aggregation operations.
-- JSON data aggregation script using RedisJSON
local function aggregate_json_data(keys, args)
local aggregation_key = args[1]
local field_path = args[2] or '$'
local operation = args[3] or 'sum'
local total = 0
local count = 0
local values = {}
-- Collect values from JSON objects
for _, key in ipairs(keys) do
local exists = redis.call('EXISTS', key)
if exists == 1 then
local value = redis.call('JSON.GET', key, field_path)
if value then
local num_value = tonumber(value)
if num_value then
table.insert(values, num_value)
total = total + num_value
count = count + 1
end
end
end
end
-- Calculate aggregation
local result
if operation == 'sum' then
result = total
elseif operation == 'avg' and count > 0 then
result = total / count
elseif operation == 'min' and #values > 0 then
result = math.min(table.unpack(values))
elseif operation == 'max' and #values > 0 then
result = math.max(table.unpack(values))
elseif operation == 'count' then
result = count
else
result = 0
end
-- Store aggregation result
if aggregation_key then
redis.call('JSON.SET', aggregation_key, '$',
string.format('{
"operation": "%s",
"result": %s,
"count": %d,
"timestamp": %d
}', operation, result, count, redis.call('TIME')[1]))
end
return {
operation = operation,
result = result,
count = count,
processed_keys = #keys
}
end
return aggregate_json_data(KEYS, ARGV)
Create time-series data processor
Implement a Lua script for processing time-series data using RedisTimeSeries module.
-- Time-series data processor with RedisTimeSeries
local function process_timeseries(keys, args)
local retention_period = tonumber(args[1]) or 86400000 -- 24 hours in ms
local aggregation_window = tonumber(args[2]) or 60000 -- 1 minute in ms
local current_time = redis.call('TIME')
local timestamp = current_time[1] * 1000 + math.floor(current_time[2] / 1000)
local processed = 0
local created = 0
local errors = {}
for _, key in ipairs(keys) do
local success, result = pcall(function()
-- Check if time series exists
local exists = redis.call('EXISTS', key)
if exists == 0 then
-- Create new time series with retention and labels
redis.call('TS.CREATE', key,
'RETENTION', retention_period,
'LABELS', 'type', 'metric', 'processed_by', 'lua')
created = created + 1
end
-- Add current timestamp with random value (in real use, pass actual values)
local value = math.random(1, 100)
redis.call('TS.ADD', key, timestamp, value)
-- Create aggregation rule if it doesn't exist
local agg_key = key .. ':avg:1m'
local agg_exists = redis.call('EXISTS', agg_key)
if agg_exists == 0 then
redis.call('TS.CREATE', agg_key,
'RETENTION', retention_period,
'LABELS', 'type', 'aggregation', 'source', key)
redis.call('TS.CREATERULE', key, agg_key,
'AGGREGATION', 'AVG', aggregation_window)
end
processed = processed + 1
return 'OK'
end)
if not success then
table.insert(errors, {key, result})
end
end
return {
processed = processed,
created = created,
errors = #errors,
error_details = errors,
timestamp = timestamp
}
end
return process_timeseries(KEYS, ARGV)
Load and test Lua scripts
Load the scripts into Redis and test their functionality with sample data.
# Connect to Redis
redis-cli -a your_secure_password_here
Load batch processor script
SCRIPT LOAD "$(cat /opt/redis-lua-scripts/batch_processor.lua)"
Load JSON aggregator script
SCRIPT LOAD "$(cat /opt/redis-lua-scripts/json_aggregator.lua)"
Load timeseries processor script
SCRIPT LOAD "$(cat /opt/redis-lua-scripts/timeseries_processor.lua)"
List loaded scripts
SCRIPT LIST
Test batch processor (create test keys first)
MSET counter1 10 counter2 20 counter3 30
EVALSHA 3 counter1 counter2 counter3 10 increment
Test JSON aggregator (create JSON test data)
JSON.SET product1 $ '{"price": 29.99, "category": "electronics"}'
JSON.SET product2 $ '{"price": 19.99, "category": "electronics"}'
EVALSHA 2 product1 product2 aggregation:electronics $.price sum
Test timeseries processor
EVALSHA 2 metric1 metric2 86400000 60000
Configure performance monitoring
Set up Redis monitoring to track Lua script performance and resource usage.
-- Performance monitoring for Lua scripts
local function get_script_stats(keys, args)
local stats = {}
-- Get general Redis info
local info = redis.call('INFO', 'stats')
local memory_info = redis.call('INFO', 'memory')
-- Get script cache information
local script_stats = {
total_calls = redis.call('INFO', 'stats'),
memory_usage = redis.call('MEMORY', 'USAGE', 'script_cache'),
cached_scripts = redis.call('SCRIPT', 'LIST')
}
-- Get module information
local modules = redis.call('MODULE', 'LIST')
-- Calculate script execution times (estimated)
local execution_times = {}
for _, key in ipairs(keys) do
if redis.call('EXISTS', key) == 1 then
local start_time = redis.call('TIME')
-- Simulate script execution time measurement
execution_times[key] = {
last_execution = start_time[1] * 1000000 + start_time[2],
avg_time = math.random(1, 1000) -- In microseconds
}
end
end
return {
timestamp = redis.call('TIME')[1],
script_stats = script_stats,
modules = modules,
execution_times = execution_times,
memory_used = redis.call('INFO', 'memory')
}
end
return get_script_stats(KEYS, ARGV)
Create script management utility
Create a Python script to manage and monitor Lua scripts in production environments.
#!/usr/bin/env python3
import redis
import hashlib
import json
import time
import os
from typing import Dict, List, Any
class RedisLuaManager:
def __init__(self, host='localhost', port=6379, password=None, db=0):
self.redis_client = redis.Redis(
host=host, port=port, password=password, db=db,
decode_responses=True, socket_timeout=5
)
self.script_cache = {}
def load_script_from_file(self, script_path: str) -> str:
"""Load and register a Lua script from file"""
try:
with open(script_path, 'r') as f:
script_content = f.read()
sha = self.redis_client.script_load(script_content)
script_name = os.path.basename(script_path)
self.script_cache[script_name] = {
'sha': sha,
'path': script_path,
'loaded_at': time.time()
}
print(f"Loaded script {script_name}: {sha}")
return sha
except Exception as e:
print(f"Error loading script {script_path}: {e}")
return None
def execute_script(self, script_name: str, keys: List[str] = None, args: List[str] = None) -> Any:
"""Execute a loaded script by name"""
if script_name not in self.script_cache:
raise ValueError(f"Script {script_name} not loaded")
sha = self.script_cache[script_name]['sha']
keys = keys or []
args = args or []
try:
start_time = time.time()
result = self.redis_client.evalsha(sha, len(keys), *(keys + args))
execution_time = (time.time() - start_time) * 1000
print(f"Script {script_name} executed in {execution_time:.2f}ms")
return result
except redis.exceptions.NoScriptError:
print(f"Script {script_name} not in cache, reloading...")
self.load_script_from_file(self.script_cache[script_name]['path'])
return self.execute_script(script_name, keys, args)
def get_script_stats(self) -> Dict[str, Any]:
"""Get performance statistics for all scripts"""
info = self.redis_client.info()
return {
'total_scripts': len(self.script_cache),
'redis_memory_used': info.get('used_memory_human'),
'redis_connected_clients': info.get('connected_clients'),
'script_cache': self.script_cache
}
def benchmark_script(self, script_name: str, iterations: int = 100,
keys: List[str] = None, args: List[str] = None) -> Dict[str, float]:
"""Benchmark script execution performance"""
execution_times = []
for _ in range(iterations):
start_time = time.time()
try:
self.execute_script(script_name, keys, args)
execution_times.append((time.time() - start_time) * 1000)
except Exception as e:
print(f"Benchmark error: {e}")
if execution_times:
return {
'avg_time': sum(execution_times) / len(execution_times),
'min_time': min(execution_times),
'max_time': max(execution_times),
'total_iterations': len(execution_times)
}
return {}
if __name__ == '__main__':
manager = RedisLuaManager(password='your_secure_password_here')
# Load all scripts
script_dir = '/opt/redis-lua-scripts'
for script_file in ['batch_processor.lua', 'json_aggregator.lua',
'timeseries_processor.lua', 'monitor.lua']:
script_path = os.path.join(script_dir, script_file)
if os.path.exists(script_path):
manager.load_script_from_file(script_path)
# Example usage
print(json.dumps(manager.get_script_stats(), indent=2))
# Benchmark example
benchmark = manager.benchmark_script('batch_processor.lua',
iterations=50,
keys=['test1', 'test2', 'test3'],
args=['10', 'increment'])
print(f"Benchmark results: {benchmark}")
Set up script monitoring with systemd
Create a systemd service to monitor script performance and automatically reload scripts if needed.
[Unit]
Description=Redis Lua Script Monitor
After=redis-server.service
Requires=redis-server.service
[Service]
Type=simple
User=redis
Group=redis
WorkingDirectory=/opt/redis-lua-scripts
ExecStart=/usr/bin/python3 /opt/redis-lua-scripts/script_manager.py
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
sudo chmod 644 /opt/redis-lua-scripts/script_manager.py
sudo chmod +x /opt/redis-lua-scripts/script_manager.py
sudo systemctl daemon-reload
sudo systemctl enable redis-script-monitor
sudo systemctl start redis-script-monitor
Verify your setup
Test that Redis 7 is running with Lua scripting enabled and modules loaded correctly.
# Check Redis server status and version
sudo systemctl status redis-server
redis-cli -a your_secure_password_here INFO server
Verify modules are loaded
redis-cli -a your_secure_password_here MODULE LIST
Check Lua scripting is enabled
redis-cli -a your_secure_password_here CONFIG GET lua-time-limit
Test script loading and execution
redis-cli -a your_secure_password_here SCRIPT LOAD "return 'Hello from Lua'"
redis-cli -a your_secure_password_here EVALSHA 0
Test JSON module
redis-cli -a your_secure_password_here JSON.SET test $ '{"hello": "world"}'
redis-cli -a your_secure_password_here JSON.GET test
Test TimeSeries module
redis-cli -a your_secure_password_here TS.CREATE temperature
redis-cli -a your_secure_password_here TS.ADD temperature '*' 23.5
redis-cli -a your_secure_password_here TS.GET temperature
Check script monitor service
sudo systemctl status redis-script-monitor
sudo journalctl -u redis-script-monitor -f
Performance optimization
Configure Lua script caching
Optimize script caching and memory usage for production workloads.
# Script cache optimization
lua-replicate-commands yes
lua-always-replicate-commands no
Memory optimization for scripts
maxmemory-policy allkeys-lru
lua-time-limit 10000
Enable performance monitoring
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 100
Monitor script performance
Set up comprehensive monitoring for Lua script execution and performance metrics.
# Monitor slow queries including Lua scripts
redis-cli -a your_secure_password_here SLOWLOG GET 10
Check script memory usage
redis-cli -a your_secure_password_here MEMORY STATS
Monitor latency
redis-cli -a your_secure_password_here LATENCY LATEST
Check loaded scripts
redis-cli -a your_secure_password_here SCRIPT LIST
Common issues
| Symptom | Cause | Fix |
|---|---|---|
| Module loading fails | Missing dependencies or wrong path | Check module compilation and verify file permissions with ls -la /opt/redis-modules/ |
| Script execution timeout | lua-time-limit too low | Increase lua-time-limit in redis.conf or optimize script logic |
| Memory usage increasing | Script cache growing unbounded | Monitor with SCRIPT LIST and implement cache cleanup strategy |
| JSON operations fail | RedisJSON module not loaded | Verify module path and restart Redis: sudo systemctl restart redis-server |
| Permission denied errors | Wrong file ownership or permissions | Fix with sudo chown redis:redis /opt/redis-* and chmod 644 for files |
| Scripts disappear after restart | Scripts not persisted | Use SCRIPT LOAD on startup or implement auto-reload in application |
Next steps
- Set up Redis monitoring with Prometheus and Grafana dashboards
- Configure Redis Sentinel with SSL/TLS encryption and authentication for high availability
- Implement Redis cluster sharding for horizontal scaling
- Optimize Redis Lua scripts for production performance
- Integrate Redis with microservices architecture
Automated install script
Run this to automate the entire setup
#!/usr/bin/env bash
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Default values
REDIS_PASSWORD="${1:-$(openssl rand -base64 32)}"
MEMORY_LIMIT="${2:-2gb}"
# Usage function
usage() {
echo "Usage: $0 [redis_password] [memory_limit]"
echo " redis_password: Password for Redis (default: auto-generated)"
echo " memory_limit: Memory limit for Redis (default: 2gb)"
exit 1
}
# Logging functions
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
log_warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
# Cleanup on error
cleanup() {
log_error "Installation failed. Cleaning up..."
systemctl stop redis-server 2>/dev/null || systemctl stop redis 2>/dev/null || true
rm -rf /tmp/RedisJSON /tmp/RedisTimeSeries /opt/redis-modules /opt/redis-lua-scripts
exit 1
}
trap cleanup ERR
# Check if running as root or with sudo
if [[ $EUID -eq 0 ]]; then
SUDO=""
else
if ! command -v sudo &> /dev/null; then
log_error "This script requires sudo privileges"
exit 1
fi
SUDO="sudo"
fi
# Auto-detect distribution
log_info "[1/8] Detecting Linux distribution..."
if [ -f /etc/os-release ]; then
. /etc/os-release
case "$ID" in
ubuntu|debian)
PKG_MGR="apt"
PKG_INSTALL="apt install -y"
PKG_UPDATE="apt update"
REDIS_SERVICE="redis-server"
REDIS_CONFIG="/etc/redis/redis.conf"
REDIS_USER="redis"
;;
almalinux|rocky|centos|rhel|ol|fedora)
PKG_MGR="dnf"
PKG_INSTALL="dnf install -y"
PKG_UPDATE="dnf update -y"
REDIS_SERVICE="redis"
REDIS_CONFIG="/etc/redis/redis.conf"
REDIS_USER="redis"
;;
amzn)
PKG_MGR="yum"
PKG_INSTALL="yum install -y"
PKG_UPDATE="yum update -y"
REDIS_SERVICE="redis"
REDIS_CONFIG="/etc/redis.conf"
REDIS_USER="redis"
;;
*)
log_error "Unsupported distribution: $ID"
exit 1
;;
esac
else
log_error "Cannot detect Linux distribution"
exit 1
fi
log_success "Detected: $PRETTY_NAME"
# Install Redis and dependencies
log_info "[2/8] Installing Redis 7 and development tools..."
$SUDO $PKG_UPDATE
if [[ "$PKG_MGR" == "apt" ]]; then
$SUDO $PKG_INSTALL redis-server redis-tools build-essential git cmake python3-dev
elif [[ "$PKG_MGR" == "dnf" ]]; then
$SUDO $PKG_INSTALL redis redis-devel gcc gcc-c++ make git cmake python3-devel
$SUDO dnf groupinstall -y "Development Tools"
elif [[ "$PKG_MGR" == "yum" ]]; then
$SUDO $PKG_INSTALL redis gcc gcc-c++ make git cmake python3-devel
$SUDO yum groupinstall -y "Development Tools"
fi
log_success "Redis and development tools installed"
# Create module directory
log_info "[3/8] Setting up Redis modules directory..."
$SUDO mkdir -p /opt/redis-modules
$SUDO mkdir -p /opt/redis-lua-scripts
# Install RedisJSON module
log_info "[4/8] Installing RedisJSON module..."
cd /tmp
git clone --recursive https://github.com/RedisJSON/RedisJSON.git
cd RedisJSON
make
$SUDO cp bin/linux-x64-release/rejson.so /opt/redis-modules/
$SUDO chown $REDIS_USER:$REDIS_USER /opt/redis-modules/rejson.so
$SUDO chmod 644 /opt/redis-modules/rejson.so
log_success "RedisJSON module installed"
# Install RedisTimeSeries module
log_info "[5/8] Installing RedisTimeSeries module..."
cd /tmp
git clone --recursive https://github.com/RedisTimeSeries/RedisTimeSeries.git
cd RedisTimeSeries
make
$SUDO cp bin/linux-x64-release/redistimeseries.so /opt/redis-modules/
$SUDO chown $REDIS_USER:$REDIS_USER /opt/redis-modules/redistimeseries.so
$SUDO chmod 644 /opt/redis-modules/redistimeseries.so
log_success "RedisTimeSeries module installed"
# Set permissions for directories
$SUDO chown -R $REDIS_USER:$REDIS_USER /opt/redis-modules /opt/redis-lua-scripts
$SUDO chmod 755 /opt/redis-modules /opt/redis-lua-scripts
# Configure Redis
log_info "[6/8] Configuring Redis with Lua scripting and modules..."
$SUDO cp $REDIS_CONFIG ${REDIS_CONFIG}.backup
# Create Redis configuration
$SUDO tee $REDIS_CONFIG > /dev/null << EOF
# Redis configuration for Lua scripting and modules
daemonize yes
supervised systemd
port 6379
tcp-backlog 511
# Network and security
bind 127.0.0.1 ::1
protected-mode yes
requirepass $REDIS_PASSWORD
timeout 0
tcp-keepalive 300
# Memory management
maxmemory $MEMORY_LIMIT
maxmemory-policy allkeys-lru
# Lua scripting configuration
lua-time-limit 5000
lua-replicate-commands yes
# Module loading
loadmodule /opt/redis-modules/rejson.so
loadmodule /opt/redis-modules/redistimeseries.so
# Logging
loglevel notice
logfile /var/log/redis/redis-server.log
syslog-enabled no
# Snapshotting
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/lib/redis
# Append only file
appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
EOF
log_success "Redis configuration updated"
# Create sample Lua script
log_info "[7/8] Creating sample Lua processing script..."
$SUDO tee /opt/redis-lua-scripts/batch_processor.lua > /dev/null << 'EOF'
-- Advanced batch data processor with error handling
local function process_batch(keys, args)
local batch_size = tonumber(args[1]) or 100
local operation = args[2] or 'increment'
local results = {}
local errors = {}
-- Validate input
if #keys == 0 then
return redis.error_reply('No keys provided')
end
-- Process keys in batches
for i = 1, #keys, batch_size do
local batch_end = math.min(i + batch_size - 1, #keys)
local batch_results = {}
for j = i, batch_end do
local key = keys[j]
local success, result = pcall(function()
if operation == 'increment' then
return redis.call('INCR', key)
elseif operation == 'decrement' then
return redis.call('DECR', key)
elseif operation == 'expire' then
local ttl = tonumber(args[3]) or 3600
return redis.call('EXPIRE', key, ttl)
else
return redis.error_reply('Invalid operation')
end
end)
if success then
table.insert(batch_results, result)
else
table.insert(errors, {key = key, error = result})
end
end
table.insert(results, batch_results)
end
return {results = results, errors = errors, processed = #keys}
end
return process_batch(KEYS, ARGV)
EOF
$SUDO chown $REDIS_USER:$REDIS_USER /opt/redis-lua-scripts/batch_processor.lua
$SUDO chmod 644 /opt/redis-lua-scripts/batch_processor.lua
# Start and enable Redis service
log_info "[8/8] Starting Redis service..."
$SUDO systemctl daemon-reload
$SUDO systemctl enable $REDIS_SERVICE
$SUDO systemctl restart $REDIS_SERVICE
# Wait for service to start
sleep 3
# Verify installation
log_info "Verifying Redis installation..."
if systemctl is-active --quiet $REDIS_SERVICE; then
log_success "Redis service is running"
else
log_error "Redis service failed to start"
exit 1
fi
# Test Redis connection and modules
if redis-cli -a "$REDIS_PASSWORD" ping | grep -q "PONG"; then
log_success "Redis is responding to commands"
else
log_error "Redis is not responding"
exit 1
fi
# Test modules
if redis-cli -a "$REDIS_PASSWORD" module list | grep -q "ReJSON"; then
log_success "RedisJSON module loaded successfully"
else
log_warning "RedisJSON module may not be loaded"
fi
if redis-cli -a "$REDIS_PASSWORD" module list | grep -q "timeseries"; then
log_success "RedisTimeSeries module loaded successfully"
else
log_warning "RedisTimeSeries module may not be loaded"
fi
# Clean up temporary files
rm -rf /tmp/RedisJSON /tmp/RedisTimeSeries
# Final success message
log_success "Redis 7 with Lua scripting and modules installed successfully!"
echo ""
echo "Configuration details:"
echo " Redis Password: $REDIS_PASSWORD"
echo " Memory Limit: $MEMORY_LIMIT"
echo " Config file: $REDIS_CONFIG"
echo " Modules directory: /opt/redis-modules"
echo " Lua scripts directory: /opt/redis-lua-scripts"
echo " Service name: $REDIS_SERVICE"
echo ""
echo "Test connection: redis-cli -a '$REDIS_PASSWORD' ping"
echo "View logs: journalctl -u $REDIS_SERVICE -f"
Review the script before running. Execute with: bash install.sh