ManagedCloud Servers

High performance handled and monitored by us 24/7/365. A complete solution to provide you with our in house expertise 24/7 tailored to your specific needs. We'll setup a bespoke server for your site using the latest tehnologies so you can get the most out of your hardware and get your website loading quickly and reliably. Find out more..

cPanelCloud Servers

Recommended - High performance cloud servers with no technical knowledge required. If you're hosting multiple websites already and you're looking to consolidate, or if you're looking to isolate yourself from the shared hosting environment but you don't have the time or knoweldge to manage a server, then the Managed cPanel Servers are for you. Find out more..

UnmanagedCloud Servers

Our unmanaged range gives you complete control at rock bottom prices and our cloud platform boasts super fast multipath 40Gb/s network, the latest Intel Xeon V3 CPUs and enterprise grade redundant SSDs. If you're a sysadmin look no further, we offer some of the best specification to price ratio servers available. Find out more..

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

View Plans

How to Install Riak On Ubuntu 14.04

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 https://packagecloud.io/gpg.key | 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 https://packagecloud.io/basho/riak/ubuntu/ trusty main" | sudo tee -a /etc/apt/sources.list.d/riak.list
$ echo "deb-src https://packagecloud.io/basho/riak/ubuntu/ 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@127.0.0.1' 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
pong
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@127.0.0.1'

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 http://127.0.0.1:8098/types/default/props

You will get the output like below :

* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8098 (#0)
> GET /types/default/props HTTP/1.1
> User-Agent: curl/7.35.0
> Host: 127.0.0.1:8098
> 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 127.0.0.1 left intact
{"props":{"allow_mult":false,"basic_quorum":false,"big_vclock":50,"chash_keyfun":{"mod":"riak_core_util","fun":"chash_std_keyfun"},"dvv_enabled":false,"dw":"quorum","last_write_wins":false,"linkfun":{"mod":"riak_kv_wm_link_walker","fun":"mapreduce_linkfun"},"n_val":3,"notfound_ok":true,"old_vclock":86400,"postcommit":[],"pr":0,"precommit":[],"pw":0,"r":"quorum","rw":"quorum","small_vclock":50,"w":"quorum","write_once":false,"young_vclock":20}}

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 https://github.com/basho/basho_docs/raw/master/source/data/goog.csv

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

wget -c https://github.com/basho/basho_docs/raw/master/source/data/load_data.erl

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.

Summary

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.

View Plans