How to install Redis on CentOs8 Print

  • 0

Redis:
According to Wikipedia, this Remote Dictionary Server is an in-memory data structure project. It implements a distributed, in-memory key-value database. This process comes with optional durability.

Benefits of using Redis
You might have heard and been aware of MySQL, the fully managed database to deploy cloud-native applications. But Redis is a NoSQL database. The important property of Redis that it stores data as a key-value pair whereas in regular databases, you have to create rows.

The regular databases use columns and tables to associate them with each other and define different filters and titles to every record. You have to manually add the information in each row to fill the whole database with information. Unlike relational databases like MySQL, Redis is a NoSQL database which stores data as a key-value pair.

The data feeding process in Redis has made it very easy, simple, and straightforward. The whole system is quite flexible and intelligently connected. Redis gives you maximum productivity without taking any substantial effort from you.

The most significant use of Redis is that people use it as a catching system. It is a flexible database, yet it provides you the persistence and connectivity in high fidelity to all data written on it.

The storage and retrieval process, both are super-fast making it possible to write and retrieve data like a flash. The cache system is robust and can outrun the interruptions and withstand failures.

Ships are connected with the master and slave data connectivity processes. When you made a change into the master node, the master-slave replication feature applies the single change on the master node to all the slave nodes connected. Redis astounds programmers and data analysts by a staggering storage ability to handle large keys and value pairs up to 512 MB.

Raspberry Pi and Arduino to support IoT apps easily install and handle Redis because of its very small footprint.

This is a cross-platform system, which is the most productive, efficient, and flexible database; you can even install it on Windows, Mac, and Linux server.

Abstract data structure Redis supports:
There are various kinds of abstract data structures which it supports flexibility, some of these are:

Strings
Lists
Maps
Sets
Sorted sets
HyperLogLogs
Bitmaps
Streams
Spatial indexes
Salvatore Sanfilippo developed this project in 2019, and Redis Labs sponsored this project; that's why it is called Redis.

Install Redis on CentOS 8:
This key value-data structure is mainly used as a database. People also use it as a message broker or as a cache. This database supports a wide variety of languages with high-performance flexibility. In this tutorial, you would learn how to install Redis on CentOS 8.

Prerequisites:
Before you can start Redis's installation process on CentOS 8, make sure that you have a non-root user account on your server with Sudo privileges. Always enable IPv6 on your server, or you will not have the installation started.

Install Redis:
This package is not readily available in CentOS 8. You need to install the Redis form other repositories. Like:

Install

Yum-utils
Epel-release packages
Use the following command to complete the installation:

sudo yum install epel-release yum-utils

Then Add the Remi repository using this command:

sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Enable this repository by running the below command:

sudo yum-config-manager --enable remi

Now install Redis run give this command:

sudo yum install redis

You will have to start Redis through this command manually:

sudo systemctl start redis

Then enable Redis service through this:

sudo systemctl enable redis

Type this to check the status of Redis:

sudo systemctl status redis-server

This command should give you the following output:

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 Sat 2019-03-21 15:12:03 PST; 39s ago

Main PID: 2157 (redis-server)

CGroup: /system.slice/redis.service

└─2157 /usr/bin/redis-server 127.0.0.1:6379

If you receive the output mentioned above, it means you have completed one process of installation. Now it's time to move on to the next step.

Binding Redis
Redis is not accessible by other hosts because of the default feature. You need to bound it to the localhost (127.0.0.1). You have to take the following steps.

Open the Redis configuration file by typing:

sudo nano /etc/redis.conf

Bind it by removing the hash from the beginning:

bind 127.0.0.1

Now replace your IP address with the server:

bind 127.0.0.1 YOUR_IP_ADDRESS

Pressing CTRL+x will save the commands and close the interface.

Restart Redis and type this command:

sudo systemctl restart redis-server

Now run the below command to make the confirmation for changes:

tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 14222/redis-server

tcp6 0 0 153.168.93.106:6379 *:* LISTEN 14222/redis-server

Setup FirewallD form remote host by:

sudo firewall-cmd --new-zone=redis –permanent

Now it’s time to open port 6379 permanently:

sudo firewall-cmd --zone=redis --add-port=6379/tcp –permanent

Replace your client IP address with the machine by giving the following command:

sudo firewall-cmd --zone=redis --add-source=YOUR_CLIENT_IP_ADDRESS –permanent

Reload the firewall and confirm the effect of changes by typing:

sudo firewall-cmd –reload

To confirm everything has gone as planned, type the following commands:

redis-cli

Redis shell will open before you, and to confirm the authenticity, type the following word:

ping

You must see this exact output after the previous command:

PONG

If you receive the output mentioned above, now it's time to exit the redis-cli shel by using this command:

exit

Testing Using Redis-client
Run Redis-cli to start testing by typing:

