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.
The first step that we have to do is adding packagecloud signing key so that we can verify Riak packages that we will download.
* 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
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.
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!
Looking for the right web hosting solution for your website can be an intimidating task. Options nowadays are more diversified than ever, and each year brings new developments in the web hosting market. If you have no clue of what to look out for, you can find yourself overwhelmed with...
Content marketing continues to be one of the most valuable tools for today’s online businesses. With content, you can improve your chances of reaching your target audience, boost your search engine standing, and even unlock new opportunities for sales. The more content you produce, the more you can strengthen your...
User Experience (UX) is one of the most crucial factors to consider in web design. As the number of websites and applications in the world today continues to accelerate, businesses are under more pressure than ever to impress customers straight away. If a user visits your website and finds slow-loading...