I compiled Riak and started it, couple of times I tried with documented hello world like example but this time I wanted to separate Riak DB server from Erlang client. Riak is notoriously bad for omitting how to guides -- this also helps early adapter to delve deeply to understand and hence good for devs at the end. I really need to thank Joe Armstrong for pointing to Riak as it is not visible few months back.
1. Riak's default cookie name is "riak" and it can be verified by "ps -ef | grep riak" or rel/etc/vm.args file has cookie properties, here it can be changed to match Erlang client
2. I copied few files from cp <>/riak/apps/riak or luke/ebin to my working directory to check dependent module to work with and found
- luke.beam
- luke_flow.beam
- luke_flow_sup.beam
- riak.beam
- riak_client.beam
- riak_core_util.beam
- riak_kv_map_phase.beam
- riak_kv_mapred_query.beam
- riak_kv_util.beam
- riak_object.beam
- vclock.beam
are necessary to talk to Riak using Erlang application
3. Once grap hold of those files and node at which Riak server is running with cookie which Riak uses -- Erlang can talk to Riak period.
4. Now the steps detailed in the README (Riak's) is working fine for me. Assuming you are the directory where the above 5 files are available (or include that dir in erl path (-pa))
I just copied sample code from README file below and io output is omitted for brevity.
prompt> erl -name riaktest@127.0.0.1 -setcookie riak
(riaktest@127.0.0.1)1> RiakNode = 'riak@127.0.0.1'.
(riaktest@127.0.0.1)1> net_adm:ping(RiakNode).
(riaktest@127.0.0.1)1> {ok, C} = riak:client_connect(RiakNode).
(riaktest@127.0.0.1)1> O0 = riak_object:new(<<"groceries">>, <<"mine">>, ["bread"]).
(riaktest@127.0.0.1)1> C:put(O0, 1).
(riaktest@127.0.0.1)1> {ok, O1} = C:get(<<"groceries">>, <<"mine">>, 1).
(riaktest@127.0.0.1)1> V = riak_object:get_value(O1).
(riaktest@127.0.0.1)1> O2 = riak_object:update_value(O1, ["milk" | V]).
(riaktest@127.0.0.1)1> C:put(O2, 1).
I am not sure only these files are enough, but probably not! there are modules for certain kind of map reduce available in Riak, so if you plan to use those builtins you may need to copy them as well.