Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Install and Configure Redis on Ubuntu 20.04 - DesignLinux

designlinux 0 Comments

Redis is an open-source in-memory key-value data store. It can be used as a database, cache and, message broker, and supports various data structures such as Strings, Hashes, Lists, Sets, and more. Redis provides high availability via Redis Sentinel and automatic partitioning across multiple Redis nodes with Redis Cluster.

This tutorial describes how to install and configure Redis on Ubuntu 20.04.

Installing Redis on Ubuntu 20.04 #

Installing Redis on Ubuntu is a straightforward process.

Redis version 5.0.x is included in the default Ubuntu 20.04 repositories. To install it run the following commands as root or user with sudo privileges:

sudo apt updatesudo apt install redis-server

Once the installation is completed, the Redis service will start automatically. To check the status of the service, enter the following command:

sudo systemctl status redis-server

You should see something like this:

● redis-server.service - Advanced key-value store
     Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-06-06 20:03:08 UTC; 10s ago
...
Redis service will fail to start if IPv6 is disabled on your server.

That’s it. You have Redis installed and running on your Ubuntu 20.04 server.

Configure Redis Remote Access #

By default, the Redis server doesn’t accept remote connections. You can connect to Redis only from 127.0.0.1 (localhost) – the machine where Redis is running.

If you are using a single server setup, where the client connecting to the database is also running on the same host, you should not enable remote access.

To configure Redis to accept remote connections open the Redis configuration file with your text editor:

sudo nano /etc/redis/redis.conf

Locate the line that begins with bind 127.0.0.1 ::1 and comment it.

/etc/redis/redis.conf
# bind 0.0.0.0 ::1
If your server has a private IP, and you want Redis to be reachable only from the private network instead of commenting the line, the private IP address after 127.0.0.1.

Save the file and restart the Redis service for changes to take effect:

sudo systemctl restart redis-server

Use the following command to verify that redis is listening on all interfaces on port 6379:

ss -an | grep 6379

You should see something like below. 0.0.0.0 means all IPv4 addresses on the machine.

tcp  LISTEN 0   511   0.0.0.0:6379   0.0.0.0:*
tcp  LISTEN 0   511      [::]:6379      [::]:*  

Next, you’ll need to configure your firewall to enable traffic from on TCP port 6379.

Typically you would want to allow access to the Redis server only from a specific IP address or IP range. For example, to allow connections only from the 192.168.121.0/24 subnet, you would run the following command:

sudo ufw allow proto tcp from 192.168.121.0/24 to any port 6379
Make sure your firewall is configured to accept connections only from trusted IP ranges.

At this point, you should be able to connect to Redis on TCP port 6379 from remote locations.

To verify that everything is set up properly, you can try to ping the Redis server from your remote machine using the redis-cli utility:

redis-cli -h <REDIS_IP_ADDRESS> ping

The command should return a response of PONG:

PONG

Conclusion #

We’ve shown you how to install Redis on Ubuntu 20.04. To find more information about how to manage your Redis installation, visit the Redis documentation page.

If you hit a problem or have feedback, leave a comment below.

redis ubuntu

Related

Tags: Redis, ubuntu

How to Install Skype on Ubuntu 20.04

Prev Post

How to Redirect stderr to stdout in Bash

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 1
  • 1,254
  • 609,702

DesignLinux.com © All rights reserved

Go to mobile version