How to Install Redis on Mac

November 5, 2020

Introduction

Redis is an open-source data storage solution. It is primarily used as a database, cache storage, or message broker due to the way it stores key-value pairs.

Redis stands out with its flexibility and high performance, wide language support, and high availability.

In this tutorial, you will learn several ways to install and configure Redis on your Mac computer.

How to install Redis on Mac

Prerequisites

  • A system running macOS Catalina
  • Access to the terminal window
  • A user with admin-level privileges

Installing Redis on Mac

There are two ways to install Redis on Mac:

      • Installing Redis from scratch.
      • Using package management software, like Homebrew.

Homebrew automates most of the installation process, making it quick and easy to add Redis to your system. It also provides more options when configuring Redis, and makes uninstalling it a lot simpler.

Option 1: Install Redis on Mac With Homebrew

If you don’t have Homebrew, install it with the following command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

If you already have a copy of Homebrew installed, update it by using:

brew update

With an up-to-date version of Homebrew, install Redis by using the command:

brew install redis

Using this command produces the following output:

Installing Redis on Mac using Homebrew

Option 2: Install Redis on Mac Without Homebrew

The second method enables you to install Redis on Mac without Homebrew.

To install Redis without Homebrew, use the following commands:

mkdir redis && cd redis
curl -O http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz
cd redis-stable
make
make test
sudo make install

Where:

  • mkdir redis && cd redis – Creates a folder called ‘redis’ and moves you to the newly created folder.
  • curl -O http://download.redis.io/redis-stable.tar.gz – Downloads the Redis installation archive.
  • tar xzvf redis-stable.tar.gz – Unpacks the ‘redis-stable‘ installation archive.
  • cd redis-stable – Moves you to the ‘redis-stable’ folder.

The remaining commands install the Redis software.


Note: NoSQL databases, like Redis, are meant to run efficiently in distributed clusters that scale out horizontally. Using Docker to deploy Redis in a container makes horizontal scaling a routine, straightforward process.


Starting and Configuring Redis on Mac

Depending on the installation method used, there are two ways to launch Redis on your system.

If you installed Redis using Homebrew, use Homebrew to launch it:

brew services start redis

If you installed Redis without Homebrew, use the following code:

redis-server

Start Redis server on Mac

Modify your Redis instance by using the commands listed below.

Launch Redis on Boot

To have Redis launch on system boot, use:

ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents

Stop Redis from Launching on Boot

To stop Redis from starting upon system boot, use:

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

Start Redis Server

There are two ways to start your Redis server:

      • Using the launchctl
      • Using the Redis configurations file.

When starting Redis with the launchctl command, use the following syntax:

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

If you want to start Redis using the configuration file, use:

redis-server /usr/local/etc/redis.conf

By default, the Redis configuration file is located at /usr/local/etc/redis.conf.

Test if Redis Server is Running

Ping your Redis server to verify if it’s running:

redis-cli ping

The system responds with a ‘pong’ if the server is up and running.

Uninstalling Redis on Mac

To uninstall Redis, use Homebrew with the following command:

brew uninstall redis

Note: Remember to also remove Redis files from your hard-drive by using:

rm ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

Conclusion

After following this tutorial, you now know how to install, configure, and uninstall Redis on your Mac computer.

For more helpful tips on using Redis, check out our comprehensive guide to Redis data types.

Aleksandar Kovačević
Aleksandar Kovacevic is an aspiring Technical Writer at phoenixNAP. With a background in both design and writing, he aims to bring a fresh perspective to writing for IT, making complicated concepts easy to understand and approach.
Next you should read
How to Clear Redis Cache
October 26, 2020

Redis is used as a database, cache storage, and message broker thanks to its ability to store key-value...
Read more
Redis Data Types with Commands: Comprehensive Guide
September 4, 2020

The article covers seven basic Redis Data Types, including HyperLogLogs and Bitmaps. Each data type is...
Read more
How to Deploy and Run Redis in Docker
July 23, 2020

The tutorial shows you how to deploy Redis using the Docker run command. Also, learn how to deploy Redis on...
Read more
How to Install Redis on Ubuntu 20.04 / 18.04
July 7, 2020

Install Redis on Ubuntu 20.04 in a couple of simple steps by following this tutorial. This guide also shows...
Read more
  • © 2021 Copyright phoenixNAP | Global IT Services. All Rights Reserved.