Tuesday, October 27, 2015

Oracle NoSQL Database and performing some basic operations

Hi ,

In this post ,  I am adding  a new page on my career and get closed to Oracle NoSQL database and functionalities. Today, i am going to talk about literally "kv approach" and do some administrative tasks like connecting and querying data.



Oracle launches on NoSQL site with this product and provides distributed key/value pair storage . For the architecture you can visit documentation, but briefly storage model consists of 2 main models . Storage nodes and replica nodes.

Storage Node is a physical (or virtual) machine with its own local storage. And every storage node has replica nodes. Replication nodes are organized into shards. A shard consists of master node for replication issues and copy nodes which improve read capability. I'll talk about the other components later, here you can see the figures below for architecture.





Lets look at our topology on BDA, here topology means all collection of storage nodes, replication nodes and administration services and etc. in cluster.

kv-> show topology
store=#MYSTORE#  numPartitions=720 sequence=772
  zn: id=zn1 name=#MYZONE# repFactor=3 type=PRIMARY

  sn=[sn1] zn:[id=zn1 name=#MYZONE#] #MYHOST1#:5000 capacity=12 RUNNING
    [rg1-rn1] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg2-rn1] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg3-rn1] RUNNING
          No performance info available
    [rg4-rn1] RUNNING
          No performance info available
    [rg5-rn1] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg6-rn1] RUNNING
          No performance info available
    [rg7-rn1] RUNNING
          No performance info available
    [rg8-rn1] RUNNING
          No performance info available
    [rg9-rn1] RUNNING
          No performance info available
    [rg10-rn1] RUNNING
          No performance info available
    [rg11-rn1] RUNNING
          No performance info available
    [rg12-rn1] RUNNING
          No performance info available
  sn=[sn2] zn:[id=zn1 name=#MYZONE#] #MYHOST2#:5000 capacity=12 RUNNING
    [rg1-rn2] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg2-rn2] RUNNING
             single-op avg latency=2.8995965 ms   multi-op avg latency=0.0 ms
    [rg3-rn2] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg4-rn2] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg5-rn2] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg6-rn2] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg7-rn2] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg8-rn2] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg9-rn2] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg10-rn2] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg11-rn2] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg12-rn2] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
  sn=[sn3] zn:[id=zn1 name=#MYZONE#] #MYHOST3#:5000 capacity=12 RUNNING
    [rg1-rn3] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg2-rn3] RUNNING
             single-op avg latency=1.1875367 ms   multi-op avg latency=0.0 ms
    [rg3-rn3] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg4-rn3] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg5-rn3] RUNNING
          No performance info available
    [rg6-rn3] RUNNING
          No performance info available
    [rg7-rn3] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg8-rn3] RUNNING
          No performance info available
    [rg9-rn3] RUNNING
          No performance info available
    [rg10-rn3] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg11-rn3] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms
    [rg12-rn3] RUNNING
             single-op avg latency=0.0 ms   multi-op avg latency=0.0 ms

  shard=[rg1] num partitions=60
    [rg1-rn1] sn=sn1
    [rg1-rn2] sn=sn2
    [rg1-rn3] sn=sn3
  shard=[rg2] num partitions=60
    [rg2-rn1] sn=sn1
    [rg2-rn2] sn=sn2
    [rg2-rn3] sn=sn3
  shard=[rg3] num partitions=60
    [rg3-rn1] sn=sn1
    [rg3-rn2] sn=sn2
    [rg3-rn3] sn=sn3
  shard=[rg4] num partitions=60
    [rg4-rn1] sn=sn1
    [rg4-rn2] sn=sn2
    [rg4-rn3] sn=sn3
  shard=[rg5] num partitions=60
    [rg5-rn1] sn=sn1
    [rg5-rn2] sn=sn2
    [rg5-rn3] sn=sn3
  shard=[rg6] num partitions=60
    [rg6-rn1] sn=sn1
    [rg6-rn2] sn=sn2
    [rg6-rn3] sn=sn3
  shard=[rg7] num partitions=60
    [rg7-rn1] sn=sn1
    [rg7-rn2] sn=sn2
    [rg7-rn3] sn=sn3
  shard=[rg8] num partitions=60
    [rg8-rn1] sn=sn1
    [rg8-rn2] sn=sn2
    [rg8-rn3] sn=sn3
  shard=[rg9] num partitions=60
    [rg9-rn1] sn=sn1
    [rg9-rn2] sn=sn2
    [rg9-rn3] sn=sn3
  shard=[rg10] num partitions=60
    [rg10-rn1] sn=sn1
    [rg10-rn2] sn=sn2
    [rg10-rn3] sn=sn3
  shard=[rg11] num partitions=60
    [rg11-rn1] sn=sn1
    [rg11-rn2] sn=sn2
    [rg11-rn3] sn=sn3
  shard=[rg12] num partitions=60
    [rg12-rn1] sn=sn1
    [rg12-rn2] sn=sn2
    [rg12-rn3] sn=sn3


