On this article we will discuss how to install Redis version 5.0 on CentOS 8.
Redis is an open source in-memory data structure store, used as a database, cache and message broker. Redis is an acronym for Remote dictionary server. Redis supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes with radius queries and streams.
Redis is in the family of databases called key-value stores. The essence of a key-value store is the ability to store some data, called a value, inside a key. This data can later be retrieved only if we know the exact key used to store it. Often Redis it is called a data structure server because it has outer key-value shell, but each value can contain a complex data structure, such as a string, a list, a hashes, or ordered data structures called sorted sets as well as probabilistic data structures like hyperloglog.
Redis Installation on CentOS 8
The installation of Redis is quite simple, on this articel we are using Redis repository that was enabled on CentOS 8 system. Installation steps will be explained below :
We have to prepare the system and all related supported matters for installation.
- CentOS 8 system with enough free memory for Redis
- Account with sudo privilege
- Update the CentOS 8 system
We will using Redis repository on CentOS 8 for installation.
1. Install Redis
[ramans@otodiginet ~]$ sudo dnf install @redis
The output will be :
Last metadata expiration check: 0:10:05 ago on Wed 07 Oct 2020 06:24:43 PM PDT. Dependencies resolved. Package Architecture Version Repository Size Installing group/module packages: redis x86_64 5.0.3-2.module_el8.2.0+318+3d7e67ea AppStream 925 k Installing module profiles: redis/common Enabling module streams: redis 5 Transaction Summary Install 1 Package Total download size: 925 k Installed size: 3.2 M Is this ok [y/N]: y Downloading Packages: redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64.rpm 357 kB/s | 925 kB 00:02 Total 234 kB/s | 925 kB 00:03 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64 1/1 Installing : redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64 1/1 Running scriptlet: redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64 1/1 Verifying : redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64 1/1 Installed products updated. Installed: redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64 Complete!
The output will be :
2. Enable and Start Redis Services
[ramans@otodiginet ~]$ sudo systemctl enable redis Created symlink /etc/systemd/system/multi-user.target.wants/redis.service → /usr/lib/systemd/system/redis.service. [ramans@otodiginet ~]$ sudo systemctl start redis
Then we check the Redis status, bu submitting command line :
[ramans@otodiginet ~]$ sudo systemctl status redis
The output will be :
● 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 Wed 2020-10-07 18:35:31 PDT; 1min 0s ago Main PID: 11761 (redis-server) Tasks: 4 (limit: 49614) Memory: 6.8M CGroup: /system.slice/redis.service └─11761 /usr/bin/redis-server 127.0.0.1:6379 Oct 07 18:35:31 otodiginet systemd: Starting Redis persistent key-value database… Oct 07 18:35:31 otodiginet systemd: Started Redis persistent key-value database.
Enable Redis To Listen in All Network Interface
Now, the Redis has been installed and running on CentOS 8 system, the next step is configuring Redis. There are lot of parameters that can be configured to fit for our needs. The configuration file is located on
/etc/redis.conf file. On this tutorial, we will enable the Redist to be accessed from other network.
By default Redis services is only enable for local network, then we will enable it to all interface network. By changing local IP address binding to all network interface (binding on 0.0.0.0 IP Address).
ramans@otodiginet ~]$ sudo vi /etc/redis.conf
We are suggested to set password for AUTHentication. The section is reside on Security are of this file. On this tutorial we set
Warning: since Redis is pretty fast an outside user can try up to 150k passwords per second against a good box. This means that you should use a very strong password otherwise it will be very easy to break. # requirepass foobared requirepass otopass01
To make the change, we have to restart Redis services.
[ramans@otodiginet ~]$ sudo systemctl restart redis
Then we verify the IP Address binding and listening port, by submitting command line below:
[ramans@otodiginet ~]$ ss -tunelp | grep 6379 tcp LISTEN 0 128 127.0.0.1:6379 0.0.0.0:* uid:966 ino:107969 sk:e <->
If we are deploying firewall on our system, the we make port 6379 to be allowed, by sybmitting command line below:
[ramans@otodiginet ~]$ sudo firewall-cmd --add-port=6379/tcp --permanent success [ramans@otodiginet ~]$ sudo firewall-cmd --reload success
We have set password for entering Redis on
/etc/redis.conf file. On this section we will try to connect to our Redis. We have to supply the password for authenticating.
Here is the steps for connecting to Redis locally.
ramans@otodiginet ~]$ redis-cli 127.0.0.1:6379> AUTH otopass01 OK 127.0.0.1:6379> info server Server redis_version:5.0.3 redis_git_sha1:00000000 redis_git_dirty:0 redis_build_id:28849dbea6f07cc8 redis_mode:standalone os:Linux 4.18.0-193.14.2.el8_2.x86_64 x86_64 arch_bits:64 multiplexing_api:epoll atomicvar_api:atomic-builtin gcc_version:8.3.1 process_id:1498 run_id:2fd45c6509147e03849201692ba664dfaa9e4aa4 tcp_port:6379 uptime_in_seconds:500 uptime_in_days:0 hz:10 configured_hz:10 lru_clock:8449068 executable:/usr/bin/redis-server config_file:/etc/redis.conf
So far, we have install and tried to connect to our Redis, and all steps are successfully completed.
The Redis version 5.0.3 installation on CentOS 8 is completed done. For more information about Redis can be found on redis.io website. Just drop your comments for your insight on Redis. Have a nice day, Stay at home and stay safe.