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

Riak is a decentralized datastore from Basho Technologies.

Clone this repository (size: 12.5 MB): HTTPS / SSH
$ hg clone http://hg.basho.com/riak
commit 315: 33a5ea0cbe7a
parent 314: 782ab18705bd
child 316: 6bb8907484bc
child 317: 20e1a57b25e8
child 325: f14ceb7797b3
do not multiply contents when making siblings defaultriak-0.5.1
jus...@basho.com
12 months ago

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

View at rev
riak / src /
filename size last modified message
Makefile 120 B 13 months ago import
chash.erl 8.3 KB 12 months ago chash unit tests
gen_server2.erl 35.1 KB 13 months ago import
jaywalker_resource.erl 6.0 KB 12 months ago typo: pull props from proplist (2)
jiak.erl 8.5 KB 12 months ago Fix jiak_client.
jiak_client.erl 6.2 KB 12 months ago bucket names are now binaries, instead of atoms
jiak_context.erl 2.4 KB 13 months ago import
jiak_context_tests.erl 1.8 KB 12 months ago some tests for jiak_context
jiak_default.erl 5.4 KB 13 months ago keys *must* be binaries - guard in riak_object + change test…
jiak_default_tests.erl 3.8 KB 12 months ago bucket names are now binaries, instead of atoms
jiak_example.erl 6.0 KB 13 months ago keys *must* be binaries - guard in riak_object + change test…
jiak_object.erl 26.3 KB 12 months ago bucket names are now binaries, instead of atoms
jiak_resource.erl 39.1 KB 12 months ago fix already-computed-etag case of generate_etag
jiak_util.erl 3.4 KB 12 months ago bucket names are now binaries, instead of atoms
json_pp.erl 1.5 KB 13 months ago import
merkerl.erl 12.4 KB 12 months ago eunit-ify merkle test
priority_queue.erl 7.9 KB 13 months ago import
riak.app.src 259 B 12 months ago increment riak app version number
riak.erl 3.7 KB 12 months ago Change Jiak to use new riak_client.
riak_app.erl 7.0 KB 12 months ago Get rid of ip/doorbell/cookie connection scheme, use…
riak_backup.erl 5.2 KB 12 months ago Finish switching riak_backup to work locally, clean up…
riak_bucket.erl 2.9 KB 12 months ago Combine riak_connect and riak_ring_gossiper, converting…
riak_claim.erl 2.2 KB 12 months ago mockable servers, and a test in riak_bucket
riak_client.erl 11.6 KB 12 months ago Add edocs to riak_eventer.
riak_connect.erl 6.3 KB 12 months ago Get rid of ip/doorbell/cookie connection scheme, use…
riak_delete.erl 2.9 KB 12 months ago use the right timeout
riak_dets_backend.erl 3.3 KB 12 months ago Added functions riak_client:filter_keys and…
riak_doorbell.erl 4.0 KB 12 months ago Create start-logger.sh to demonstrate event logging. Get…
riak_ets_backend.erl 3.7 KB 12 months ago bucket names are now binaries, instead of atoms
riak_event_logger.erl 4.1 KB 12 months ago Update event logger so that if no filename is provided, it…
riak_eventer.erl 14.0 KB 12 months ago Add edocs to riak_eventer.
riak_fs_backend.erl 7.1 KB 12 months ago bucket names are now binaries, instead of atoms
riak_get_fsm.erl 11.3 KB 12 months ago unique ids for client requests prevent mixing
riak_keys_fsm.erl 3.9 KB 12 months ago unique ids for client requests prevent mixing
riak_local_logger.erl 2.5 KB 13 months ago add a local-node logfile facility
riak_map_executor.erl 4.3 KB 13 months ago backends now store under {Bucket,Key} instead of hashed…
riak_map_localphase.erl 5.5 KB 12 months ago vnode-local map phase execution
riak_map_phase_fsm.erl 4.1 KB 12 months ago Merge.
riak_mapreduce.erl 6.5 KB 12 months ago bucket names are now binaries, instead of atoms
riak_mapreduce_fsm.erl 6.9 KB 12 months ago unique ids for client requests prevent mixing
riak_object.erl 18.7 KB 12 months ago bucket names are now binaries, instead of atoms
riak_osmos_backend.erl 6.7 KB 12 months ago bucket names are now binaries, instead of atoms
riak_put_fsm.erl 11.9 KB 12 months ago unique ids for client requests prevent mixing
riak_reduce_phase_fsm.erl 3.1 KB 12 months ago Merge.
riak_ring.erl 13.0 KB 12 months ago Finish switching riak_backup to work locally, clean up…
riak_ring_manager.erl 5.8 KB 12 months ago Merge.
riak_startup.erl 1.6 KB 12 months ago Get rid of ip/doorbell/cookie connection scheme, use…
riak_sup.erl 2.4 KB 12 months ago Get rid of ip/doorbell/cookie connection scheme, use…
riak_test_util.erl 2.0 KB 12 months ago add tests for new filter-keys and list-buckets queries to…
riak_util.erl 7.5 KB 12 months ago bucket names are now binaries, instead of atoms
riak_vnode.erl 10.9 KB 12 months ago do not multiply contents when making siblings
riak_vnode_master.erl 3.9 KB 13 months ago backends now store under {Bucket,Key} instead of hashed…
riak_vnode_sidekick.erl 3.8 KB 13 months ago ensure use of gen_server2:call/cast
riak_web.erl 2.2 KB 13 months ago default http log location
vclock.erl 5.6 KB 12 months ago convert ad-hoc unit test in vclock.erl to eunit

