GNU/Linux >> Linux Esercitazione >  >> Cent OS

Come installare e configurare Redis 6 su Rocky Linux/Centos 8

In questo tutorial impareremo come installare Redis 6 su Rocky Linux/Centos 8.

Contenuti correlati

  • Come installare e configurare Redis 6 su Fedora 34
  • Come eseguire Redis 6 con Docker e Docker-Compose
  • Come installare e configurare Postgres 14 su Fedora 34
  • Cose da fare su una nuova installazione desktop di Fedora 34

Prerequisiti

Per seguire, assicurati di avere:

  • Un server Rocky Linux/Centos 8 aggiornato
  • Accesso a Internet
  • Accesso root al server o utente con accesso sudo

Indice dei contenuti

  1. Aggiorna il server Rocky Linux/Centos 8
  2. Installazione di Redis
  3. Configurazione di Redis
  4. Collegamento ed esecuzione di operazioni di base in Redis
  5. Prestazione Redis Benchmark

1. Aggiorna Rocky Linux/Centos 8 Server

Prima di procedere, assicurati che il server sia aggiornato utilizzando questo comando:

sudo dnf -y update

Assicuriamoci anche che vim sia installato usando questo comando poiché lo useremo in seguito:

sudo dnf install -y vim

2. Installazione di redis

Redis 6 non è disponibile nei server Rocky Linux/Centos 8 predefiniti. Utilizzeremo la versione remi per installare il modulo Redis che ci consentirà di installare redis 6.

Abilita il repository Remi usando questo comando:

sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y

Quindi elenca redis usando questo:

$ sudo dnf module list redis
Last metadata expiration check: 0:02:05 ago on Fri 29 Oct 2021 08:08:41 PM UTC.
Rocky Linux 8 - AppStream
Name            Stream             Profiles             Summary
redis           5 [d]              common [d]           Redis persistent key-value database
redis           6                  common [d]           Redis persistent key-value database

Remi's Modular repository for Enterprise Linux 8 - x86_64
Name            Stream             Profiles             Summary
redis           remi-5.0           common [d]           Redis persistent key-value database
redis           remi-6.0           common [d]           Redis persistent key-value database
redis           remi-6.2           common [d]           Redis persistent key-value database

Abilita redis 6.2

sudo dnf module enable redis:remi-6.2 -y

Installa redis

sudo dnf install redis

Utilizzare questo comando per confermare il pacchetto redis installato:

$ rpm -qi redis
Name        : redis
Version     : 6.2.6
Release     : 1.el8.remi
Architecture: x86_64
Install Date: Fri 29 Oct 2021 08:14:06 PM UTC
Group       : Applications/Databases
Size        : 4522111
License     : BSD
Signature   : RSA/SHA256, Mon 04 Oct 2021 12:34:26 PM UTC, Key ID 555097595f11735a
Source RPM  : redis-6.2.6-1.el8.remi.src.rpm
Build Date  : Mon 04 Oct 2021 12:28:08 PM UTC
Build Host  : builder.remirepo.net
Relocations : (not relocatable)
Packager    : Remi Collet
Vendor      : Remi's RPM repository <https://rpms.remirepo.net/>
URL         : http://redis.io
Bug URL     : https://forum.remirepo.net/
Summary     : A persistent key-value database
Description :
Redis is an advanced key-value store. It is often referred to as a data
structure server since keys can contain strings, hashes, lists, sets and
sorted sets.

You can run atomic operations on these types, like appending to a string;
incrementing the value in a hash; pushing to a list; computing set
intersection, union and difference; or getting the member with highest
ranking in a sorted set.

In order to achieve its outstanding performance, Redis works with an
in-memory dataset. Depending on your use case, you can persist it either
by dumping the dataset to disk every once in a while, or by appending
each command to a log.

Redis also supports trivial-to-setup master-slave replication, with very
fast non-blocking first synchronization, auto-reconnection on net split
and so forth.

Other features include Transactions, Pub/Sub, Lua scripting, Keys with a
limited time-to-live, and configuration settings to make Redis behave like
a cache.

You can use Redis from most programming languages also.

Ora che il servizio è stato installato, avviamolo con questo comando:

sudo systemctl start redis

Abilita il servizio in modo che si avvii all'avvio:

$ sudo systemctl enable redis
Created symlink /etc/systemd/system/multi-user.target.wants/redis.service → /usr/lib/systemd/system/redis.service.

Dopo l'avvio del servizio, utilizzare questo comando per verificare lo stato del servizio:

$ sudo systemctl status redis
● redis.service - Redis persistent key-value database
   Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/redis.service.d
           └─limit.conf
   Active: active (running) since Fri 2021-10-29 20:16:17 UTC; 25s ago
 Main PID: 62643 (redis-server)
   Status: "Ready to accept connections"
    Tasks: 5 (limit: 23168)
   Memory: 7.3M
   CGroup: /system.slice/redis.service
           └─62643 /usr/bin/redis-server 127.0.0.1:6379

