15th January, 2016 | Tutorials |

How to Install Riak On Ubuntu 14.04

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

Get a Cloud Server

Riak (Riak KV) is a distributed NoSQL database that is highly available, scalable, and easy to operate.

Riak KV automatically distributes data across the cluster to ensure fast performance and fault-tolerance.

Several key features that Riak has :

  • High Availability. Riak KV is designed to intelligently replicate and retrieve data. Any data that you have from IoT to hybrid cloud application is always available.
  • Massive Scalability. Riak uses scale-out architecture which enables you to add capacity seamlessly using commodity hardware. Add a new machine to the cluster and the performance improvement is near-linear.
  • Operational Simplicity. Data is automatically distributed across nodes. You only need to add a new machine to add capacity - no need to think about distibuting the data itself.
  • Fault Tolerant. Riak can still work, read and write your data, even if there is a network partition or hardware failure.
  • Low Latency. With global replication and masterless architecture, Riak KV serves data quickly and predictably even under peak load conditions.
  • Complex Query Support. Riak KV provides you with three ways to query data using Solr full-text search, secondary indexes and Map Reduce.
  • Riak Data Types. Riak KV provides pre-built data types for the most common data structures that are required by distributed, active workloads.
  • Robust APIs and Client Libraries. Whether you code in Java, Ruby, Python, C#, Erlang, Node.js or .NET – Riak KV makes it easy to select the language your application needs.
  • Multi Cluster Replication. Riak KV makes it easy to replicate clusters across your datacenter or around the world for data geo-location, secondary analytics or business continuity.

Updating the Base System

This tutorial assumes that we have a clean Ubuntu Server 14.04. Before installing Riak, let's update our base system to the latest update

$ sudo apt-get update
$ sudo apt-get -y upgrade

Now our base system is ready, lets get the latest update and we're ready to install Riak on our system.

Installing Riak

The first step that we have to do is adding packagecloud signing key so that we can verify Riak packages that we will download.

$ curl | sudo apt-key add -

Add riak repository to new apt list file. We will create separate list file under /etc/apt/sources.list.d/ directory.

$ echo "deb trusty main" | sudo tee -a /etc/apt/sources.list.d/riak.list
$ echo "deb-src trusty main" | sudo tee -a /etc/apt/sources.list.d/riak.list

Update your repository local database.

$ sudo apt-get update

Install Riak

$ sudo apt-get install riak

Now let's check the riak service status

$ sudo service riak status
Node 'riak@' not responding to pings.
riak is stopped

We can see above that Riak is not started by default. Let's start riak service

$ sudo service riak start
!!!! WARNING: ulimit -n is 1024; 65536 is the recommended minimum.

We can ignore the warning above for now, we'll deal with it later. Now if we check the riak service status we will get the output that riak is running.

$ sudo service riak status
riak is running

Verify the Riak Installation

Now it's time to verify our one node Riak installation. The first method is using the riak-admin command :

$ sudo riak-admin test
Successfully completed 1 read/write cycle to 'riak@'

The output above showed that we did 1 read/write cycle successfully to our Riak installation.

Another method to verify Riak installation is via a HTTP call to Riak. You can run command below:

$ curl -v

You will get the output like below :

* Hostname was NOT found in DNS cache
*   Trying
* Connected to ( port 8098 (#0)
> GET /types/default/props HTTP/1.1
> User-Agent: curl/7.35.0
> Host:
> Accept: */*
< HTTP/1.1 200 OK
< Vary: Accept-Encoding
* Server MochiWeb/1.1 WebMachine/1.10.8 (that head fake, tho) is not blacklisted
< Server: MochiWeb/1.1 WebMachine/1.10.8 (that head fake, tho)
< Date: Mon, 21 Dec 2015 05:45:20 GMT
< Content-Type: application/json
< Content-Length: 447
* Connection #0 to host left intact

Configuring Maximum Open Files

By default each user on ubuntu get max file limit 1024. This is why we get a warning when we start Riak. To remove this warning we can use the two methods below. First is to configure maximum open files from the security limit. We run riak as user riak. We will configure the user riak to have a soft limit 4096 and a hard limitf of 65536 for opened files. Open /etc/security/limits.conf. At the end of the file add :

riak soft nofile 4096
riak hard nofile 65536

The next step is to create default config for riak. Create new file /etc/default/riak. Add the line below :

ulimit -n 65536

This file will be loaded automatically by the Riak init script. Now when we restart Riak we will not get any warning

$ sudo service riak restart
 * Restarting riak                                                                                                                           ok

Import data to Riak

We have a working Riak installation. Now let's import sample data to our Riak installation. We will use an erlang script to import sample data. The sample data that we will use is Google historical stock price data. For more information you can read Loading Data and Running Mapreduce Tutorial.

Since we will use an Erlang script let's install erlang first. You can use the command below to install Erlang

$ sudo apt-get -y install erlang

After installing erlang, let's download the sample data.

wget -c

The last one is of course to download the load data script to import sample data to our Riak installation.

wget -c

After downloading the erlang script and sample data, let's change permissions for the load-data.erl file with additional execute permission so that we can run this file.

$ chmod +x load_data.erl

Now run this script with the parameter goog.csv to import Google stock-price data.

$ ./load_data.erl goog.csv

You will see some output that the script is importing data to our Riak installation.


In this tutorial we learned how to install Riak on Ubuntu 14.04. We also learned basic configuration of our Riak installation and importing sample data to Riak. We are not configuring Riak as a cluster yet, this will be a topic for a tutorial in the near future. Until then. have fun with Riak!

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

Get a Cloud Server