cs-695 nosql database riak (part 1 of 2)ccartled/teaching/2015-fall/... · 2015. 9. 8. · riak has...

18
1/18 Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides CS-695 NoSQL Database Riak (part 1 of 2) Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015 10 Sept. 2015

Upload: others

Post on 17-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

1/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

CS-695 NoSQL DatabaseRiak (part 1 of 2)

Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge

10 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 201510 Sept. 2015

Page 2: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

2/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

Table of contents I

1 Miscellanea

2 Origins and history

3 Data model

4 CRUDy stuff

5 Assignment #2

6 Conclusion

7 References

8 Backup Slides

Page 3: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

3/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

Corrections and additions since last lecture.

Assignment #1 should havebeen turned in.

Assignment #2 is available.

Page 4: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

4/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

Where it came from and why.

Riak is new.

Based on principles from Amazon’s“Dynamo” paper [2]

“. . . highly available key-value storagesystem . . . ”

BASE not ACID

Reliability and scalability are paramount

Data is partitioned, replicated,autoversioned

Reads and writes are quorum based

Key-value database

ReST framework

No security

Page 5: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

5/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

Where it came from and why.

Commercialized by Basho Technologies1

Riak versions:

1.1, Feb 21 2012, added Riaknostic, . . .

1.4, July 10, 2013, added counters, . . .

2.0, September 2, 2014, added new data types including sets,maps, registers, and flags . . .

2.1, April 16, 2015, added an optimization for manywrite-heavy workloads . . .

We have riak version 2.1.0 on cs695-nosql. (See usefullStuff.pdf).

1http://basho.com/

Page 6: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

6/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

What is in the backend?

The architecture (part 1 of 2)

Secure Hash Algorithm 1(SHA1) generates 160 bithash of key

SHA1 creates uniform hash

160 bit space is dividedacross “vnodes”

vnodes are divided acrossphysical nodes

Nodes are peer-to-peerImage from [4].

Page 7: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

7/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

What is in the backend?

The architecture (part 2 of 2)

Dotted vector clocks areused for version control[3]

No locking for CRUDoperations (BASE)

Vnode assignments handleddynamically, loss of a vnodenot catastrophic

Automatic read repair ofbad data

Active Anti-Entropy correctinconsistent data in thebackground

Image from [4].

Page 8: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

8/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

Pre-CRUDy stuff

Riak has a ReSTfull interface

http://SERVER:PORT/riak/BUCKET/KEY

SERVER – localhost

PORT – 8098 (forcs695-nosql)

riak – constant, casesensitive

BUCKET – where the stuffwill be store (a.k.a, thedatabase)

KEY – key associated withdata

Information about Riakinstallation:curl http://localhost:8098/stats |python -m json.tool

Page 9: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

9/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

Pre-CRUDy stuff

Creating a database

The database always exists. Usercreate namespaces (calledbuckets) within which keys areused to store and retrieve data.A namespace without keys doesnot exist.

Image from [1].

Page 10: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

10/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

CRUDy nuts and bolts

Creating a key-value pair

urlToKey = http://SERVER:PORT/riak/BUCKET/KEY

urlToKey = http://localhost:8098/riak/favs/db

curl -X PUT urlToKey -H “Content-Type: . . . ” -d”data”

curl -X PUT http://localhost:8098/riak/favs/db -H“Content-Type: text/html” -d“< html >< body >< h1 > My new favorite DB is RIAK. </h1 >< /body >< /html >”

The example shows HTML as the data, but it could be anything.Recommended Content-Type are controlled by Internet AssignedNumbers Authority (IANA)2.

2http://www.iana.org/assignments/media-types/media-types.xhtml

Page 11: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

11/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

CRUDy nuts and bolts

Reporting a key-value pair

curl urlToKey

curl http://localhost:8098/riak/favs/db

returns ⇒ <html><body><h1>My new favorite DB is

RIAK.</h1></body></html>

Page 12: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

12/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

CRUDy nuts and bolts

Updating and deleting a key-value pair

Updating

curl -X PUT urlToKey -H “Content-Type: . . . ” -d”new data”curl -X PUT http://localhost:8098/riak/favs/db -H“Content-Type: text/example -d “better data”

Deleting

curl -X DELETE urlToKeycurl -X DELETE http://localhost:8098/riak/favs/db

Page 13: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

13/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

CRUDy nuts and bolts

Deleting a database

There isn’t a straight forward way to get there from here.

curl urlToLocalHost/buckets/bucket/keys?keys=true3

curl http://localhost:8098/buckets/favs/keys?keys=true

returns ⇒ “keys”:[“db”]

Iterate through return values deleting each key

When all keys are gone, bucket is gone

Conceptually; a bucket is a namespace that is created when thefirst key is added, and deleted when the last key is removed.

3http://docs.basho.com/riak/latest/dev/references/http/list-keys/

Page 14: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

14/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

CRUDy nuts and bolts

Misc. Riak commands

Riak has a fairly well documented list of commands (HTTP andAPIs)4

Bucket-related operations (GET, SET, RESET, LIST)

Object-related operations (FETCH, STORE, DELETE)

Query-related operations (MapReduce, INDEXes)

Server-related operations (PING, Status, List resources)

Search-related operations (QUERY, INDEX info, fetch, store,delete, SCHEMA fetch, store)

4http://docs.basho.com/riak/latest/

Page 15: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

15/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

Words of explanation.

The full text is available at:http://www.cs.odu.edu/

~ccartled/

Teaching/2015-Fall/NoSQL/

Assignments/02/

Requires a YouTube video.

Page 16: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

16/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

What have we covered?

Basics of Riak key-valuedatabase.Riak is not safe/protected,beware of your “database”Assignment #2

Next time: continued CRUDy exploration

Page 17: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

17/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

References I

[1] Douglas Adams, The ultimate hitchhiker’s guide, Wings books, 1996.

[2] Giuseppe DeCandia, Deniz Hastorun, Madan Jampani, GunavardhanKakulapati, Avinash Lakshman, Alex Pilchin, SwaminathanSivasubramanian, Peter Vosshall, and Werner Vogels, Dynamo: Amazon’shighly available key-value store, ACM SIGOPS Operating Systems Review,vol. 41, ACM, 2007, pp. 205–220.

[3] Nuno Preguica, Carlos Bauqero, Paulo Sergio Almeida, Victor Fonte, andRicardo Goncalves, Brief announcement: Efficient causality tracking indistributed storage systems with dotted version vectors, Proceedings of the2012 ACM symposium on Principles of distributed computing, ACM, 2012,pp. 335–336.

[4] Alexander Sicular, Why riak just works,http://basho.com/posts/technical/why-riak-just-works/, 2015.

[5] Wikipedia Staff, Matsuo basho,https://en.wikipedia.org/wiki/Matsuo_Bash%C5%8D, 2015.

Page 18: CS-695 NoSQL Database Riak (part 1 of 2)ccartled/Teaching/2015-Fall/... · 2015. 9. 8. · Riak has a fairly well documented list of commands (HTTP and APIs)4 Bucket-related operations

18/18

Miscellanea Origins and history Data model CRUDy stuff Assignment #2 Conclusion References Backup Slides

Terms and definitions

Basho Technologies

Named for Matsuo Basho

Japanese poet 1644 - 1694

Greatest master of the haikuform

Image from [5].