What is Redis?

According to wikipedia, REDIS (REmote DIctionary Server) is a software project that implements data structure servers. It is open-source, networked, in-memory, and stores keys with optional durability.
According to monthly rankings by, Redis is often ranked:

  • the most popular key-value database,
  • #4 NoSQL database in user satisfaction and market presence based on user reviews,
  • the most popular NoSQL database in containers,
  • the #1 NoSQL database among Top 50 Developer Tools & Services.



[email protected] # apt-get install redis-server

Centos/Redhat/Scientific Linux

[email protected] # yum install redis
[email protected] # systemctl start redis # if you are using systemd

Configuration and remarquable parameters

The configuration file is /etc/redis/redis.conf for Debian/Ubuntu and /etc/redis.conf for Redhat Centos. The main remarquable parameters are :

Listening address


Listening port

port 6379

Daemonize or not the server

daemonize yes

Database number

Set the number of databases.

databases 16

Client number

maxclient 3

Max memory

maxmemory 128m

Max memory policy

Once the allocated maxmemory is consumed, Redis will process to key eviction. There are 5 different manners:

  • volatile-lru -> remove the key with an expire set using an LRU algorithm : evict keys trying to remove the less recently used (LRU) keys first, but only among keys that have an expire set, in order to make space for the new data added
  • allkeys-lru -> remove any key accordingly to the LRU algorithm : evict keys trying to remove the less recently used (LRU) keys first, in order to make space for the new data added.
  • volatile-random -> remove a random key with an expire set
  • allkeys-random -> remove a random key, any key
  • volatile-ttl -> remove the key with the nearest expire time (minor TTL)
  • noeviction -> don’t expire at all, just return an error on write operations
Related concept:   Find Sound card details in Linux/Unix

For production use it is recommanded to set this parameter to volatile-lru.

maxmemory-policy volatile-lru

Redis command line interface

To access Redis CLI use redis-cli command:

redis-cli -p REDIS_PORT

if not listening on localhost:

redis-cli -p REDIS_PORT -h REDIS_HOST

Replication Master-Slaves and Security

Slave side

After connecting to redis-cli:

SLAVEOF master_ip master_port

The master can be protected by a password. In this case the slave must be authenticated before receiving the replication

MASTERAUTH master_password

Master side

If you want to protect your data with a password you can set it like below:


Replication status

To obtain replication status you can use:

# Replication

To stop replication, on slave :


Hope that this blogs helps you to set up correctly one of the most popular memory-cache system. Feel free to read our blogs and leave feedbacks. Till next time.