Cassandra-2.2.8-Installation Guide

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

CASSANDRA – 2.2.

8 INSTALLATION
GUIDE
By. Mr. Gopal Krishna
Sr.Hadoop Architect
CCA 175-Spark and Hadoop Certified Consultant

STEP 1: Download dsc-cassandra-2.2.8-


bin.tar.gz from below website
http://downloads.datastax.com/community/

STEP 2: Place the Downloaded TARBALL in


‘INSTALL’ directory [Path:
/home/gopalkrishna/INSTALL]

STEP 3: Extract the Downloaded TARBALL


using below command
tar -xzvf dsc-cassandra-2.2.8-bin.tar.gz
STEP 4: After tarball extraction, we will get
a directory dsc-cassandra-2.2.8/

STEP 5: Update the CASSANDRA_HOME &


PATH Variables in bashrc file (command: nano
~/.bashrc)

# Below 2 lines we have to add for CASSANDRA Installationexport


CASSANDRA_HOME=/home/gopalkrishna/INSTALL/dsc-cassandra-2.2.8

export PATH=$PATH:$CASSANDRA_HOME/bin
STEP 6: To check the bashrc changes, open a new
terminal and type ‘echo $CASSANDRA_HOME’ command

STEP 7: To Start Cassandra Server, use below


command:

cassandra

NOTE: To start the server in foreground use


Cassandra -f

STEP 8: To Start with Cassandra Query Language


Shell [ cqlsh ], use the below command from any
path:
Command: cqlsh

NOTE: To Come of cqlsh, use exit command


cqlsh> show host
Connected to Test Cluster at 127.0.0.1:9042.
cqlsh> show version
[cqlsh 5.0.1 | Cassandra 2.2.8 | CQL spec 3.3.1 | Native protocol
v4]
cqlsh> CREATE KEYSPACE gopal_cql WITH replication = {'class':
'SimpleStrategy','replication_factor':1};
cqlsh>
cqlsh> DESC KEYSPACES;

system_traces gopal_cql system_auth system


system_distributed

cqlsh> USE gopal_cql ;


cqlsh:gopal_cql>
cqlsh:gopal_cql> DESCRIBE TABLES ;

<empty>

cqlsh:gopal_cql> CREATE TABLE emptab(empid int PRIMARY KEY ,


... ename text , esal int);

cqlsh:gopal_cql> DESCRIBE TABLES ;


emptab

cqlsh:gopal_cql> INSERT INTO emptab ( empid , ename , esal) VALUES (


100,'GOPAL',12000);
cqlsh:gopal_cql> INSERT INTO emptab ( empid , ename , esal) VALUES (
101,'RAVI',14000);
cqlsh:gopal_cql> INSERT INTO emptab ( empid , ename , esal) VALUES (
102,'KRISHNA',16000);
cqlsh:gopal_cql> INSERT INTO emptab ( empid , ename , esal) VALUES (
103,'MOUNI',18000);
cqlsh:gopal_cql>

cqlsh:gopal_cql> SELECT * FROM emptab ;

empid | ename | esal


-------+---------+-------
100 | GOPAL | 12000
102 | KRISHNA | 16000
101 | RAVI | 14000
103 | MOUNI | 18000

(4 rows)
cqlsh:gopal_cql>
cqlsh:gopal_cql> SELECT * FROM emptab WHERE empid = 103;

empid | ename | esal


-------+-------+-------
103 | MOUNI | 18000

(1 rows)
cqlsh:gopal_cql>
cqlsh:gopal_cql> SELECT * FROM emptab WHERE esal = 14000;
InvalidRequest: Error from server: code=2200 [Invalid query] message="Predicates on
non-primary-key columns (esal) are not yet supported for non secondary index queries"
cqlsh:gopal_cql>

cqlsh:gopal_cql> CREATE INDEX emptab_esal_index ON emptab (esal);


cqlsh:gopal_cql>
cqlsh:gopal_cql> SELECT * FROM emptab WHERE esal = 14000;

empid | ename | esal


-------+-------+-------
101 | RAVI | 14000

(1 rows)
cqlsh:gopal_cql>

You might also like