{"id":14444,"date":"2022-01-28T05:45:04","date_gmt":"2022-01-28T05:45:04","guid":{"rendered":"https:\/\/linuxways.net\/?p=14444"},"modified":"2022-01-28T05:45:04","modified_gmt":"2022-01-28T05:45:04","slug":"how-to-deploy-redis-on-rocky-linux-8","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/red-hat\/how-to-deploy-redis-on-rocky-linux-8\/","title":{"rendered":"How to Deploy Redis on Rocky Linux 8"},"content":{"rendered":"<p><a href=\"https:\/\/redis.io\/\">Redis<\/a> is a free, open-source, in-memory data structure store widely used as a database, cache, and message broker.<\/p>\n<p>In this tutorial, we will explore commands to install Redis on our machine. Not just that, we will also see how to configure it. Rocky Linux 8 is the operating system we have used in this guide.<\/p>\n<p>Let\u2019s go!<\/p>\n<h2>Installation Guide:<\/h2>\n<p>Following these steps, we will install and configure Redis:<\/p>\n<h3>Step 1: Install Redis<\/h3>\n<p>To install Redis, run this command:<\/p>\n<pre>sudo dnf install redis<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"238\" height=\"30\" class=\"wp-image-14445\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-614.png\" \/><\/p>\n<h3>Step 2: Edit Redis Configuration file<\/h3>\n<p>Next, we will make some changes to the Redis configuration file.<\/p>\n<p>Open the file using the vim editor:<\/p>\n<pre>sudo vim \/etc\/redis.conf<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"250\" height=\"34\" class=\"wp-image-14446\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-615.png\" \/><\/p>\n<p>Locate supervised directive in the file. It will be written as:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"105\" height=\"24\" class=\"wp-image-14447\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-616.png\" \/><\/p>\n<p>Change it to:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"152\" height=\"26\" class=\"wp-image-14448\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-617.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-617.png 152w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-617-150x26.png 150w\" sizes=\"auto, (max-width: 152px) 100vw, 152px\" \/><\/p>\n<h3>Step 3: Start Redis<\/h3>\n<p>After saving changes, start Redis like this:<\/p>\n<pre>sudo systemctl start redis<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"269\" height=\"24\" class=\"wp-image-14449\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-618.png\" \/><\/p>\n<h3>Step 4: Enable Redis<\/h3>\n<p>Similarly, we will enable Redis with this command:<\/p>\n<pre>sudo systemctl enable redis<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"278\" height=\"30\" class=\"wp-image-14450\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-619.png\" \/><\/p>\n<h3>Step 5: Check Redis status<\/h3>\n<p>Now we will confirm if Redis service is running fine or not. Do that with this command:<\/p>\n<pre>sudo systemctl status redis<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"278\" height=\"30\" class=\"wp-image-14451\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-620.png\" \/><\/p>\n<h3>Step 6: Test Redis Installation<\/h3>\n<p>In this step, we will test Redis by running the command mentioned below. If it returns with PONG, this means redis is working fine.<\/p>\n<pre>$ sudo redis-cli ping<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"203\" height=\"31\" class=\"wp-image-14452\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-621.png\" \/><\/p>\n<h2>Protect Redis with the help of a Password<\/h2>\n<p>To secure the database, we will assign it a password to prevent unauthorized access.<\/p>\n<h3>Step 1: Edit Redis configuration file<\/h3>\n<p>First of all, open the Redis configuration file again using this command:<\/p>\n<pre>sudo vim \/etc\/redis.conf<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"242\" height=\"30\" class=\"wp-image-14453\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-622.png\" \/><\/p>\n<p>Find the following directive in the file to uncomment it and assign your password:<\/p>\n<pre>requirepass strong_password<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"260\" height=\"21\" class=\"wp-image-14454\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-623.png\" \/><\/p>\n<h3>Step 2: Restart Redis<\/h3>\n<p>To update changes, restart Redis.<\/p>\n<pre>sudo systemctl restart redis<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"287\" height=\"30\" class=\"wp-image-14455\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-624.png\" \/><\/p>\n<h3>Step 3: Enter Redis-cli<\/h3>\n<p>Now, we will check if the password authentication is working fine or not. To do that, access Redis client with this command:<\/p>\n<pre>redis-cli<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"120\" height=\"26\" class=\"wp-image-14456\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-625.png\" \/><\/p>\n<h3>Step 4: Set Key to a value<\/h3>\n<p>Now set a key to a value like this:<\/p>\n<pre>set keystudent Tom<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"191\" height=\"36\" class=\"wp-image-14457\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-626.png\" \/><\/p>\n<p>This will give an error, telling you that authentication is required to set the key.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"309\" height=\"24\" class=\"wp-image-14458\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-627.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-627.png 309w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-627-300x23.png 300w\" sizes=\"auto, (max-width: 309px) 100vw, 309px\" \/><\/p>\n<p>To get access, push your password with auth command like this:<\/p>\n<pre>auth your_password<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"108\" height=\"18\" class=\"wp-image-14459\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-628.png\" \/><\/p>\n<p>Once the password is accepted, you will be able to set a key to the value.<\/p>\n<h3>Step 5: Retrieve the value<\/h3>\n<p>To retrieve the value you just assigned to the key, use the get command like this:<\/p>\n<pre>get keystudent<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"137\" height=\"24\" class=\"wp-image-14460\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-629.png\" \/><\/p>\n<h3>Step 6: Exit Redis<\/h3>\n<p>To exit the database, just type quit and hit enter.<\/p>\n<pre>Quit<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"39\" height=\"29\" class=\"wp-image-14461\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-630.png\" \/><\/p>\n<h2>Configure Redis for remote access<\/h2>\n<p>Here, we will see how to configure Redis to be accessed remotely from another machine.<\/p>\n<h3>Step 1: Edit Redis configuration file<\/h3>\n<p>First of all, open the redis.conf file with this command:<\/p>\n<pre>sudo nano \/etc\/redis.conf<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"261\" height=\"23\" class=\"wp-image-14462\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-631.png\" \/><\/p>\n<p>Search for the bind directive, which is set to listen to localhost. Comment it:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"133\" height=\"25\" class=\"wp-image-14463\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-632.png\" \/><\/p>\n<p>Next, give the remote server\u2019s ip address like this<\/p>\n<pre>Bind private_ip<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"143\" height=\"24\" class=\"wp-image-14464\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-633.png\" \/><\/p>\n<p>To grant access to Redis over the public internet, set the bind directive to 0.0.0.0.<\/p>\n<pre>bind 0.0.0.0<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"117\" height=\"27\" class=\"wp-image-14465\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-634.png\" \/><\/p>\n<h3>Step 2: Disable protected mode<\/h3>\n<p>Now change protected mode yes to no as shown below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"163\" height=\"30\" class=\"wp-image-14466\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-635.png\" \/><\/p>\n<p>Save the changes and exit.<\/p>\n<h3>Step 3: Restart Redis<\/h3>\n<p>Now, restart the database with this command to update changes in the Redis configuration file:<\/p>\n<pre>sudo systemctl restart redis<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"279\" height=\"22\" class=\"wp-image-14467\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-636.png\" \/><\/p>\n<h2>Configure Firewall for Redis<\/h2>\n<p>In this part, we will configure the default firewall in Rocky Linux, namely firewalld, to allow Redis to listen on port 6379 which is its default port.<\/p>\n<h3>Step 1: Allow Redis port 6379<\/h3>\n<p>Run the following command so that Redis can listen on its default port:<\/p>\n<pre>sudo firewall-cmd --add-port=6379\/tcp --permanent<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"470\" height=\"26\" class=\"wp-image-14468\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-637.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-637.png 470w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-637-300x17.png 300w\" sizes=\"auto, (max-width: 470px) 100vw, 470px\" \/><\/p>\n<h3>Step 2: Reload firewall<\/h3>\n<p>To update changes, reload the firewall with this command:<\/p>\n<pre>sudo firewall-cmd --reload<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"257\" height=\"29\" class=\"wp-image-14469\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-638.png\" \/><\/p>\n<h3>Step 3: Test new settings<\/h3>\n<p>Now that we have configured the firewall for Redis, let\u2019s test if a remote machine can access Redis or not. Do that by running the following command from a remote machine:<\/p>\n<pre>redis-cli -h server_IP<\/pre>\n<p>server_IP is the IP address of the machine on which Redis is deployed. In my case, it is 10.128.1.2.<\/p>\n<pre>redis-cli -h 10.128.1.2<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"256\" height=\"30\" class=\"wp-image-14470\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/01\/word-image-639.png\" \/><\/p>\n<p>That was all for today. In this document, we saw in detail how to install and configure Redis on Rocky Linux 8.<\/p>\n<p>To see how you can install Redis on Ubuntu 20.04, visit:<\/p>\n<p><a href=\"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-and-configure-redis-in-ubuntu-20-04\/\">https:\/\/linuxways.net\/ubuntu\/how-to-install-and-configure-redis-in-ubuntu-20-04\/<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Redis is a free, open-source, in-memory data structure store widely used as a database, cache, and message broker. In this tutorial, we will explore commands to install Redis&hellip;<\/p>","protected":false},"author":1,"featured_media":14534,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[165],"tags":[189,436],"class_list":["post-14444","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-red-hat","tag-redis","tag-rocky-linux-8"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/14444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=14444"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/14444\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/14534"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=14444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=14444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=14444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}