Installing Redis on Ubuntu 16.04/18.04

Posted on by David Singer | Updated:
Reading Time: 4 minutes

What is Redis? 

Redis or “REmote DIctionary Server” is defined as an open source, "key-value" database storage medium, which is additionally known as a data structure server. At its heart, Redis works with key-value pairs and stores data in a location that's easily referenceable by two specific values. These key-value associations are usually a set of two linked data entries which are made up by a key, which is a unique identifier for a type of data and, the value, which can be either the particular data that is identified or, an indicator to the location of that data.

Redis has five main data types it can utilize:

  • Strings - Strings are a basic value in Redis. They can contain any kind of data size up to 512Mb including jpegs or other objects like blobs.
  • Lists - Lists are exactly as the name implies; simply lists of strings, sorted by the order in which they are applied
  • Sets - Sets are simply a group of unordered strings
  • SortedSets - Sorted Sets are akin to regular sets. The main difference is that sorted set items are associated with, and sorted by a weighted score field. This allows for priority items to be set when entered data into the sorted set
  • Hashes - Hashes map the string fields and values themselves. They are capable of defining multiple elements and can store more than 4 billion field-value pairs

Redis holds the database entries entirely in memory, and will only use the hard disk for persistent storage. These key-value pair values are often used in hash tables, lookup tables and configuration files. Redis can accept key-values for a wide variety of formats so operations can be run on the server with a reduced server workload. Redis can also replicate data to any number of slave servers which makes it a prime candidate for large database replication setups.

What Are the Advantages of Redis?

  1. Redis is extremely fast − Redis can perform hundreds of thousands of (set, get) commands per second.
  2. It supports well know data types − As noted above, Redis supports most of the data types normally used by developers such as strings, lists, sets, sorted sets, and hashes.
  3. Operations are protected (or atomic) which means:
    1. All operations in a transaction are chronological and executed in sequence
    2. All operations in a transaction are performed as a single unit of work which limits interference from other operations
  4. .Multifunction database − Redis is a multifunction, noSQL database that can be used in a wide variety of use cases including caching, large dataset, full-text searches, spark data processing or any other short-lived data manipulation.

All of these options place Redis firmly in the middle of the NoSQL ecosystem.

What is NoSQL?

NoSQL is a type of database design that takes into consideration a wide group of data models, including key-value, document, columnar and graph formats.

NoSQL stands for "not only SQL" and is an alternative to the more traditional relational databases like MySQL in which data is laid out in tables, and the data scheme is carefully constructed before the actual database is created. NoSQL databases are especially useful for working with very large distributed datasets

A quick breakdown of how NoSQL stacks up against other database schemes:

how NoSQL stacks up against other database schemes

Install Redis on Ubuntu

To install Redis on Ubuntu, SSH into your server, once at the command prompt type the following commands. This will install Redis on your server.

apt-get update

apt-get install redis-server

Start Redis

redis-server

Next, let’s ensure Redis starts at boot:

systemctl enable redis-server.service

Also, let's set one of the main memory variables in the Redis config (this value will depend on your servers available memory)

vim /etc/redis/redis.conf

maxmemory 256mb

maxmemory-policy allkeys-lru

Finally, let’s restart Redis to ensure the values are retained:

systemctl restart redis-server.service

Check If Redis is Active

Run the following command at the servers command prompt:

redis-cli

This will open a Redis prompt.

redis 10.0.0.1:6379

After running the above command, your servers IP address (10.0.0.1) and the port Redis is running on will be shown (6379).

Now type in the following command at the Redis prompt:

redis 10.0.0.1:6379> ping
PONG
PONG” shows that Redis is successfully installed on your machine.

Install Redis via Source

To install Redis manually via source, simply SSH into your server and run the following command:

wget http://download.redis.io/redis-stable.tar.gz && tar xvzf redis-stable.tar.gz && cd redis-stable && make && make install

The Redis configuration file will be in the current install directory. Let’s copy it to a better location:

mkdir /etc/redis
cp redis.conf /etc/redis/

Now, let start Redis:

redis-server /etc/redis/redis.conf &
redis-cli ping
PONG

Lastly, here is a fun way to test Redis out. Try it!  Overall, if you need a fast, robust, and highly scalable NoSQL solution for use with your application or as a project adjunct Redis can meet your needs! Try it out on one of our Private Cloud product offerings or one of our stable, reliable Dedicated servers!

Meetups and Contacts for Redis

We’d like to send a shout out to the people over at https://redislabs.com/ who have provided some of the best and most excellent support over the years, awesome job!

For enterprise support, contact:
Blake Lipps– midwest Redis account rep/consultant
Drake Albee – west coast Redis consultant

For individual support, see the Redis community pages. The areas in which you can find active support or interact with the Redis community are noted here:

  • The HQ of the Redis community is on Reddit in the subreddit. You can use that community to ask for help, post new ideas for new features, link to articles of interest for the Redis community, and/or have other questions answered
  • Join the mailing list by subscribing via email
  • Meet up in the #redis channel on Freenode (web access link)
  • Check the Redis tag on Stack Overflow
  • Follow Redis news feed on Twitter

If you happen to live in one of the larger cities listed below, there are Local Redis meetup groups as well! Local Redis meetup info:

Avatar for David Singer

About the Author: David Singer

I am a g33k, Linux blogger, developer, student, and former Tech Writer for Liquidweb.com. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Latest Articles

Email security best practices for using SPF, DKIM, and DMARC

Read Article

Linux dos2unix command syntax — removing hidden Windows characters from files

Read Article

How to use kill commands in Linux

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article