0% found this document useful (0 votes)
37 views3 pages

A Personalized Guide To Installing Cassandra On My Local Computer

This document provides steps to install Cassandra locally and set it up with a keyspace and table. It explains that one must first install Java, then Cassandra by adding repositories and installing the package. It describes how to check the Cassandra service, start it, and connect via cqlsh. It also outlines creating a keyspace and table, loading sample data from a CSV file using a Python script, and extracting data to another CSV file.

Uploaded by

chinmayghosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views3 pages

A Personalized Guide To Installing Cassandra On My Local Computer

This document provides steps to install Cassandra locally and set it up with a keyspace and table. It explains that one must first install Java, then Cassandra by adding repositories and installing the package. It describes how to check the Cassandra service, start it, and connect via cqlsh. It also outlines creating a keyspace and table, loading sample data from a CSV file using a Python script, and extracting data to another CSV file.

Uploaded by

chinmayghosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

A personalized guide to installing

cassandra on my local computer


Crafted by Partha | Supported by Vishal
1st June, 2020

Installing Cassandra
There were several steps I had to follow in order to get cassandra running on my system.
I came across them out one by one, slowly— and it took me ∼3 days to figure out the route.

First need to install java


To have a successful cassandra installation, one needs the correct version of Java.
1 /home/partha$ java −version

might give something like —


2 openjdk version "11.0.7" 2020−04−14

Well, version 11 is fine. But if you get 9 or 10 , sorry— you will need. . .
3 /home/partha$ sudo apt−get install openjdk −11− j d k openjdk −11− j r e

followed by. . .
4 /home/partha$ sudo apt−get update

5 /home/partha$ echo " deb http://www.apache.org/dist/cassandra/debian 311x


main" | sudo tee −a /etc/apt/sources.list.d/ cassandra .sources.list
6 /home/partha$ https://www.apache.org/dist/ cassandra /KEYS | sudo apt−key
add −
7 /home/partha$ sudo apt−get update

and finally
8 /home/partha/cassandra$ sudo apt−get install cassandra

This should install cassandra to one’s local system.

1
To check, just type on your termainal . . .
9 /home/partha/cassandra$ service cassandra status

To start the cassandra service, the follwing command need to be executed —


10 /home/partha/cassandra$ bin/ cassandra

. . . and enter the environment using —


11 /home/partha/cassandra$ cqlsh

Creating a keyspace
12 cqlsh> CREATE KEYSPACE cxsphere_development WITH replication = {’class’: ’
SimpleStrategy’, ’replication_factor’: ’1’} AND durable_writes = true;
13
14 cqlsh> DESCRIBE keyspaces;
15
16 system_virtual_schema system_schema system_views system_distributed
17 cxsphere_development system_auth system system_traces
18
19 cqlsh> CREATE TABLE cxsphere_development.customer_identity(app_id text,
user_id int, source text, section text, category text, data map<text,
text>, primary key(app_id, user_id, source, section, category));
20
21 cqlsh> DESCRIBE tables;
22
23 Keyspace system_virtual_schema
24 −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
25 keyspaces "columns" tables
26
27 Keyspace cxsphere_development
28 −−−−−−−−−−−−−−−−−−−−−−−−−−−−−
29 customer_identity
30
31 Keyspace system_schema
32 −−−−−−−−−−−−−−−−−−−−−−
33 ... ... ...

2
Once tables or keyspaces are created. . .

We need to load data (say, from a csv file), and read data from the tables for our varied
obscure purposes !

Loading data to cassandra


To load the data in the india_terrain directory to cassandra, one would need —
34 /home/.../cxsphere-api/data-pipeline/in$ python sales.py indian_terrain
indian_terrain/data−sample.csv

Extracting data from cassandra


Once that is done, data can be read from the local cassandra server with —
35 /home/.../cxsphere-api/data-pipeline/out$ python sales.py indian_terrain
indian_terrain/output.csv

A bird’s eye view of the folder structure looks like this —


|- > in
| | ...
| +-- sales . py
| +-> indian_terrain
| |- - ...
| +- - data - sample . csv
L -> out
| ...
+- - sales . py
+- > indian_terrain
|- - ...
+- - output . csv

You might also like