Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure Redis on Ubuntu 18.04

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to install and configure Redis on Ubuntu 18.04. it is very detailed and has a certain reference value. Interested friends must read it!

Why use Redis?

As mentioned above, Redis's performance and superior capabilities make it better than traditional databases. The typical usage of Redis is:

Caching-its enhanced ability to persist data to disk makes it a better choice for traditional caching solutions

Queue-Redis can be used to queue jobs in the background.

Counters-Redis allows you to simply create and implement counters without reading data or updating the database. Counters in Redis will remain consistent

Publish and subscribe-users can easily distribute data using the publish / subscribe paradigm

How do I install Redis on Ubuntu?

Redis exists in Ubuntu's official package repository. Now let's install Redis on Ubuntu:

1. Update the APT repository cache

In order to install Redis, you first need to update Ubuntu's APT repository cache. You can use the following command to do so:

[linuxidc@linux:~/www.linuxidc.com] $sudo apt update

2. Use the APT command to install Redis on Ubuntu

[linuxidc@linux:~/www.linuxidc.com] $sudo apt install redis

Press y, then press Enter to continue.

3. Check the Redis version

To check that Redis is installed correctly and working properly, enter the following command:

[linuxidc@linux:~/www.linuxidc.com] $redis-cli-- version

The output displays the version of the utility currently installed on the computer.

Start and stop Redis

After the installation is complete, you can check to see if Redis is running. You can do this using the following command:

[linuxidc@linux:~/www.linuxidc.com] $sudo systemctl status redis In the output, locate Active: active (running).

In the output, find "Active: active (running)".

If you have not already started Redis, you can start it by entering the following command:

[linuxidc@linux:~/www.linuxidc.com] $sudo systemctl start redis-server

If Redis is already running and you want to stop it, you can use the following command:

[linuxidc@linux:~/www.linuxidc.com] $sudo systemctl stop redis

After that, you will see "Active: inactive (dead)" in the output of the first command in this section.

How to configure a Redis server on Ubuntu

The default configuration of Redis is in / etc/redis/redis.conf. By default, the server listens for connections from all available interfaces on the server. You can have it listen on the interface of your choice, which can be one or more interfaces as needed. This can be done by using a binding configuration instruction followed by one or more IP addresses.

To instruct the Redis server to listen on a specific IP address, you need to edit the / etc/redis/redis.conf file. Open it with your favorite editor. We will use vi. We use the following command to open the file:

Sudo vim / etc/redis/redis.conf

Find bind 127.0.0.1:: 1

Now change the IP address by entering the value of the interface you want the Redis server to listen on. For example:

Bind 192.168.213.135

If you want to add multiple IP addresses, simply separate them with a space:

Bind 192.168.213.135 192.168.213.136

Here you need to enter the IP address of your network.

However, if you want the server to listen on all interfaces on the network, you can use the following command:

Bind 0.0.0.0

When the changes are complete, save and close the file. In vim, you can click: and execute wq! To do that. Then restart the Redis server to apply the changes. The command to restart is:

Sudo systemctl restart redis-server above is all the contents of the article "how to install and configure Redis on Ubuntu 18.04". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report