How to Install and Configure a Redis Server on Ubuntu 16

Try it in our public cloud & Get $5 Credit
CLAIM NOW

Redis, short for “Remote Dictionary Server”, is a scalable data structure store that can be distributed across multiple servers and architectures. It has features that mark it as being a versatile alternative to other database and cache alternatives, such as Lua scripting, in-memory persistence, and a multiplicity of data types. It’s also exceptional at dealing with use cases that require advanced queuing operations.

Redis is in use by such well known sites as Patreon, Trello, Slack and Medium. It is open source under the BSD license.

Getting started

To complete this guide, you will need the following:
• 1 Node (Cloud Server or Dedicated Server) running a clean installation of Ubuntu 16.
• All commands should be run as the root user

Tutorial

Ensure that your installation of Ubuntu 16 is fully up to date with this command.

apt-get update && apt-get upgrade -y

Install the redis server package, which is included in the base repositories.

apt-get install redis-server -y

To prevent others from accessing your Redis keystore, you will need to make sure that Redis is bound to your local IP address. This is hands-down the safest security option, and the best one for this particular guide.

First, open the Redis configuration in a text editor.

nano /etc/redis/redis.conf

Next, search for the line which starts with bind. Change it to this line instead:

bind 127.0.0.1

Start the Redis server.

service redis-server start

In order for Redis to start up again when the server is restarted, enable it to start on boot.

update-rc.d redis-server enable
update-rc.d redis-server defaults

Redis is installed! You can now enter the first data into your new Redis server.

root@redis-node:~# redis-cli
127.0.0.1:6379> set besthost "Globo.Tech"
OK
127.0.0.1:6379> get besthost
"Globo.Tech"

Conclusion

Now that you have Redis installed, take some time to explore the capabilities of one of the most popular NoSQL options out there. There are plugins that exist for many popular website backend technologies like WordPress, Magento, and Celery, so there’s plenty of opportunity to experiment.

One thing that you’ll notice during use is that due to being entirely in-memory, Redis is much faster than any of the alternatives out there. It is single-threaded, however, so be careful to note that you cannot utilize parallel execution. Despite that, Redis will give you a lot of flexibility to manipulate data. If this guide was helpful to you, kindly share it with others who may also be interested.