How to install and configure redis on ubuntu 20


Redis is an open-source in-memory data store. It’s used as a flexible, highly available key-value database that maintains a high level of performance.

Bạn đang xem: How to install and configure redis on ubuntu 20

Apart from its performance and flexibility, Redis stands out with its wide language support, high availability, and automatic partitioning.

In this tutorial, learn how lớn install Redis on Ubuntu 20.04 / 18.04.


5. To exit out of the Redis shell run:


Step 4: Secure Redis

Step 4.1: Set Up Redis Authentication

Redis includes an authentication feature as an additional security layer. The feature is not enabled by default. Therefore, you need lớn modify the configuration tệp tin khổng lồ activate it.

1. To start, open the Redis configuration file for editing:

sudo nano /etc/redis/redis.conf2. Then, locate the requirepass directive sầu under the SECURITY section & unphản hồi it (by removing #).

3. Once you have uncommented the line, replace foobared with the password of your choice.

4. Save và cthất bại the tệp tin.

5. Restart the Redis service:

suvì chưng systemctl restart redis.serviceOnce you configure Redis lớn require authentication, it will refuse any query until you provide the required password.

For example, if you switch lớn the redis-cli command prompt & try khổng lồ run the ping demo, the output displays the message: (error) NOAUTH Authentication required.

The only way to lớn start working in Redis in such a case is lớn provide the password defined in the configuration file.

Use the command:

auth [your_password>If the output responds with OK you are good to lớn go.

Xem thêm: Các Phần Mềm Mã Nguồn Mở - Phần Mềm Mã Nguồn Mở Là Gì

Step 4.2: Bind Redis lớn Localhost

If you installed the software following the steps outlined above sầu, Redis should only be accessible from localhost. Limiting access in such a way is a matter of network security.

However, you may have changed the mặc định settings và now want to lớn restrict connections to lớn localhost.

To do so, open the Redis configuration tệp tin for editing:

suvị nano /etc/redis/redis.confScroll down và find the NETWORK section in the tệp tin. Then, unphản hồi the bind ::1 line (by removing #), as in the image below.

Once you save & exit the file, make sure lớn restart the service with:

suvì systemctl restart redisWith this, you have successfully managed lớn bind Redis to localhost, restricting access to lớn other connections.

Step 4.3: Rename or Kill Dangerous Commands

Another way to lớn protect your data is to disable specific commands or rename them, so they are unguessable. This is a useful security feature that can restrict normal users from using commands that could harm the system.

To disable or rename such commands, open the Redis configuration file:

suvị nano /etc/redis/redis.confLocate the SECURITY section & scroll down khổng lồ the #Command renamingline. There you can find examples on how lớn rename or kill commands.

For example, to rename the CONFIG command, add the line:

rename-comm& CONFIG [new_command_name>In this example, the config command is renamed khổng lồ sys_admin_config_836 (something a normal user would not be able khổng lồ guess).

To remove sầu certain commands, you can disable (kill) them. To vị this, rename the dangerous commvà inkhổng lồ an empty string.

Therefore, if you want to disable the config command, add the line:

rename-commvà CONFIG ""
After you have made these changes, make sure to lớn save the changes, and restart the Redis service.


This tutorial should help you install and mix up Redis on your Ubuntu 20.04 (or 18.04). Also, it provided a few tips on securing your Redis data store.

NoSquốc lộ databases, lượt thích Redis, are meant khổng lồ run efficiently in distributed clusters that scale out horizontally. Using Docker lớn deploy Redis in a container makes horizontal scaling a routine, straightforward process.