Redis easily installed and updated on the server
Part Ⅰ – Only necessary for the update
- Shut down Redis and safely shut down data storage
Bash
root@server:~# redis-cli 127.0.0.1:6379> SHUTDOWN SAVE (1.89s) not connected> quit root@server:~#
- Stop Redis instance: ~# systemctl stop redis_6379 or ~# service redis_6379 stop
- Backup of the current Redis configuration /etc/redis/6379.conf and data files /var/lib/redis/6379/appendonly.aof and /var/lib/redis/6379/dump.rdb
Part Ⅱ – Installation / Update
Debian + Ubuntu
~# apt-get install build-essential
~# apt-get install tcl wget
CentOS
~# yum groupinstall 'Development Tools'
~# yum install tcl wget
Debian + Ubuntu + CentOS
~# wget http://download.redis.io/redis-stable.tar.gz
~# tar xvzf redis-stable.tar.gz
~# cd redis-stable/
~/redis-stable# make distclean
~/redis-stable# make
~/redis-stable# make test
...\o/ All tests passed without errors!...
~/redis-stable# make install
~/redis-stable# cd
~# cd utils/
~/utils# ./install_server.sh
Selected config:
Port : 6379
Config file : /etc/redis/6379.conf
Log file : /var/log/redis_6379.log
Data dir : /var/lib/redis/6379
Executable : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Success!
Starting Redis server...
Installation successful!
root@server:~/redis-stable/utils# cd
~/utils# cd
~# systemctl start redis_6379
~# systemctl status redis_6379
Display More
Open Redis configuration – Testing Redis with Ping Pong
~# redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>
Display Redis version
~# redis-server --version
Redis server v=5.0.5 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=346d28814696cac3
~#
Part Ⅲ – Configure server for Redis
Option A: Settings for overcommit_memory and somaxconn
~# echo never > /sys/kernel/mm/transparent_hugepage/enabled
~# echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf && sysctl -p
~# echo "net.core.somaxconn = 65535" >> /etc/sysctl.conf && sysctl -p
Check:
~# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
~# cat /proc/sys/net/core/somaxconn
65535
Option B: Settings for transparent_hugepage, overcommit_memory and somaxconn
Install the sysfsutils package:
~# apt install sysfsutils
and enter the following 3 lines in the file /etc/sysfs.conf (after the text):
kernel/mm/transparent_hugepage/enabled = never
vm.overcommit_memory = 1
net.core.somaxconn = 65535
Check:
~# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
~# sysctl -a | grep hugepage
sysctl: reading key "net.ipv6.conf.all.stable_secret"
sysctl: reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.eth0.stable_secret"
sysctl: reading key "net.ipv6.conf.eth1.stable_secret"
sysctl: reading key "net.ipv6.conf.lo.stable_secret"
vm.hugepages_treat_as_movable = 0
vm.nr_hugepages = 0
vm.nr_hugepages_mempolicy = 0
vm.nr_overcommit_hugepages = 0
~# cat /proc/sys/net/core/somaxconn
65535
(Default = 128)
~# sysctl -a | grep commit
sysctl: reading key "net.ipv6.conf.all.stable_secret"
sysctl: reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.eth0.stable_secret"
sysctl: reading key "net.ipv6.conf.eth1.stable_secret"
sysctl: reading key "net.ipv6.conf.lo.stable_secret"
vm.nr_overcommit_hugepages = 0
vm.overcommit_kbytes = 0
vm.overcommit_memory = 1
vm.overcommit_ratio = 50
Display More
All changed settings are displayed here in the Redis configuration file /etc/redis/6379.conf. The first two values are caused by the following configuration for system.d.
daemonize yes
supervised systemd
logfile /var/log/redis_6379.log
dir /var/lib/redis/6379
maxclients 10000
maxmemory 15GB (Server hat 32G Memory)
maxmemory-policy volatile-ttl
maxmemory-samples 5
appendonly yes
The Highlight – The great finale – Configure Redis for system.d
We create the file redis.service in /lib/systemd/system/redis.service with the following content:
[Unit]
Description=Redis In-Memory Data Store
After=network.target
[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=0755
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
[Install]
WantedBy=multi-user.target
Display More
Thus, the two following values must also be adapted in the Redis configuration /etc/redis/6379.conf.
daemonize yes
pidfile /var/run/redis/redis.pid
Then definitely reload the daemon and restart Redis.
~# systemctl daemon-reload
~# systemctl restart redis_6379
About the Author
Hola Hello ஹலோ Halo привет Hallo Salut Ciao Olá 你好 Γεια σας もしもし Pozdravljeni สวัสดี Habari ਹੈਲੋ Salve прывітанне
WoltLab POLSKI Polskie tłumaczenie
WoltLab ESPAÑOL – Traducción Español
WoltLab PORTUGUÊS Tradução Português
VieCode Rynek + Sklep + Leksykon w POLSKI
VieCode Mercado+Tienda+Léxico en ESPAÑOL
VieCode Mercado + Loja + Léxico em PORTUGUÊS
CLS EasyLink ESPAÑOL + PORTUGUÊS (BR) + POLSKI