README

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

Date: 2010-06-09 10:06:44 CDT



Table of Contents
=================
1 Overview 
2 Quick Start 
    2.1 Building Riak 
    2.2 Starting Riak 
    2.3 Connecting a client to Riak 
    2.4 Clients for Other Languages 
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/
    - admin.org: Riak Administration Guide
    - architecture.txt: details about the underlying design of Riak
    - basic-client.txt: slightly more detail on using Riak
    - basic-setup.txt:  slightly more detail on setting up Riak
    - basic-mapreduce.txt: introduction to map/reduce on Riak
    - js-mapreduce.org: using Javascript with Riak map/reduce
    - man/riak.1.gz: manual page for the riak(1) command
    - man/riak-admin.1.gz manual page for the riak-admin(1) command
    - raw-http-howto.txt: using the Riak HTTP interface



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 (R13B04 or later) installation,
   building Riak should be as simple as:


  $ cd $RIAK
  $ make 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@127.0.0.1 -setcookie riak
  
  Eshell V5.7.4  (abort with ^G)
  (riaktest@127.0.0.1)1>

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


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


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

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


  (riaktest@127.0.0.1)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@127.0.0.1)3> C:put(O0, 1).
    
    Now, read the list back from the Riak server and extract the value


  (riaktest@127.0.0.1)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@127.0.0.1-riakdemo@127.0.0.1-266664",
              {1,63415509105}}],
            {dict,0,16,16,8,80,48,
                  {[],[],[],[],[],[],[],[],[],[],[],[],[],...},
                  {{[],[],[],[],[],[],[],[],[],[],[],...}}},
            undefined}}
  
   (riaktest@127.0.0.1)5> %% extract the value
   (riaktest@127.0.0.1)5> V = riak_object:get_value(O1).
   ["bread"]

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


  (riaktest@127.0.0.1)6> %% add milk to the list
  (riaktest@127.0.0.1)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@127.0.0.1-riakdemo@127.0.0.1-266664",
         {1,63415509105}}],
       {dict,0,16,16,8,80,48,
             {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
             {{[],[],[],[],[],[],[],[],[],[],[],[],[],...}}},
       ["milk","bread"]}
  
  (riaktest@127.0.0.1)7> %% store the new list
  (riaktest@127.0.0.1)7> C:put(O2, 1).
  ok

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


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

2.4 Clients for Other Languages 
================================

   Client libraries are available for many languages.  Rather than
   bundle them with the Riak server source code, we have given them
   each their own source repository.  Currently, official Riak
   client language libraries include:

   + Javascript
     [http://bitbucket.org/basho/riak-javascript-client]

   + Python
     [http://bitbucket.org/basho/riak-python-client]

   + Ruby
     [http://bitbucket.org/basho/riak-ruby-client]
     [http://github.com/seancribbs/ripple/]

   + Java
     [http://bitbucket.org/basho/riak-java-client]

   + PHP
     [http://bitbucket.org/basho/riak-php-client]

   + Erlang
     [http://bitbucket.org/basho/riak-erlang-client]
     (using protocol buffers instead of distributed Erlang)

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@127.0.0.1)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. 
    The below commands assume you are running a default configuration for 
    parameters such as cookie.

    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

    To backup a node or cluster run the following:
    $ bin/riak-admin backup riak@X.X.X.X riak <directory/backup_file> node
    $ bin/riak-admin backup riak@X.X.X.X riak <directory/backup_file> all
    
    Restores can function in two ways, if the backup file was of a node the 
    node will be restored and if the backup file contains the data for a 
    cluster all nodes in the cluster will be restored.
    
    To restore from a backup file:
    $ riak-admin restore riak@X.X.X.X riak <directory/backup_file>
    
    To view the status of a node:
    $ bin/riak-admin status
    
    If you change the IP or node name you will need to use the reip command:
    $ bin/riak-admin reip <old_nodename> <new_nodename>