Setting up a Riak Development Cluster on Ubuntu 12.04

In order to explore and fully appreciate Riak, you're going to need to setup multiple nodes. Since not everyone has 3 extra boxes around, they've made it easy to setup the nodes on a single box. I'll walk you through the steps I took to setup a development Riak cluster on Ubuntu 12.04.

The first step is to get your dependencies installed:

sudo apt-get install build-essential libncurses5-dev openssl libssl-dev
sudo apt-get install erlang
sudo apt-get install git

Next, you'll need to grab the riak source:

git clone git:// && cd riak

Before we build our cluster, there are few things to change from the defaults. This will turn off authentication for the admin tool (I did say this was a development cluster ;)).

sed -i 's/{auth, userlist}/{auth, none}/g' ./rel/files/app.config

Next, let's turn on riak control and riak search:

sed -i 's/{enabled, false}/{enabled, true}/g' ./rel/files/app.config

Now we're ready to build a 3 node cluster from source:

make devrel DEVNODES=3 && cd dev

Next, start up all of the nodes and join them together:

find dev*/bin/riak -exec {} start \;
find dev[2-9]/bin/riak-admin -exec {} cluster join dev1@ \;
dev1/bin/riak-admin cluster plan
dev1/bin/riak-admin cluster commit

And now you have a running 3 node cluster listening on a bunch of weird ports. Let's add haproxy in the mix to expose the cluster under standard (8098 for http and 8087 for protocol buffers) ports with roundrobin distribution. First, install haproxy:

sudo apt-get install haproxy

Next, create a configuration file for haproxy (I'll name mine dev.haproxy.conf) with the following contents:

#Mostly from OJ Reeves post:
        maxconn 2048

        retries 3
        maxconn 1024
        timeout connect 3000

frontend riak_pb
        mode tcp
        bind *:8087
        default_backend riak_pb_cluster
        timeout client 1200000

backend riak_pb_cluster
        mode tcp
        balance roundrobin
        timeout server 1200000
        server riak1 check
        server riak2 check
        server riak3 check

frontend riak_http
        bind *:8098
        mode http
        default_backend riak_http_cluster
        timeout client 1200000

backend riak_http_cluster
        mode http
        balance roundrobin
        timeout server 1200000
        option httpchk GET /ping
        server riak1 check
        server riak2 check
        server riak3 check

Now run haproxy -f dev.haproxy.conf and you now have a cluster listening for connections. Fire up your web browser and point it at machine:8098/admin and you should see the web interface, Riak Control, displaying your cluster status. That's it! You're ready to start learning about Riak.

1 Comment so far

  1. Mark @ September 16th, 2013

    I have a quick comment regarding your masked input plugin. I don’t want to send you a twitter because I do not have a twitter account so here it is. Your latest version of (1.3.1) will fail in IE7 because of a trailing comma in line 29: placeholder: ‘_’,

    Removing the comma will fix the IE7 issue.

Leave a reply