How To Install Redis on Manjaro
In this tutorial, we will show you how to install Redis on Manjaro. Redis, the lightning-fast, in-memory key-value data store, has earned its place as a vital component in the tech stack of many applications. Whether you’re dealing with caching, real-time analytics, or a data store, Redis is a powerhouse.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of Redis on a Manjaro Linux.
Prerequisites
- A server or desktop running one of the following operating systems: Manjaro, and other Arch-based distributions.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- Ensure that your Manjaro system is connected to the internet. This is crucial as it allows you to download the required packages and the Redis installation.
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Redis on Manjaro
Step 1. Before diving into the Redis installation, it’s crucial to make sure your Manjaro system is up to date. Open a terminal and execute the following commands:
sudo pacman -Syu
Step 2. Installing Memcached on Manjaro.
- Method 1: Using Pacman to Install Redis.
Let’s install Redis via Pacman:
sudo pacman -S redis
Once installed, it’s good practice to verify the Redis version. This is how you can do it:
redis-server --version
- Method 2: Compiling and Installing Redis from Source.
You can download the latest version of Redis from the official website or using the following command:
wget https://download.redis.io/releases/redis-7.2.1.tar.gz
Next, extract the downloaded source code and navigate to the Redis source directory:
tar xzf redis-7.2.1.tar.gz cd redis-7.2.1
The heart of the process involves compiling and installing Redis from the source. Here’s how it’s done:
make sudo make install
To verify that Redis has been installed successfully, you can run the following command:
redis-server --version
Step 3. Using Redis from the CLI.
The true magic of Redis begins when you start the Redis server. Use the following command to commence the journey:
redis-server
Is the Redis server alive and kicking? A quick ping will tell you:
redis-cli ping
To halt the Redis server, use this command:
redis-cli shutdown
Step 4. Configuring Redis.
Redis configuration settings are stored in configuration files. On a Manjaro system, these files are typically located in the /etc/redis/
directory. The primary configuration file is named redis.conf
. You can use a text editor, such as nano
or vim
, to make changes to these configuration files.
To access the Redis configuration file, you can use the following command:
sudo nano /etc/redis/redis.conf
Basic Redis Configuration
- Port Configuration:
The default port that Redis listens on is 6379. You can change this port if needed, but ensure that the new port is not in use by other services.
port 6379
- Bind Configuration:
You can specify the network interfaces on which Redis will listen for incoming connections. To bind to all available network interfaces, use:
bind 0.0.0.0
To bind to a specific IP address, replace 0.0.0.0
with the IP address.
- Password Protection:
To secure your Redis server, you can set a password. Uncomment the
requirepass
directive and replace'yourpassword'
with your chosen password:
requirepass yourpassword
with this configuration, clients connecting to Redis will be required to provide the password.
- Save Configuration:
Redis periodically saves data snapshots to disk to ensure data persistence. The
save
directive is used to specify when these snapshots occur. By default, Redis saves the dataset:- After 900 seconds (15 minutes) if at least one key has changed.
- After 300 seconds (5 minutes) if at least 10 keys have changed.
- After 60 seconds if at least 10000 keys have changed.
You can adjust these settings to suit your needs.
- Maximum Memory Configuration:You can limit the amount of memory Redis uses. The
maxmemory
directive defines this limit and themaxmemory-policy
specifies the eviction policy to use when the memory limit is reached. For example, to limit Redis to 1GB of memory and use the Least Recently Used (LRU) eviction policy:
maxmemory 1gb maxmemory-policy allkeys-lru
Congratulations! You have successfully installed Redis. Thanks for using this tutorial to install the latest version of Redis on the Manjaro system. For additional help or useful information, we recommend you check the official Redis website.