redis-cli

In order to find out the authentic execution, first of all, store a value with the key myname to store value, John use the following command:

set myname "John"

You must see the following output:

OK

Now to fetch the value of myname, run the following command:

get myname

In response, you must have the following output:

John

It is time to exit the Redis-cli by typing:

exit

Configure Redis Authentication
Configure Redis Authentication to require AUTH before client can make any processing:

requirepass

Example:

requirepass StrongPassword

Set Persistent Store for Recovery
Change the appendonlyvalue to yes by:

appendonly yes

appendfilename "appendonly.aof"

Restart Redis service:

sudo systemctl restart redis

For active firewalld service, allow port 6379:

sudo firewall-cmd --add-port=6379/tcp --permanenent

sudo firewall-cmd –reload

Check redis service status:

$ sudo systemctl status redis

You will have the following output:

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 Sat 2018-12-29 10:11:56 EAT; 9s ago

Process: 30485 ExecStop=/usr/libexec/redis-shutdown (code=exited, status=0/SUCCESS)

Main PID: 30500 (redis-server)

Tasks: 4 (limit: 11510)

Memory: 6.4M

CGroup: /system.slice/redis.service

└─30500 /usr/bin/redis-server 0.0.0.0:6379

Dec 29 10:11:56 rhel8.local systemd[1]: Stopped Redis persistent key-value database.

Dec 29 10:11:56 rhel8.local systemd[1]: Starting Redis persistent key-value database…

Dec 29 10:11:56 rhel8.local systemd[1]: Started Redis persistent key-value database.

Connect to Redis
Confirm your local connectivity by:

$ redis-cli

127.0.0.1:6379> INFO

NOAUTH Authentication required.

Test authenticate:

127.0.0.1:6379> AUTH

If everything is fine, you will have the following output:

OK

Check Redis information.

127.0.0.1:6379> INFO

You will see the following output:

127.0.0.1:6379> INFO Server

Server

redis_version:4.0.10

redis_git_sha1:00000000

redis_git_dirty:0

redis_build_id:fdf31b4ab3504500

redis_mode:standalone

os:Linux 4.18.0-32.el8.x86_64 x86_64

arch_bits:64

multiplexing_api:epoll

atomicvar_api:atomic-builtin

gcc_version:8.2.1

process_id:30500

run_id:d8c5ba56a0735a6831a0b3467c3efa95ac174cdd

tcp_port:6379

uptime_in_seconds:222

uptime_in_days:0

hz:10

lru_clock:2563866

executable:/usr/bin/redis-server

config_file:/etc/redis.conf

Perform Redis Benchmarking
For 10 parallel connections, for a total of 100k requests:

# redis-benchmark -h 127.0.0.1 -p 6379 -n 100000 -c 10

The screen would show this entire result:

# redis-benchmark -h 127.0.0.1 -p 6379 -n 100000 -c 10

..................................................

100.00% <= 0 milliseconds

85470.09 requests per second

====== LRANGE_500 (first 450 elements) ======

100000 requests completed in 1.17 seconds

10 parallel clients

3 bytes payload

keep alive: 1

100.00% <= 0 milliseconds

85397.09 requests per second

====== LRANGE_600 (first 600 elements) ======

100000 requests completed in 1.18 seconds

10 parallel clients

3 bytes payload

keep alive: 1

100.00% <= 0 milliseconds

84530.86 requests per second

====== MSET (10 keys) ======

100000 requests completed in 1.18 seconds

10 parallel clients

3 bytes payload

keep alive: 1

100.00% <= 0 milliseconds

84961.77 requests per second

To show connected clients, use:

127.0.0.1:6379> client list

The result would be:

id=185 addr=127.0.0.1:54300 fd=8 name= age=75 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client

How to perform Redis Benchmark

Built-in tool the Redis-benchmark allows you to see system’s performance statistics. You can have access to data transfer rate, throughput or latency are a few capabilities form a long list of possibilities.

Some of the command options are as follow:

-n:

Defines the number of requests
The default is 100000
-c:

Defines the number of parallel connections
The default value is 50
-p:

Redis port
Which by default is 6379
-h:

Used to define the host
The default value is set to localhost (127.0.0.1)
-a:

Accustomed to prompt for a password
If the server needs authentication
-q:

Stands for quiet mode
Displays the number of average requests made per second
-t:

Used to run a combination of tests
-P:

Used for pipelining
Also, for enhanced performance
-d:

Specifies the data size
Bytes for getting and SET values
By default, this is set to 3 bytes

Conclusion:
Congratulation, you have successfully installed and configured Redis on CentOS 8. If you find any difficulty in installation contact our support team.

If you are looking for a dedicated server, click here and get the best price and features which you can imagine on the internet.


Was this answer helpful?

« Back