DateBase
Redis

Redis Installation Guide

1. Installing Redis Client Tools

For Ubuntu/Debian:

To install Redis client tools (redis-tools), run:

sudo apt-get update
sudo apt-get install redis-tools

Verify the installation:

redis-cli -h <redis_host> -p <redis_port> -a <redis_password>
redis-cli -h redis15.localnet.org -p 6390 PING

Set Redis port:

redis_port=6379

2. Installing Redis Server

Using APT (Recommended):

  1. Install required packages:

    sudo apt install lsb-release curl gpg
  2. Add Redis APT repository:

    curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
    echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
  3. Update package list and install Redis:

    sudo apt-get update
    sudo apt-get install redis

Using Snap:

Alternatively, you can install Redis via Snap:

sudo snap install redis

3. Starting and Managing Redis Service

For APT installation:

  1. Start the Redis server:

    sudo systemctl start redis
  2. Enable Redis to start on boot:

    sudo systemctl enable redis
  3. Check the status of the Redis service:

    sudo systemctl status redis

For Snap installation:

  1. Start the Redis service:

    sudo snap start redis
  2. Enable Redis to start on boot:

    sudo snap set redis start-on-boot=true
  3. Check the status of the Redis service:

    sudo snap services redis

4. Configuring Redis

The configuration file for Redis is typically located at /etc/redis/redis.conf (for APT installations). You can edit this file to configure settings like bind, port, requirepass (for password protection), etc.

Example to set a password:

sudo nano /etc/redis/redis.conf
# Uncomment and set your password
requirepass yourpassword

After making changes, restart Redis:

sudo systemctl restart redis

5. Testing Redis Installation

To test if Redis is working correctly, use the Redis CLI:

redis-cli

Ping Redis server:

redis-cli -p 6379 PING
# Output should be: PONG

Set and get a key-value pair:

redis-cli -p 6379 SET mykey "Hello Redis"
redis-cli -p 6379 GET mykey
# Output should be: "Hello Redis"

Conclusion

With these steps, you should have Redis server and client tools installed and configured. You can now start using Redis for caching, data storage, and more. If you encounter any issues, consult the Redis documentation (opens in a new tab) for further troubleshooting and advanced configurations.


🧙 AI Wizard - Instant Page Insights

Click the button below to analyze this page.
Get an AI-generated summary and key insights in seconds.
Powered by Perplexity AI!