You see i have 3 Storage Nodes with option of Replication Factor 3. It means in a Shard there are 3 node for replication. And you can see i have 60 Partitions for key value pairs. Here Store means keeping metadata like database name for this cluster.

In our BDA environment , we setup a NoSQL cluster given below and you can interact with database with Java APIs.

For connecting a non-Secure Oracle NoSQL database, you run following command :

$ java -jar /opt/oracle/kv-ce/lib/kvstore.jar runadmin -host localhost -port 5000
kv-> 
kv-> 
kv-> show
Incorrect number of arguments for command: show
Usage: show admins |
            events |
            faults |
            indexes |
            parameters |
            perf |
            plans |
            pools |
            schemas |
            snapshots |
            tables |
            topology |
            upgrade-order |
            users |

            zones

If you enable security you have to provide an security file for authentication.

$java -jar $KVHOME/lib/kvstore.jar runadmin -port 5000 -host localhost -security adminlogin.txt 
Logged in admin as root
kv-> 

kv-> 

After that you can list all the tables in your store like this


kv-> show table
Tables: 
        myTable
        user_test

And to see contents of a table, you must connect to your store.

kv-> connect store -name #MYSTORE# -port 5000 -host localhost -security adminlogin.txt 
Connected to #MYSTORE#  at localhost:5000.
kv-> 

kv-> get table -name myTable
{"id":17113,"original_title":"The Ballad of Jack and Rose","overview":"The Ballad of Jack and Rose is a 2005 drama film written and directed by Rebecca Miller, and starring herhusband Daniel Day-Lewis; it also stars Camilla Belle, Catherine Keener, Paul Dano, Ryan McDonald, Jason Lee, Jena Malone, Susanna Thompson and Beau Bridges. The film tells the story of an environmentalist and his teenage daughter who livealone on a secluded island commune, and their complicated relationship as a heart illness brings his life to an end. It was filmed in Rock Barra, Prince EdwardIsland, Canada and in New Milford, Connecticut.","poster_path":"/mHuDRajE1H8y74oCRpZHFSNiqDi.jpg","release_date":"2005","vote_count":916051,"runtime":121,"popularity":5.0,"genres":"Drama"}
{"id":1171867,"original_title":"Yojinbo","overview":"{nihongo","poster_path":"","release_date":"1961","vote_count":0,"runtime":0,"popularity":7.0,"genres":"Drama"}
{"id":11020,"original_title":"Picnic at Hanging Rock","overview":"This is a story about a frog who turns into a prince","poster_path":"/2OSDlLISTBz7qhA0aGOziguve6w.jpg","release_date":"1975","vote_count":5120000,"runtime":121,"popularity":11.0,"genres":"Drama"}
{"id":11112,"original_title":"The Associate","overview":"The Associate is a 1996 film starring Whoopi Goldberg, Dianne Wiest, Eli Wallach, Timothy Daly, Bebe Neuwirth, Austin Pendleton and Lainie Kazan. Is based on the Jenaro Prieto novel El Socio (1928).","poster_path":"/8ifNj9AER5WlC64HVar5ZHTNiqu.jpg","release_date":"1997","vote_count":0,"runtime":122,"popularity":3.0,"genres":"Comedy"}
{"id":1430,"original_title":"Bowling for Columbine","overview":"Bowling for Columbine is a 2002 American documentary film written, directed and narrated by Michael Moore. Thefilm explores what Moore suggests are the causes for the Columbine High School massacre in 1999 and other acts of violence with guns. Moore focuses on the background and environment in which the massacre took place and some common public opinions and assumptions about related issues. The film also looks into the natureof violence in the United States.The film brought Moore international attention as a rising filmmaker and won numerous awards, including the Academy Award for Best Documentary Feature, the Independent Spirit Award for Best Documentary Feature, a special 55th Anniversary Prize at the 2002 Cannes Film Festival and the Cesar Award for Best Foreign Film.","poster_path":"/8oc0FyFmbeFAr4AWIlcsTTwXTPh.jpg","release_date":"2002","vote_count":58008423,"runtime":120,"popularity":14.0,"genres":"Documentary"}
{"id":48395,"original_title":"Rare Exports","overview":"Rare Exports: A Christmas Tale is a 2010 Finnish Fantasy film directed by Jalmari Helander about people living near the Korvatunturimountain who discover the secret behind Santa Claus. The film is based on a 2003 short film Rare Exports Inc. by Jalmari and Juuso Helander.","poster_path":"/y7jpOSMjYT4xE5vZi0l8sJ3vS0V.jpg","release_date":"2010","vote_count":0,"runtime":125,"popularity":15.0,"genres":"Fantasy"}
{"id":43772,"original_title":"Raye makhfi","overview":"Secret Ballot ({{lang-fa","poster_path":"/umn64QR4U3UgOzDMEJ8a8w4cgfx.jpg","release_date":"2001","vote_count":0,"runtime":180,"popularity":1.0,"genres":"Drama"}
{"id":15258,"original_title":"The Aristocrats","overview":"The Aristocrats is a 2005 documentary filmabout the famous dirty joke of the same name.  It was conceived and produced bycomedians Penn Jillette and Paul Provenza, edited by Emery Emery, and released to theaters by TH!NKFilm.  The film is dedicated to Johnny Carson, as \"The Aristocrats\" was said to be his favorite joke.","poster_path":"/EyTR50IhzyLEn76qDcqt7JaZMg.jpg","release_date":"2005","vote_count":6377277,"runtime":181,"popularity":13.0,"genres":"Documentary,Comedy"}
{"id":20006,"original_title":"Pink Cadillac","overview":"Pink Cadillac is a 1989 American action-comedy film about a bounty hunter and a group of white supremacists chasing after an innocent woman who tries to outrun everyone in her husband's prized pinkCadillac. The film starred Clint Eastwood and Bernadette Peters and also has small cameo appearances by Jim Carrey and Bryan Adams.","poster_path":"/alnmL28Epu8V5thcLyvZ1t0CSTk.jpg","release_date":"1989","vote_count":12143484,"runtime":0,"popularity":12.0,"genres":"Comedy,Music,Action"}
{"id":22327,"original_title":"Youth in Revolt","overview":"Youth in Revolt is a 2009 coming-of-age film adaptation of C.D. Payne's epistolary novel of the same name starringMichael Cera.","poster_path":"/zRoAnTniqhzcUUrUj777bmlNmo7.jpg","release_date":"2009","vote_count":1962,"runtime":60,"popularity":6.0,"genres":"Comedy"}

10 rows returned
kv->

To look at users, type

kv-> show users
user: id=u2 name=#USER1#
user: id=u1 name=root

Ok, that's all. I will talk about much in next posts.

Enjoy & share.


Source:
http://docs.oracle.com/cd/NOSQL/html/index.html
http://docs.oracle.com/cd/NOSQL/html/ConceptsManual/architecture.html

No comments :

Post a Comment