Pages

Friday, June 29, 2012

NO SQL with Cassandra: Step by Step with Cassandra CLI


Step 1: Please navigate to the folder in which you have installed and configured Cassandra\bin directory in my case it is E:\software\cassandra\bin. Then please execute the batch command Cassandra-cli


 Step 2: Now you will see the following screen which will show the prompt related to Cassandra after connecting to the server.
 Step 3: Let us create the Keyspace for working as “Test”

Step 4: The message will get into an agreement with the cluster and it creates the keyspace, please assume that keyspace is analogous to Database in RDBMS. Now let us use the keyspace using the command “use test;”
Now you will get a message such as Authenticated to keyspace: test

Step 5: Creating the User column family.

As per the screenshot we have created the column family with the columns full_name, email and gender.

Step 6: Now let us see how to insert values in to these columnfamily we have just created.
In the above given screenshot you can realize how we have inserted value to the column family in Cassandra.

Step 7: Now let us see how we need  to read the ones which are stored, that’s pretty simple just give List Users;

In this you can realize that each of it has column name, value and its timestamp. Wonderful isn’t? Now I have added a new column called birth_year to the user kumar with the value 1980, as given in the following:

Now let’s list the users and see what impact it has made.

Now it has listed two users  one user with 3 column values and another user with 4 column values. hope now you have realized how we can add columns dynamically with Cassandra.
Step 8: Let’s try and get value for a specific user.  Now you need to user GET.

The command will go like this GET users[‘siva’];

Step 9:  We will try to retrieve the value for specific column for the specific user’s email id.
The command will go like this GET users[‘siva’][‘email’];

Step 10: How to delete a particular column for the given user?
This ends my preliminary exploration of Cassandra for NOSQL. Will try to come up with more experiments in the upcoming days. Thanks.

2 comments:

Unknown said...

Hey I need a little help with getting setup with cassandra - would you be interested in helping out.
I can pay any charges incurred.
my email address is sn2000@gmail.com
thanks.
sri

T. Thirumavalavan said...

Rs.150 charge for withdrawal http://valavan-teentonic.blogspot.com/2017/03/rs150-charge-for-withdrawal.html