1

Install Redis from Source on Debian 10

 2 years ago
source link: https://www.vultr.com/docs/install-redis-from-source-on-debian-10
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
<?xml encoding="utf-8" ??>

Redis is an in-memory data structure store used as a database, message broker, and cache. It implements a distributed key-value store system. It supports many kinds of data structures. In this tutorial, we will build Redis from source on Debian 10.

Prerequisites

1. Install Dependencies

Build tools

To build Redis, we need build tools like compilers and make. Debian bundles these packages in the build-essential metapackage. We also need the pkg-config package. To install these dependencies, run

# apt install pkg-config build-essential -y

Git

Git is a source control tool that will be used to retrieve the source code from the repository. Install it with the following command.

# apt install git -y

2. Install Redis

First, you must choose which version of Redis you are going to install. You can select the latest (unstable) version directly from Git, or you can get old versioned stable release.

Create the install directory

First, we will change directories to /opt (and create it in case it does not exist), a place to store software not installed through the package manager.

# mkdir /opt
# cd /opt

Select Version to Install

Unstable

To get the very latest Redis from git (unstable):

# git clone https://github.com/antirez/redis

Change directories to the folder.

# cd redis

Stable

To get the latest stable, find the link at the Redis download page. As of this writing, the latest stable Redis is 6.0.5.

# wget http://download.redis.io/releases/redis-6.0.5.tar.gz

Extract the compressed archive (adjusting the version number to the version you downloaded).

# tar xf redis-6.0.5.tar.gz

Change directories to the folder.

# cd redis-6.0.5

Build Redis

Redis uses a Makefile build system. Build it with the following command.

# make

Install it:

# make install

3. Using Redis

We will now demonstrate some of Redis's features. Start a Redis server in the background (daemonized):

# redis-server --daemonize yes

Now, connect to the server with redis-cli:

# redis-cli

Test Connectivity

The client's connectivity can be tested with the ping command.

127.0.0.1:6379> ping

You should see in response:

PONG

Assign a Value to a Key

Test assigning a value to a key with the following command.

127.0.0.1:6379> set test "redis works"

You should see in response:

OK

Retrieve the value of the key.

127.0.0.1:6379> get test

You should see in response:

"redis works"

Exit redis-cli

Use the exit command to exit the Redis CLI interface.

127.0.0.1:6379> exit

Conclusion

Congratulations, you have now built from source and tested Redis on a Debian 10 Vultr instance.

Want to contribute?

You could earn up to $600 by adding new articles


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK