Apache cassandra


Published on

Introduction about Apache cassandra. In this presentation you can learn about what is apache cassandra, and how you can use CQL?

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Apache cassandra

  1. 1. By: Muralidharan Deenathayalan Technical Lead, www.quanticate.com Apache, Apache Cassandra, and Cassandra are trademarks of the Apache Software Foundation. Terms & Conditions
  2. 2. My Bio data • 7+ years of experience in Microsoft technologies like Asp.net, C#, SQL server and SharePoint • 2+ years of experience in open source technologies like Java, Alfresco and Apache Cassandra • Csharpcorner MVP Why I love Cassandra • It runs on Windows machines  • Easy to install • Easy to configure • Easy to develop
  3. 3. Agenda • What is Apache Cassandra ? • Birth • Architecture • Key Features • Key Components • Apache Cassandra Connectivity • What is CQL and CQL Drivers • Apache Cassandra – CRUD Demo
  4. 4. What is Apache Cassandra • Distributed • High Performance • Scalable • No Single Point of Failure database
  5. 5. Apache Cassandra - Birth 2008
  6. 6. Apache Cassandra - Architecture • The ring represents a cyclic range of token values (i.e., the token space). • Each node is assigned a position on the ring based on its token. • Each node communicates with each other node using Gossip protocol. • First data written into commit log for data durability • Later data pushed from commit log to memtable, once memtable is full then the data written into sstable (disk).
  7. 7. Open Source Column Oriented High PerformanceHigh Availability & Fault Tolerance Peer – Peer Architecture CQL Tunable Consistency Apache Cassandra - Features Flexible Schema
  8. 8. Apache Cassandra – Key Components Keyword Description Schema / Keyspace A collection of column families Table/ Column Family A set of rows Row An ordered set of columns Partitioning Keys are mapped into the token space by a Partitioner. Replication Cassandra provides high availability and fault tolerance through data replication. The replication uses the ring to determine nodes used for replication. Consistency Levels Clients can specify the consistency level on both read and write operations trading off between high availability, consistency, and perform CQL Cassandra provides an SQL-like query language called the Cassandra Query Language
  9. 9. Apache Cassandra connectivity • Apache Thrift (RPC) • Scalable cross-language services development • C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, OCaml and Delphi • thrift --gen <language> <Thrift filename> • http://thrift.apache.org/ • Cassandra Query Language (CQL) • SQL like statements • Supports Triggers • Does not support Sub-queries and joins • http://www.datastax.com/documentation/cql/3.1/cql/cql_using/about_cql_c.html
  10. 10. Apache Cassandra - CQL Client Drivers Language / Framework Client driver Name Description URI PHP Cassandra - PDO A CQL (Cassandra Query Language) driver for PHP http://code.google.com/a/apache- / Python Pycassa Pycassa is the most well known Python library for Cassandra https:// github.com/pycassa/pycassa Ruby Ruby Gem Ruby has support for Cassandra via a gem. http:// rubygems.org/gems/cassandra .NET Cassandra- Sharp .NET client for Cassandra https:// github.com/datastax/csharp -driver Node.Js Cassandra- Node Cassandra/ CQL driver for Node.js https://github.com/racker/node-ca
  11. 11. Step 1: Install Apache Cassandra. http://cassandra.apache.org/download/ Step 2: Install Python. http://www.python.org/download/releases/2.7.3/ Step 3: Add the Python executable path in the windows path variable, otherwise configure in the environment variable. Open command prompt : C:> path =%path%;<python exe path> Step 4: In the command prompt, navigate to Cassandrabin folder. For ex C:cassandrabin> Apache Cassandra - Installation
  12. 12. Apache Cassandra – Starting CLI Step 1: Start the Apache Cassandra Server by running <Cassandra>binCassandra.bat. Step 2: Start Command Line Interface from <Cassandra>bincassandra-cli.bat Step 3: Connect you Cassandra CLI with Cassandra Server.. Command: connect localhost/9160;
  13. 13. Apache Cassandra – Using CLI Demo Connect Cassandra Server - connect localhost/9160; Displaying existing Keyspaces - show keyspaces; Creating new keyspace - CREATE KEYSPACE testkeyspace with placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy' and strategy_options = {replication_factor:1}; Use existing keyspace - use testkeyspace ; Creating column family - create column family users with comparator = UTF8Type and key_validation_class=UTF8Type and column_metadata = [{column_name: userName, validation_class:UTF8Type}, {column_name: email, validation_class:UTF8Type}];
  14. 14. Apache Cassandra – Using CLI Demo Insert records into Columnfamily - set users['student01']['userName']='Student1'; - set users['student01']['email']='Student1@example.com'; Read existing record in a Columnfamily - get users['student01']['userName']; - get users['student01']; Update records in Columnfamily - set users['student01']['email']='Student1@example.co.in'; Deleting records in Columnfamily - del users['student01']['email']; - del users['student01'];
  15. 15. Apache Cassandra – Using CQL Demo Connect Cassandra Server and execute CQLSh.bat file Create Keyspace - CREATE KEYSPACE CassandraCQLDemo WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 }; Use existing keyspace - use CassandraCQLDemo; Creating tables - CREATE TABLE users( user_id varchar, age int, email varchar, city varchar,PRIMARY KEY (user_id));
  16. 16. Apache Cassandra – Using CQL Demo Insert records into table - INSERT INTO users(user_id, age, email, city)VALUES ('jsmith',32,'john.smith@example.com','Dallas'); - INSERT INTO users(user_id, city) VALUES ('pscott','New Jersey'); Read records from table - SELECT * FROM users; - SELECT * FROM users WHERE user_id='jsmith'; Update existing record in a table - update users set email = ‘muralidharan@example.com’ where user_id=‘'jsmith’; Deleting records in table - DELETE email FROM users WHERE user_id = 'jsmith '; - DELETE FROM users WHERE user_id = 'pscott';
  17. 17. Q & A
  18. 18. Follow me Twitter www.Twitter.com/muralidharand Coding-Freaks.Net www.codingfreaks.net
  19. 19. Thank you