Skip to content
jgnewman edited this page Nov 28, 2012 · 15 revisions

The default backend used by Riak is the bitcask backend, but the Riak CS package comes with a special backend that should be used by the Riak cluster that is part of the Riak CS system. It is a custom version of the standard multibackend that ships with Riak. Some of the Riak buckets used internally by Riak CS use secondary indexes, which currently requires the eleveldb backend. Other parts of the Riak CS system can benefit more from the use of the bitcask backend. The use of the custom multibackend enables Riak CS to take advantage of the strengths of both of these backends to achieve the best blend of performance and features. The next section covers how to properly setup Riak to use this multibackend.

Additionally, the Riak CS storage calculation system uses Riak's MapReduce to sum the files in a bucket. This means you must tell all of your Riak nodes where to find Riak CS's compiled files before calculating storage.

Configuring Riak for use with Riak CS

First, edit Riak's app.config file and find and delete the line containing the storage_backend property in the riak_kv section. The default setting is for the bitcask backend and would look like this:

{storage_backend, riak_kv_bitcask_backend},

Next, expose the necessary Riak CS modules to Riak and instruct Riak to use the custom multibackend. Continue editing Riak's app.config file, and add this to the riak_kv section:

{add_paths, ["RIAK-CS-CODE-PATH"]},
{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, "DATADIR/leveldb"}
    ]},
    {be_blocks, riak_kv_bitcask_backend, [
         {data_root, "DATADIR/bitcask"}
    ]}
]},

Next, add this to the riak_core section of the app.config

{default_bucket_props, [{allow_mult, true}]},

where X.Y.Z is the version of Riak CS you have installed.

Replace RIAK-CS-CODE-PATH with the appropriate directory listed below.

        Riak CS Linux code path:
            /usr/lib/riak-cs/lib/riak_cs-X.Y.Z/ebin

        Riak CS Solaris code path:
            /opt/riak-cs/lib/riak_cs-X.Y.Z/ebin

        Developer source (after a "make stage" or "make dev" compilation):
            $PATH-TO-CS-REPO/rel/riak-cs/lib/riak_cs-X.Y.Z/ebin

Replace all instances of DATADIR with the appropriate directory listed below that will be storing Riak's data.

        Riak Linux data directory path:
            /var/lib/riak

        Riak Solaris data directory path:
            /opt/riak/data

        Riak developer source data directory path:
            ./data

Save and exit the editing session on the app.config file.

The location of the app.config file for different environments is shown below.

        Riak Linux config file path:
            /etc/riak/app.config

        Riak Solaris config file path:
            /opt/riak/etc/app.config

        Riak developer source config file path:
            ./rel/riak/etc/app.config

To test that you have configured a Riak node correctly, start Riak and connect to its console (using riak attach), then run:

(riak@127.0.0.1)1> code:which(riak_cs_kv_multi_backend).
"/usr/lib/riak-cs/lib/riak_cs-X.Y.Z/ebin/riak_cs_kv_multi_backend.beam"

If the path that you added to Riak's app.config is returned, your node is configured correct. If instead, the atom non_existing is returned, Riak was unable to find the Riak CS code.

Note: To detach from the riak console after doing a riak attach it is important to use CTRL+D to detach the console and leave Riak running. CTRL+C will cause the Riak node to exit and in many cases this is not the desired outcome of detaching from the console.