Book Image

Real-time Analytics with Storm and Cassandra

By : Shilpi Saxena
Book Image

Real-time Analytics with Storm and Cassandra

By: Shilpi Saxena

Overview of this book

Table of Contents (19 chapters)
Real-time Analytics with Storm and Cassandra
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Introduction to CQLSH


Now that we are through with the Cassandra setup, let's get acquainted with the shell and a few basic commands:

  1. Run CQL at /usr/local/Cassandra/apache-cassandra-1.1.6 using bin/cqlsh with a host and port:

    bin/cqlsh  –host <ip-adress> -p <port number>
    
  2. Create a keyspace either at the Cassandra client or at CQL, as follows:

    create keyspace <keyspace_name>; 
    
  3. Create a column family at the Cassandra client or at CQL as follows:

    use <keyspace_name>;
    create column family <columnfamily name>;
    

    For example, create the following table:

    CREATE TABLE appUSers (
      user_name varchar,
      Dept varchar,
      email varchar,
      PRIMARY KEY (user_name));
    
  4. Insert a few records into the column family from the command line:

    INSERT INTO appUSers (user_name, Dept, email)
      VALUES ('shilpi', 'bigdata, '[email protected]');
    
  5. Retrieve the data from the column family:

    SELECT * FROM appUSers LIMIT 10;