Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Installing Redis
2.1.
Installing Redis from the source
2.2.
Installing Redis on Linux
2.3.
Installing Redis on Windows
2.4.
Installing Redis on macOS
3.
Frequently Asked Questions
3.1.
What permissions do users belonging to the redislabs group have?
3.2.
What port does Redis run on?
3.3.
How to check whether the Redis server is running?
3.4.
How do we run Redis?
4.
Conclusion
Last Updated: Mar 27, 2024
Easy

Installing Redis

Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

Redis is frequently referred to as a data structures server. This implies that Redis gives users access to flexible data structures through a set of instructions communicated across Transmission Control Protocol (TCP) connections using a simple protocol. As a result, many processes can use the same data structures to query and alter them.

Another appropriate comparison is to think about Redis as a more advanced version of Memcached, including operations such as Lists, Sets, ordered data structures, and so on, rather than just SETs and GETs.

This article will help you gather the prerequisites and instructions for installing Redis on your Linux, macOS, and Windows system.

Also see, Multiple Granularity in DBMS

Installing Redis

Below are the steps to install the Redis data structure server on your LinuxWindows, and macOS systems.

Redis

Source: https://en.wikipedia.org/wiki/Redis

 

Installing Redis from the source

Redis provides an option to be installed on different operating systems from the source file, independent of the operating system installed on, including Linux and macOS. 

C and libc are the only dependencies or prerequisites for Installing Redis.

For installing from the source, follow these steps:

Step 1: Obtain the source file either from the official download page or run the following command in the terminal: 

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

 

Step 2: Extract the files from the tar folder and change the current directory to extracted directory.

tar -xzvf redis-stable.tar.gz
cd redis-stable

 

Step 3: Install the Redis using the make command in the extracted directory.

make

 

Two of the following libraries will be present in the src directory on successful installation.

  1. Redis-server is the name of the Redis Server.
  2. Redis-CLI is a command-line tool for interacting with Redis.

We can install the above binaries in /usr/local/bin using: 

make install

 

Start your Redis server with:

redis-server

Installing Redis on Linux

Open-source, free operating system distributions of Linux provide Redis packages out of the box. We can install the Redis with the following commands:

sudo apt-get update
sudo apt-get install redis

 

If the distribution fails to auto-detect the Redis package, run the following command before executing the above one:

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

 

We can alternatively install Redis using the snapcraft store available in various Linux distributions, including centOS.

Follow the below instructions for Installing Redis from snapcraft store:

sudo yum install epel-release
sudo yum install snapd
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap
sudo snap install redis

Installing Redis on Windows

On Windows, Redis is not officially supported. However, you may install Redis on Windows for development purposes by following the methods below.

We must activate WSL2 on Windows before installing Redis (Windows Subsystem for Linux). WSL2 allows us to run Linux binaries on Windows natively.

Requirements: Windows 10 v2004 or Windows 11.

Install WSL2 with the help of Microsoft official documentation.

On the Ubuntu subsystem, run the following commands for Installing Redis:

sudo apt-add-repository ppa:redislabs/redis
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install redis-server

 

Start the Redis server with:

sudo service redis-server start

Installing Redis on macOS

Alternatively to Installing Redis from the source, we can install Redis on macOS using homebrew. To confirm if you have homebrew already installed, run the following command:

$ brew --version

 

On failure of the above command, refer to the official homebrew website for installation.

On successful installation of homebrew, install Redis on macOS, using the following command in the terminal:

brew install redis

 

You can start the Redis server using:

redis-server

 

After successful installation, let us help you configure Redis on your system.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Frequently Asked Questions

What permissions do users belonging to the redislabs group have?

The redislabs:redislabs user and group are created during the installation of Redis Enterprise Software.

It is optional to add other users to the redislabs group. Users in the redislabs group can read and execute commands (e.g., the rladmin status command), but they can't write (or remove) files or folders.

What port does Redis run on?

TCP Port 6379 is the default port for the Redis server.
How to change the port number on which the Redis server runs?

Modify the Redis server configuration file and provide the starting port to make the changes permanent.

Open the terminal and make the following changes to the configuration:

sudo nano /etc/redis/redis.conf


Change the value to your selected port by locating the entry as shown below.

port 6379

 

Save and close the file once you've specified your preferred port. To implement the modifications, restart the Redis service.

How to check whether the Redis server is running?

We can check if Redis is running from the command line:

redis-cli ping

 

We should get back

PONG

 

It indicates Redis is up and running.

How do we run Redis?

To launch the Redis client, open a terminal and type redis-cli. This will establish a connection to your local server,

$redis-cli 
redis 127.0.0.1:6379> 
redis 127.0.0.1:6379> PING  
PONG

Conclusion

In this article, we have extensively discussed the instructions to install Redis on different operating systems. We looked at:

  1. Installing Redis from the source
  2. Installing Redis on Linux
  3. Installing Redis on Windows
  4. Installing Redis on macOS

 

We hope this blog has helped you enhance your knowledge regarding the installation of Redis. You can use Coding Ninjas Studio to learn about Redis data types and Redis configuration and practice various DSA questions to prepare for interviews. It will help you in mastering effective coding techniques, and you will also get interview experiences with people working in big companies.

Do upvote our blog to help other ninjas grow. Happy Coding!

Previous article
Elasticsearch vs Redis
Next article
Redis Clients
Live masterclass