Oct 29 20:16:17 ip-10-2-40-54.us-west-2.compute.internal systemd[1]: Starting Redis persistent key-v>
Oct 29 20:16:17 ip-10-2-40-54.us-west-2.compute.internal systemd[1]: Started Redis persistent key-va>

Il Active: active (running) significa che il servizio è stato avviato correttamente.

3. Configurazione di Redis

Il file di configurazione di redis si trova in questo percorso /etc/redis/redis.conf . In questa sezione, aggiorneremo il file di configurazione di redis per consentire l'accesso remoto, per impostare una password di autenticazione, per aggiungere un file pid e per impostare l'archivio persistente per il ripristino.

Modifica il file di configurazione redis usando questo:

sudo vim /etc/redis/redis.conf

Per consentire l'accesso remoto all'istanza redis, associare redis a 0.0.0.0 utilizzando questa riga:

bind 0.0.0.0

Per impostare la password in redis, usa questo:

requirepass j2GfJuLFR8

Per aggiungere un file pid a redis:

pidfile /var/run/redis/redis-server.pid

Imposta l'archivio persistente per il ripristino modificando appendonlyvalue su yes

appendonly yes
appendfilename "appendonly.aof"

Riavvia il servizio redis per applicare le modifiche:

sudo systemctl restart redis

4. Connessione ed esecuzione delle operazioni di base in Redis

Se hai un servizio firewalld attivo, consenti la porta 6379

sudo firewall-cmd --add-port=6379/tcp --permanent
sudo firewall-cmd --reload

Connessione a redis in locale:

$ redis-cli

Per autenticarsi:

127.0.0.1:6379> auth j2GfJuLFR8
OK

Dovresti ricevere OK nell'uscita. Se inserisci una password errata, l'autenticazione non dovrebbe riuscire.

Controlla le informazioni redis.

127.0.0.1:6379> INFO

Questo produrrà un lungo elenco di dati. Puoi limitare l'output passando Section come argomento. Es.

127.0.0.1:6379> INFO Server
# Server
redis_version:6.2.6
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:b0cb03c693a4c6cc
redis_mode:standalone
os:Linux 4.18.0-305.3.1.el8_4.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:c11-builtin
gcc_version:8.4.1
process_id:62643
process_supervised:systemd
run_id:668853b6d043e64d7af95ab586c9aca9d6b8f49a
tcp_port:6379
server_time_usec:1635538653706020
uptime_in_seconds:76
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:8148701
executable:/usr/bin/redis-server
config_file:/etc/redis/redis.conf
io_threads_active:0

5. Esecuzione del benchmarking Redis

Esegui il benchmark con 15 connessioni parallele, per un totale di 10k richieste, contro redis locali per testarne le prestazioni.

$ redis-benchmark -h 127.0.0.1 -p 6379 -n 10000 -c 15 -a j2GfJuLFR8
====== PING_INLINE ======
  10000 requests completed in 0.23 seconds
  15 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 3600 1 300 100 60 10000
  host configuration "appendonly": no
  multi-thread: no

Latency by percentile distribution:
0.000% <= 0.055 milliseconds (cumulative count 2)
50.000% <= 0.127 milliseconds (cumulative count 5509)
75.000% <= 0.159 milliseconds (cumulative count 7514)

..........

99.940% <= 0.503 milliseconds (cumulative count 9994)
100.000% <= 0.607 milliseconds (cumulative count 10000)

Summary:
  throughput summary: 74074.07 requests per second
  latency summary (msec):
          avg       min       p50       p95       p99       max
        0.159     0.072     0.151     0.239     0.279     0.567

Per ulteriori opzioni ed esempi, usa:

$ redis-benchmark --help

Conclusione

Siamo riusciti a installare e configurare Redis 6 in Rocky Linux/Centos 8.


Cent OS
  1. Come installare PostgreSQL su CentOS 8 / Rocky Linux 8 / RHEL 8

  2. Come installare e configurare la finestra mobile in Rocky Linux/Centos 8

  3. Come installare il client FreeIPA su Rocky Linux/Alma Linux/CentOS 8

  4. Come installare e configurare Mono su Rocky Linux 8 e CentOS 8

  5. Come installare Redis su Rocky Linux 8

Come installare e configurare Redis su CentOS 8

Come installare Apache Maven su Rocky Linux / CentOS 8

Come installare Spotify su CentOS 8 / Rocky Linux

Come installare Rabbitmq in Rocky Linux/Alma Linux/Centos 8

Come installare Redis su CentOS 6

Come installare Redis su CentOS 7