justin / riak (http://riak.basho.com/)

Riak is a decentralized datastore from Basho Technologies.

Clone this repository (size: 6.4 MB): HTTPS / SSH
$ hg clone http://bitbucket.org/justin/riak/

 NB: This is not the latest revision. For the latest view, go to tip.

View at rev
riak /
filename size last modified message
client_lib  
config  
demo  
deps  
doc  
ebin  
priv  
releasenotes  
scripts  
src  
www  
.hgignore 260 B 7 months ago hgignore
.hgtags 50 B 7 months ago Added tag riak-0.2 for changeset 383abb86f65d
Emakefile 114 B 7 months ago import
LICENSE 9.9 KB 7 months ago import
Makefile 688 B 7 months ago import
NOTICE 276 B 7 months ago import
README 5.3 KB 7 months ago R13 note
TODO 1.0 KB 7 months ago update TODO
debug-restart.sh 715 B 7 months ago debugging startup script
riak-env.sh 32 B 7 months ago import
riak_demo.escript 3.3 KB 7 months ago explicitly put demo node on 127.0.0.1
start-backup-dump.sh 441 B 7 months ago import
start-backup-restore.sh 463 B 7 months ago import
start-eventer.sh 424 B 7 months ago import
start-fresh.sh 898 B 7 months ago import
start-join.sh 949 B 7 months ago import
start-restart.sh 940 B 7 months ago import

README

                           Welcome to Riak.
                           ================




Table of Contents
=================
1 Overview 
2 Quick Start 
    2.1 Building Riak 
    2.2 Starting Riak 
    2.3 Connecting a client to Riak 
3 Server Management 
    3.1 Configuration 
    3.2 Server Control 
        3.2.1 bin/riak 
        3.2.2 bin/riak-admin 


1 Overview 
~~~~~~~~~~~
  Riak is a distributed, decentralized data storage system. 
  
  Below, you will find the "quick start" directions for setting up and
  using Riak.  For more information, browse the following files:
  
  * README:  this file
  * TODO:    a list of improvements planned for Riak
  * LICENSE: the license under which Riak is released
  * apps/    the source tree for Riak and all its dependencies
  * doc/
    - basic-setup.txt:  slightly more detail on setting up Riak
    - basic-client.txt: slightly more detail on using Riak
    - architecture.txt: details about the underlying design of Riak
    - index.html:       the root of the edoc output of 'make docs'


2 Quick Start 
~~~~~~~~~~~~~~

  This section assumes that you have copy of the Riak source tree. To get
  started, you need to:
  1. Build Riak
  2. Start the Riak server
  3. Connect a client and store/fetch data

2.1 Building Riak 
==================

   Assuming you have a working Erlang (R13B03 or later) installation,
   building Riak should be as simple as:


  $ cd $RIAK
  $ make all rel

2.2 Starting Riak 
==================

   Once you have successfully built Riak, you can start the server with the
   following commands:


  $ cd $RIAK/rel/riak
  $ bin/riak start

   Now, verify that the server started up cleanly and is working:

   $ bin/riak-admin test

   Note that the $RIAK/rel/riak directory is a complete, self-contained instance
   of Riak and Erlang. It is strongly suggested that you move this directory
   outside the source tree if you plan to run a production instance.

2.3 Connecting a client to Riak 
================================

   Now that you have a functional server, let's try storing some data in
   it. First, start up a erlang node using our embedded version of erlang:


  $ erts-<vsn>/bin/erl -name riaktest -setcookie riak
  
  Eshell V5.7.4  (abort with ^G)
  (riaktest@example.com)1>

   Now construct the node name of Riak server and make sure we can talk to it:


  (riaktest@example.com)4> RiakNode = riak_util:str_to_node(riak).
  
  (riaktest@example.com)2> net_adm:ping(RiakNode).
  pong
  (riaktest@example.com)2>
   
   We are now ready to start the Riak client:


  (riaktest@example.com)2> {ok, C} = riak:client_connect(RiakNode).
  {ok,{riak_client,'riak@example.com',<<4,136,81,151>>}}

   Let's create a shopping list for bread at /groceries/mine:


  (riaktest@example.com)6> O0 = riak_object:new(<<"groceries">>, <<"mine">>, ["bread"]).
  O0 = riak_object:new(<<"groceries">>, <<"mine">>, ["bread"]).
  {r_object,<<"groceries">>,<<"mine">>,
         [{r_content,{dict,0,16,16,8,80,48,
                           {[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
                           {{[],[],[],[],[],[],[],[],[],[],[],[],...}}},
                     ["bread"]}],
         [],
         {dict,1,16,16,8,80,48,
               {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
               {{[],[],[],[],[],[],[],[],[],[],[],[],[],...}}},
         undefined}
  
   (riaktest@example.com)3> C:put(O0, 1).
    
    Now, read the list back from the Riak server and extract the value


  (riaktest@example.com)4> {ok, O1} = C:get(<<"groceries">>, <<"mine">>, 1).
  {ok,{r_object,<<"groceries">>,<<"mine">>,
            [{r_content,{dict,2,16,16,8,80,48,
                              {[],[],[],[],[],[],[],[],[],[],[],[],...},
                              {{[],[],[],[],[],[],
                                ["X-Riak-Last-Modified",87|...],
                                [],[],[],...}}},
                        ["bread"]}],
            [{"20090722191020-riaktest@example.com-riakdemo@example.com-266664",
              {1,63415509105}}],
            {dict,0,16,16,8,80,48,
                  {[],[],[],[],[],[],[],[],[],[],[],[],[],...},
                  {{[],[],[],[],[],[],[],[],[],[],[],...}}},
            undefined}}
  
   (riaktest@example.com)5> %% extract the value
   (riaktest@example.com)5> V = riak_object:get_value(O1).
   ["bread"]

     Add milk to our list of groceries and write the new value to Riak:


  (riaktest@example.com)6> %% add milk to the list
  (riaktest@example.com)6> O2 = riak_object:update_value(O1, ["milk" | V]).
  {r_object,<<"groceries">>,<<"mine">>,
       [{r_content,{dict,2,16,16,8,80,48,
                         {[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
                         {{[],[],[],[],[],[],
                           ["X-Riak-Last-Modified",87,101,100|...],
                           [],[],[],[],[],...}}},
                   ["bread"]}],
       [{"20090722191020-riaktest@example.com-riakdemo@example.com-266664",
         {1,63415509105}}],
       {dict,0,16,16,8,80,48,
             {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
             {{[],[],[],[],[],[],[],[],[],[],[],[],[],...}}},
       ["milk","bread"]}
  
  (riaktest@example.com)7> %% store the new list
  (riaktest@example.com)7> C:put(O2, 1).
  ok

     Finally, see what other keys are available in groceries bucket:


  (riaktest@example.com)8> C:list_keys(<<"groceries">>).
  {ok,[<<"mine">>]}


3 Server Management 
~~~~~~~~~~~~~~~~~~~~

3.1 Configuration 
==================
   Configuration for the Riak server is stored in $RIAK/rel/riak/etc
   directory. There are two files:
   - vm.args 
     This file contains the arguments that are passed to the Erlang VM
     in which Riak runs. The default settings in this file shouldn't need to be
     changed for most environments.

   - app.config 
     This file contains the configuration for the Erlang applications
     that run on the Riak server.

   More information about this files is available in doc/basic-setup.txt.

3.2 Server Control 
===================

3.2.1 bin/riak 
---------------
    This script is the primary interface for starting and stopping the Riak
    server.

    To start a daemonized (background) instance of Riak:

    $ bin/riak start 

    Once a server is running in the background you can attach to the Erlang
    console via:

    $ bin/riak attach

    Alternatively, if you want to run a foreground instance of Riak, start it
    with:

    $ bin/riak console

    Stopping a foreground or background instance of Riak can be done from a
    shell prompt via:

    $ bin/riak stop 

    Or if you are attached/on the Erlang console:

    (riak@example.com)1> q().

    You can determine if the server is running by:

    $ bin/riak ping

3.2.2 bin/riak-admin 
---------------------
    This script provides access to general administration of the Riak server. 

    To join a new Riak node to an existing cluster:


  $ bin/riak start # If a local server is not already running
  $ bin/riak-admin join <node in cluster>

    (Note that you must have a local node already running for this to work)
    
    To verify that the local Riak node is able to read/write data:

    $ bin/riak-admin test