Skip to the content.

Redis - Setup

Basic Concepts

Installation

Ubuntu

System Repo

apt install redis systemd

Official Repo

# for minimal distribution (such as a Docker container)
apt install lsb-release

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
apt update
apt install redis

Or

snap install redis

CentOS

apt install redis systemd

Configuration

# /etc/sysctl.d/30-redis.conf

vm.swappiness = 0
vm.overcommit_memory = 1
net.core.somaxconn = 4096
net.core.netdev_max_backlog = 4096
net.ipv4.tcp_max_syn_backlog = 4096
systemctl restart procps.service
# /etc/security/limits.d/redis.conf

redis  soft  nofile  65535
redis  hard  nofile  65535
# /etc/redis/redis.conf

#bind * -::*
protected-mode yes
#tcp-backlog <4096>
appendonly yes
echo never > /sys/kernel/mm/transparent_hugepage/enabled

systemctl start|stop|status|restart redis
# Ubuntu
systemctl enable|disable redis-server
systemctl start|stop|restart|status redis-server

# CentOS
systemctl enable|disable redis
systemctl start|stop|restart|status redis

RedisJson Module

# /etc/redis/redis.conf

# RedisJson
loadmodule /path/to/librejson.dylib  # macOS
loadmodule /path/to/librejson.so     # Linux

References