September 21, 2014

Setting up Riak CS with Riak 2.0

A while back, a buddy at work was trying to setup Riak and was having some difficulty with it. Recently, I started looking at Riak to use as a key-value database and thought, maybe I will see what the big deal was with Riak CS.

The first issue is that Riak 2.0 is new. While most examples have riak.config being used as the new configuration file, most of the Riak CS examples still use the older release examples. This can make it difficult to set up Riak, if it is your first time. Don’t worry, I have some notes on the example of building a local test environment with Riak CS and Riak 2.0.

First, the tutorial I am using is at basho: here. You will noticed that most of the set up for Riak is done via the app.config, which is the old way of configuration, as of 2.0. The 2.0 configuration is almost straight forward and makes it easier to setup than in the old erlang configuration way. To start let’s dive in:

It starts at step 3:

 {default\_bucket\_props, [{allow\_mult, true}]}, 

To translate this to Riak 2.0, first edit the file at /etc/riak/riak.conf and use this setting instead:

 buckets.default.allow\_mult = true 

After that, you will need to change out the storage backend, here is a before and after:

 ## before 2.0 {storage\_backend, riak\_kv\_bitcask\_backend} ## after 2.0 storage\_backend = multi ## default is bitcask 

After that, we need to configure the multiple backends, which can be: leveldb, memory, multi and bitcask. Here is the version difference for that:

 ## before 2.0 {add\_paths, ["/usr/lib/riak-cs/lib/riak\_cs-1.5.0/ebin"]}, {storage\_backend, riak\_cs\_kv\_multi\_backend}, {multi\_backend\_prefix\_list, [{<<"0b:">>, be\_blocks}]}, {multi\_backend\_default, be\_default}, {multi\_backend, [ {be\_default, riak\_kv\_eleveldb\_backend, [ {max\_open\_files, 50}, {data\_root, "/var/lib/riak/leveldb"} ]}, {be\_blocks, riak\_kv\_bitcask\_backend, [ {data\_root, "/var/lib/riak/bitcask"} ]} ]}, ## after 2.0 storage\_backend = multi multi\_backend.default = be\_default multi\_backend.be\_default.storage\_backend = leveldb multi\_backend.be\_default.leveldb.data\_root = /var/lib/riak/leveldb multi\_backend.be\_block.storage\_backend = bitcask multi\_backend.be\_block.bitcask.data_root = /var/lib/riak/bitcask 

Next, you will need to expose some IP’s. Do note, they default to JUST localhost, so if you want to bind to any network interface, use 0.0.0.0. This will allow other computers to see the ports:

 ## before 2.0 {http, [ {"127.0.0.1", 8098 } ]} {pb, [ {"127.0.0.1", 8087 } ]} ## after 2.0 listener.http.internal = 127.0.0.1:8098 ## and listener.protobuf.internal = 127.0.0.1:8087 

Follow the tutorial as normal, and you should be good to go. The Riak-CS configs still use the erlang configs, so those directions are good. For more information on the configurations of Riak 2.0 file visit, here. Hope this helps!