How to Install Redis in RHEL 8
Redis (which means REmote DIctionary Server) is an open-source, well known and advanced in-memory data structure store, used as a database, cache and message broker. You can consider it as a store and a cache: it has a design where data is always modified and read from the main computer memory (RAM) but also stored on disk.
Redis features include, among others, built-in replication, transactions and different levels of on-disk persistence. It supports various data structures including strings, lists, sets, hashes, sorted sets with range queries, bitmaps and many more.
It is used as an ideal solution for building high-performance, scalable software, and web applications. It supports most programming languages out there including Python, PHP, Java, C, C#, C++, Perl, Lua, Go, Erlang and many others. Currently, it is being used by companies such as GitHub, Pinterest, Snapchat, StackOverflow and more.
Although Redis works in most POSIX systems such as Linux, *BSD, and OS X without external dependencies, Linux is the recommended platform for production deployments.
In this article, we will explain how to install Redis on RHEL 8 Linux distribution.
- RHEL 8 with Minimal Installation
- RHEL 8 with RedHat Subscription Enabled
- RHEL 8 with Static IP Address
Installing Redis Server on RHEL 8
1. In RHEL 8, the Redis meta-package is provided by the Redis module, which you can install using the DNF package manager.
# dnf module install redis OR # dnf install @redis
The following are some useful Redis set up hints before you proceed to start and configure the Redis service:
Make sure to set the Linux kernel overcommit memory setting to
1 by adding
vm.overcommit_memory = 1 to /etc/sysctl.conf configuration file.
Then apply the change by rebooting the system or run the following command to apply the setting immediately.
# sysctl vm.overcommit_memory=1
In Linux, the transparent huge pages features tends to significantly affect both memory usage and latency in a negative way. To disable it use the following echo command.
# echo never > /sys/kernel/mm/transparent_hugepage/enabled
In addition, also ensure that you set up swap in your system. It is suggested to set up as much as swap as memory.
2. Redis is designed to be a very long-running process in your server under Systemd, it can run as a service. To start the Redis service for now and enable it to auto-start at system boot time, use the systemctl utility as follows.
# systemctl start redis # systemctl enable redis # systemctl status redis
From the above output, it is clear that the Redis server is running on port 6379, and you can verify it using one of the following commands:
# ss -tlpn OR # ss -tlpn | grep 6379
Important: This means that the Redis is configured to listen only into the IPv4 loopback interface address on the above port.
Configuring Redis Server on RHEL 8
3. You can configure Redis using the /etc/redis.conf configuration file. The file is well documented, each of the default configuration directives is well explained. Before you can edit it, create a back up of the file.
# cp /etc/redis.conf /etc/redis.conf.orig
4. Now open it for editing using any of your favorite text-based editors.
# vi /etc/redis.conf
If you want the Redis-server to listen to external connections (especially if you are setting up a cluster), you need to set it to listen to a particular interface or multiple chosen interfaces using the “bind” configuration directive, followed by one or more IP addresses.
Here is an example:
bind 127.0.0.1 bind 192.168.56.10 192.168.2.105
5. After making any changes in the Redis configuration file, restart the Redis service to apply the changes.
# systemctl restart redis
6. If your server has the default firewall service running, you need to open port 6379 in the firewall to allow external connection to the Redis server.
# firewall-cmd --permanenent --add-port=6379/tcp # firewall-cmd --reload
7. Finally, access the Redis server using the redis-cli client program.
# redis-cli >client list
For more information on how Redis works and how to use it, see the Redis documentation.
That’s all! In this article, we’ve explained how to install Redis in RHEL 8. If you have any queries share with us via the feedback form below.