Come installare Redis Server su Rocky Linux
Su questa pagina
- Conclusione
Prerequisiti
- Un sistema Rocky Linux. Assicurati che tutti i pacchetti e i repository siano aggiornati all'ultima versione
- Un utente root o un utente con privilegi root. Utilizzerai questo utente per installare nuovi pacchetti e modificare le configurazioni di sistema.
Installazione di Redis dal repository AppStream
sudo dnf install redis
sudo systemctl enable redis
sudo systemctl start redis
sudo systemctl status redis
Installazione di Redis dall'origine
sudo dnf install epel-release -y
sudo dnf group install "Development Tools" -y
sudo dnf install jemalloc lua hiredis linenoise -y
sudo dnf install openssl-devel systemd-devel -y
sudo adduser --system --user-group --no-create-home --shell /sbin/nologin redis
sudo mkdir -p /var/lib/redis
sudo chown -R redis:redis /var/lib/redis
cd /usr/src/
wget https://download.redis.io/releases/redis-6.2.5.tar.gz
tar -xzvf redis-6.2.5.tar.gz
cd redis-*/
sudo make BUILD_TLS=yes USE_SYSTEMD=yes
- BUILD_TLS=abilita il supporto TLS per Redis,
- USE_SYSTEMD=abilita il supporto per systemd, il sistema Rocky Linux che usa systemd come suo sistema init.
sudo make test
\o/ All tests passed without errors!
Cleanup: may take some time... OK
make[1]: Leaving directory '/usr/src/redis-6.2.5/src'
sudo make PREFIX=/usr install
redis-server --version
redis-cli --version
Configurazione di Redis
mkdir -p /etc/redis
cp /usr/src/redis-*/redis.conf /etc/redis/redis.conf
sudo nano /etc/redis/redis.conf
bind 127.0.0.1
daemonize yes
supervised systemd
dir /var/lib/redis
requirepass AJds9dshsd8wqejdw82389r3ej3983jk
Configurazione del file di servizio per Redis
cd /usr/src/redis-*/utils/
cp systemd-redis_server.service /etc/systemd/system/redis-server.service
sudo nano /etc/systemd/system/redis-server.service
[Unit]
...
AssertPathExists=/var/lib/redis
[Service]
...
ExecStart=/usr/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/bin/redis-cli shutdown
Restart=alway
...
User=redis
Group=redis
WorkingDirectory=/var/lib/redis
sudo systemctl daemon-reload
sudo systemctl enable redis-server
sudo systemctl start redis-server
sudo systemctl status redis-server
Rinominare o disabilitare Redis Dangerous Command
sudo nano /etc/redis/redis.conf
rename-command FLUSHDB ""
rename-command FLUSHALL ""
rename-command DEBUG ""
rename-command SHUTDOWN SHUT_ME_DOWN
rename-command CONFIG CONFIG_ME_NOW
sudo systemctl restart redis-server
Verificare l'installazione di Redis
redis-cli
redis-cli -h 127.0.0.1 -p 6379
auth AJds9dshsd8wqejdw82389r3ej3983jk
ping
CONFIG get bind
CONFIG_ME_NOW get bind
CONFIG_ME_NOW get supervised
Conclusione