{"id":7253,"date":"2018-11-19T16:59:16","date_gmt":"2018-11-19T13:59:16","guid":{"rendered":"https:\/\/www.howtoforge.com\/tutorial\/how-to-setup-riak-kv-cluster-on-ubuntu-1804\/"},"modified":"2018-11-19T16:59:16","modified_gmt":"2018-11-19T13:59:16","slug":"how-to-setup-riak-kv-database-cluster-on-ubuntu-18-04","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/how-to-setup-riak-kv-database-cluster-on-ubuntu-18-04\/","title":{"rendered":"How to Setup Riak KV Database Cluster on Ubuntu 18.04"},"content":{"rendered":"<p>Riak is a distributed NoSQL database that offers high-availability, fault tolerance,\u00a0operational simplicity, and scalability. Riak has been written in Erlang, and part of &#8216;Basho&#8217; products that provide different version, including Riak KV (Key-value), Riak TS (optimized for IoT\/Time Series), and Riak CS (Riak Cloud Storage).<\/p>\n<p>In this tutorial, we will\u00a0show you to step-by-step how to install and configure the NoSQL database Riak KV on Ubuntu 18.04 LTS server. We will create the Riak KV cluster with three Ubuntu servers.<\/p>\n<h2 id=\"prerequisites\">Prerequisites<\/h2>\n<ul>\n<li>3 Servers Ubuntu 18.04\/16.04<\/li>\n<ul>\n<li>hakase-riak01\u00a0\u00a0\u00a0\u00a0 10.1.1.10<\/li>\n<li>hakase-riak02\u00a0\u00a0\u00a0\u00a0 10.1.1.11<\/li>\n<li>hakase-riak03\u00a0\u00a0\u00a0\u00a0 10.1.1.12<\/li>\n<\/ul>\n<li>Root privileges<\/li>\n<\/ul>\n<h2 id=\"what-we-will-do\">What we will do?<\/h2>\n<ol>\n<li>Install Riak KV on Ubuntu 18.04<\/li>\n<li>Basic Riak KV Configuration<\/li>\n<li>Setup Riak KV Cluster<\/li>\n<li>Testing<\/li>\n<\/ol>\n<h2 id=\"step-install-riak-kv-on-ubuntu-lts\">Step 1 &#8211; Install Riak KV on Ubuntu 18.04 LTS<\/h2>\n<p>The first step we will do for this guide is to install the Riak KV packages on all of the servers, so run all commands in this stage on all servers.<\/p>\n<p>We will install the Riak KV from the packagecloud repository, and will be using the Riak KV packages for Ubuntu Xenial version.<\/p>\n<p>Add the packagecloud key and install &#8216;apt-transport-https&#8217;.<\/p>\n<pre class=\"command\"><code spellcheck=\"false\">curl https:\/\/packagecloud.io\/gpg.key | sudo apt-key add -<br\/>sudo apt-get install -y apt-transport-https<\/code><\/pre>\n<p>Now go to the &#8216;\/etc\/apt\/sources.list.d&#8217; directory and create a new repository file &#8216;riak.list&#8217;.<\/p>\n<pre class=\"command\"><code spellcheck=\"false\">cd \/etc\/apt\/sources.list.d\/<br\/>vim riak.list<\/code><\/pre>\n<p>Paste Riak KV repository below.<\/p>\n<pre># this file was generated by packagecloud.io for&#13;\n# the repository at https:\/\/packagecloud.io\/basho\/riak&#13;\n&#13;\ndeb https:\/\/packagecloud.io\/basho\/riak\/ubuntu\/ xenial main&#13;\ndeb-src https:\/\/packagecloud.io\/basho\/riak\/ubuntu\/ xenial main<\/pre>\n<p>Save and exit.<\/p>\n<p>Update the repository and install the Riak KV packages using the apt command below.<\/p>\n<pre class=\"command\"><code spellcheck=\"false\">sudo apt update<br\/>sudo apt install riak -y<\/code><\/pre>\n<p>Wait for the installation.<\/p>\n<p><a class=\"fancybox\" id=\"img-1\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_riak_kv_cluster_on_ubuntu_1804\/big\/1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/11\/how-to-setup-riak-kv-database-cluster-on-ubuntu-18-04.png\" alt=\"Install Riak Database\" width=\"500\" height=\"239\" title=\"\"><\/a><\/p>\n<p><strong>Note:<\/strong><\/p>\n<ul>\n<li>Run all commands on this stage on all server nodes.<\/li>\n<\/ul>\n<h2 id=\"step-basic-configuration-riak-kv\">Step 2 &#8211; Basic Configuration Riak KV<\/h2>\n<p>In this step, we will configure the Riak KV for our NoSQL cluster. Before configuring the Riak KV itself, we need to setup the open files limit on the Ubuntu system.<\/p>\n<p>Edit the &#8216;\/etc\/security\/limits.conf&#8217; file using <a href=\"https:\/\/www.howtoforge.com\/vim-basics\" target=\"_blank\" rel=\"noopener noreferrer\">vim editor<\/a>.<\/p>\n<pre class=\"command\"><code spellcheck=\"false\">vim \/etc\/security\/limits.conf<\/code><\/pre>\n<p>Paste configuration below to the end of the line.<\/p>\n<pre>riak soft nofile 65536&#13;\nriak hard nofile 200000<\/pre>\n<p>Save and exit.<\/p>\n<p>Now go to the &#8216;\/etc\/riak&#8217; directory, edit the default configuration file &#8216;riak.conf&#8217;.<\/p>\n<pre class=\"command\"><code spellcheck=\"false\">cd \/etc\/riak\/<br\/>vim riak.conf<\/code><\/pre>\n<p>Change the\u00a0default nodename &#8216;<a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"d8aab1b9b398b4b7bbb9b4b0b7abac\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a>&#8216; with &#8216;<a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"6e1c070f052e3d0b1c180b1c273e\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a>&#8216;.<\/p>\n<pre><code spellcheck=\"false\">nodename = <a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"b5c7dcd4def584859b849b849b8484\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a><\/code><\/pre>\n<p>Now uncomment those schedulers lines below.<\/p>\n<pre>erlang.schedulers.force_wakeup_interval = 500&#13;\nerlang.schedulers.compaction_of_load = false<\/pre>\n<p>Uncomment the &#8216;ring_size&#8217; line and leave it default &#8217;64&#8217;.<\/p>\n<pre><code spellcheck=\"false\">ring_size = 64<\/code><\/pre>\n<p>Change the HTTP listener and protocol buffers with the &#8216;ServerIP&#8217;.<\/p>\n<pre>listener.http.internal = 10.1.1.11:8098&#13;\nlistener.protobuf.internal = 10.1.11.11:8087<\/pre>\n<p>Save and exit.<\/p>\n<p>Now test riak configurations, then start the riak service.<\/p>\n<pre class=\"command\"><code spellcheck=\"false\">riak chkconfig<br\/>riak start<\/code><\/pre>\n<p>And the following is the result.<\/p>\n<p><a class=\"fancybox\" id=\"img-2\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_riak_kv_cluster_on_ubuntu_1804\/big\/2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/11\/how-to-setup-riak-kv-database-cluster-on-ubuntu-18-04-1.png\" alt=\"Start Riak\" width=\"500\" height=\"121\" title=\"\"><\/a><\/p>\n<p>Next, we will test our riak service configuration by running commands below.<\/p>\n<pre class=\"command\"><code spellcheck=\"false\">riak ping<br\/>curl -v http:\/\/10.1.1.11:8098\/types\/default\/props<\/code><\/pre>\n<p>Make sure you get the &#8216;pong&#8217; result from the &#8216;riak ping&#8217; command, and get the HTTP status code &#8216;200&#8217; from the curl command.<\/p>\n<p><a class=\"fancybox\" id=\"img-3\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_riak_kv_cluster_on_ubuntu_1804\/big\/3.png\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/11\/how-to-setup-riak-kv-database-cluster-on-ubuntu-18-04-2.png\" alt=\"\" title=\"\"><\/a><\/p>\n<p>Basic configurations of Riak KV distributed NoSQL have been completed, and we&#8217;re ready to setup the Riak KV Cluster.<\/p>\n<p><strong>Note:<\/strong><\/p>\n<ul>\n<li>Run all commands on this stage on all server nodes.<\/li>\n<\/ul>\n<h2 id=\"step-setup-riak-kv-cluster\">Step 3 &#8211; Setup Riak KV Cluster<\/h2>\n<p>In this step, we will setup the cluster by joining the &#8216;hakase-riak02&#8217; and &#8216;hakase-riak03&#8217; nodes to the first node.<\/p>\n<h3 id=\"second-node\">Second Node<\/h3>\n<p>On the &#8216;hakase-riak02&#8217; node, run the riak-admin below.<\/p>\n<pre class=\"command\"><code spellcheck=\"false\">riak-admin cluster join <a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"cbb9a2aaa08bfafbe5fae5fae5fafb\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a><\/code><\/pre>\n<p><a class=\"fancybox\" id=\"img-4\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_riak_kv_cluster_on_ubuntu_1804\/big\/4.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/11\/how-to-setup-riak-kv-database-cluster-on-ubuntu-18-04-3.png\" alt=\"Setup Riak KV Cluster\" width=\"500\" height=\"116\" title=\"\"><\/a><\/p>\n<p>Now back to the &#8216;hakase-riak01&#8217; node, run riak-admin commands below.<\/p>\n<pre class=\"command\"><code spellcheck=\"false\">riak-admin cluster plan<br\/>riak-admin cluster commit<\/code><\/pre>\n<p>And the &#8216;hakase-riak02&#8217; node has been added to the cluster, check it using command below.<\/p>\n<pre class=\"command\"><code spellcheck=\"false\">riak-admin cluster status<\/code><\/pre>\n<p><a class=\"fancybox\" id=\"img-5\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_riak_kv_cluster_on_ubuntu_1804\/big\/5.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/11\/how-to-setup-riak-kv-database-cluster-on-ubuntu-18-04-4.png\" alt=\"riak-admin cluster status\" width=\"485\" height=\"550\" title=\"\"><\/a><\/p>\n<h3 id=\"third-node\">Third Node<\/h3>\n<p>On the &#8216;hakase-riak03&#8217; node, run the riak-admin command below.<\/p>\n<pre class=\"command\"><code spellcheck=\"false\">riak-admin cluster join <a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"12607b73795223223c233c233c2322\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a><\/code><\/pre>\n<p><a class=\"fancybox\" id=\"img-6\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_riak_kv_cluster_on_ubuntu_1804\/big\/6.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/11\/how-to-setup-riak-kv-database-cluster-on-ubuntu-18-04-5.png\" alt=\"Third Node\" width=\"500\" height=\"116\" title=\"\"><\/a><\/p>\n<p>Now back to the &#8216;hakase-riak01&#8217; node, run riak-admin commands below.<\/p>\n<pre class=\"command\"><code spellcheck=\"false\">riak-admin cluster plan<br\/>riak-admin cluster commit<\/code><\/pre>\n<p>All server node &#8216;hakase-riak02&#8217; and &#8216;hakase-riak03&#8217; has been added to the cluster, check again using command below.<\/p>\n<pre class=\"command\"><code spellcheck=\"false\">riak-admin cluster status<\/code><\/pre>\n<p>The Riak KV cluster\u00a0installation and configuration has been completed.<\/p>\n<p><a class=\"fancybox\" id=\"img-7\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_riak_kv_cluster_on_ubuntu_1804\/big\/7.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/11\/how-to-setup-riak-kv-database-cluster-on-ubuntu-18-04-6.png\" alt=\"iak KV cluster installation complete\" width=\"474\" height=\"550\" title=\"\"><\/a><\/p>\n<h2 id=\"step-testing\">Step 4 &#8211; Testing<\/h2>\n<p>The Riak KV NoSQL cluster has been created, now we want to test the cluster by uploading a data image to the cluster, and test to access from the other nodes to ensure data replication between all nodes.<\/p>\n<p>On the &#8216;hakase-riak01&#8217; server, download an image using wget command below.<\/p>\n<pre class=\"command\"><code spellcheck=\"false\">cd ~\/<br\/>wget https:\/\/vignette.wikia.nocookie.net\/nichijou\/images\/a\/a0\/113407.jpg -O hakase.jpg<\/code><\/pre>\n<p>Now upload the image to the Riak KV cluster using <a href=\"https:\/\/www.howtoforge.com\/linux-curl-command\/\" target=\"_blank\" rel=\"noopener noreferrer\">curl command<\/a>.<\/p>\n<pre class=\"command\"><code spellcheck=\"false\">curl -XPUT http:\/\/10.9.9.10:8098\/riak\/images\/hakase.jpg -H \"Content-type: image\/jpg\" --data-binary @hakase.jpg<\/code><\/pre>\n<p><a class=\"fancybox\" id=\"img-10\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_riak_kv_cluster_on_ubuntu_1804\/big\/10.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/11\/how-to-setup-riak-kv-database-cluster-on-ubuntu-18-04-7.png\" alt=\"Testing Riak setup\" width=\"500\" height=\"86\" title=\"\"><\/a><\/p>\n<p>Open your web browser and type other nodes IP address, and you will get the same image.<\/p>\n<p><strong>&#8216;hakase-riak02&#8217;.<\/strong><\/p>\n<p><em><strong>http:\/\/10.1.1.11:8098\/riak\/images\/hakase.jpg<\/strong><\/em><\/p>\n<p><a class=\"fancybox\" id=\"img-8\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_riak_kv_cluster_on_ubuntu_1804\/big\/8.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/11\/how-to-setup-riak-kv-database-cluster-on-ubuntu-18-04-8.png\" alt=\"Test node 2\" width=\"500\" height=\"229\" title=\"\"><\/a><\/p>\n<p><strong>&#8216;hakase-riak03&#8217;.<\/strong><\/p>\n<p><em><strong>http:\/\/10.1.1.12:8098\/riak\/images\/hakase.jpg<\/strong><\/em><\/p>\n<p><a class=\"fancybox\" id=\"img-9\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_riak_kv_cluster_on_ubuntu_1804\/big\/9.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/11\/how-to-setup-riak-kv-database-cluster-on-ubuntu-18-04-9.png\" width=\"500\" height=\"220\" alt=\"\" title=\"\"><\/a><\/p>\n<p>If you want to delete the image data, use the curl command below.<\/p>\n<pre class=\"command\"><code spellcheck=\"false\">curl -XDELETE 'http:\/\/10.9.9.10:8098\/riak\/images\/hakase.jpg'<\/code><\/pre>\n<p>The Riak KV Cluster\u00a0installation and configuration on Ubuntu 18.04 has been completed successfully.<\/p>\n<h2 id=\"reference\">Reference<\/h2>\n","protected":false},"excerpt":{"rendered":"<p>Riak is a distributed NoSQL database that offers high-availability, fault tolerance,\u00a0operational simplicity, and scalability. Riak has been written in Erlang, and part of &#8216;Basho&#8217; products that provide different version, including Riak KV (Key-value), Riak TS (optimized for IoT\/Time Series), and Riak CS (Riak Cloud Storage). In this tutorial, we will\u00a0show you to step-by-step how to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-7253","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/7253","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=7253"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/7253\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=7253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=7253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=7253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}