PUT Knowledge BUCKET Brain KEY Riak
Upcoming SlideShare
Loading in...5
×
 

PUT Knowledge BUCKET Brain KEY Riak

on

  • 843 views

Introduction to Riak, and Riak-CS at "Munich Rubyshift The big Ruby & Database shootout!" 9/2013 http://www.meetup.com/Munich-Rubyshift-Ruby-User-Group/

Introduction to Riak, and Riak-CS at "Munich Rubyshift The big Ruby & Database shootout!" 9/2013 http://www.meetup.com/Munich-Rubyshift-Ruby-User-Group/

Statistics

Views

Total Views
843
Views on SlideShare
841
Embed Views
2

Actions

Likes
0
Downloads
5
Comments
0

1 Embed 2

https://twitter.com 2

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

PUT Knowledge BUCKET Brain KEY Riak PUT Knowledge BUCKET Brain KEY Riak Presentation Transcript

  • PUT Knowledge BUCKET Brain KEY Riak An intro to Riak by Phil github.com/sideshowcoder twitter.com/ischi
  • Code The slides contain code, this is how it works a_string = "I am a string" a_string
  • Ok so Riak, eh? client = Riak::Client.new bucket = client.bucket("brain") object = bucket.get_or_new("riak") object.content_type = "application/json" object.data = { message: "Know stuff on riak!", level: "awesome" } object.store object.reload.data
  • What is Riak? Key / Value Store Distributed Dynamo based
  • Buckets client.bucket("brain").name
  • Keys bucket.keys
  • Values bucket.get("riak").data
  • Distributed Keyspace is spread across the members of a cluster via Consistent Hashing
  • Hashing Key => Hash(key) => Result => 2ˆn -1 possible outcomes Digest.hexencode Digest::MD5.digest("my-key")
  • Consistent Hashing Source littleriakbook
  • Replication Source littleriakbook
  • CAP Theorem Consistency Availability Partition tolerance
  • Trade-offs Riak chooses adjustable AP, which means it never reaches full Consistency but can be tuned to the needs
  • N/R/W Values N: Replication count R: Min number of nodes to read from W: Min number of nodes to write to
  • More on the basics behind this? Littleriakbook by Eric Redmond dynamo paper
  • Ring members $ riak-admin member-status =========================== Membership ============================ Status Ring Pending Node ------------------------------------------------------------------- valid 100.0% -- 'riak@127.0.0.1' ------------------------------------------------------------------- Valid:1 / Leaving:0 / Exiting:0 / Joining:0 / Down:0
  • Ring Status $ riak-admin ring-status ============================ Claimant ============================= Claimant: 'riak@127.0.0.1' Status: up Ring Ready: true ======================== Ownership Handoff ======================== No pending changes. ======================== Unreachable Nodes ======================== All nodes are up and reachable
  • Just Key / Value store? ... mehh! Tags Map and Reduce S3...
  • 2i aka Secondary Indexes aka Tags object = bucket.get("riak") object.indexes["level_bin"] = ["awesome"] object.store bucket.get_index("level_bin", "awesome")
  • Map and Reduce js_func = "function(v){ return [Riak.mapValuesJson(v)[0].message]; }" Riak::MapReduce.new(client) .add("brain", "riak") .map(js_func, :keep => true) .run
  • Let's talk S3 Wait what?
  • Run your own S3 (compatible) backed by Riak
  • Features Same API as S3 (use aws-sdk in ruby) Great reporting facilities It's your own S3!
  • Setup Install Riak Install RiakCS Install Stanchion It's detailed here
  • ... or just setup via Vagrant! $ vagrant plugin install vagrant-berkshelf $ vagrant plugin install vagrant-omnibus $ git clone https://github.com/basho/vagrant-riak-cs-cluster $ cd vagrant-riak-cs-cluster $ RIAK_CS_CREATE_ADMIN_USER=1 vagrant up Virtual setup using vagrant
  • Create a user curl -H 'Content-Type: application/json' -X POST http://127.0.0.1:8080/riak-cs/user --data '{"email":"admin@admin.com", "name":"admin"}'
  • OK let's try it! AWS::S3.new({ :access_key_id => "8AA5UQR3EACDS_TIAXLV", :secret_access_key => "M5eG0q1pN9y6hlc4-JbiCHXLt1YXCY2n7Sb5Yg==", :use_ssl => false, :proxy_uri => "http://localhost:8080" })
  • Create a bucket s3bucket = s3.buckets.create("my-bucket", :acl => :public_read) s3.buckets.map(&:name)
  • Write something! obj = s3bucket.objects["riak.jpg"] obj.write File.read('./images/riak.jpg') obj.acl = :public_read s3bucket.objects.map(&:key)
  • OK lets read it back This is loaded from local Riak CS
  • Recap Distributes Key / Value Store Easy to interface with Clients are build of HTTP Use RiakCS to replace or augment S3
  • Questions?
  • Resources Littleriakbook by Eric Redmond Basho docs on Racks