How to connect to Cassandra in itversity


#1

I wanted to create a sample project using Spark and Cassandra. Request anyone to let me know the details on how to connect to cassandra in Itversity lab. I want shell connectivity commands info: host, port, username, password etc

Your time and help is appreciated.

Thanks,
Ashok


#2

@ashok_singamaneni, sure let us work on it. We also have not done in the past.

Here are the connection details
Hostname: csql.itversity.com
Port: 9042
To launch cqlsh, first set environment variable CQLSH_HOST - export CQLSH_HOST=csql.itversity.com

You give a try using this information and let me know if you run into any issue. We will take it forward together.


#3

@itversity Durga, Thank you! I was able to login to Cassandra.


#4

Guys please share how i can connect to cassandra in spark.
i dont see com.datastax…
Please advise


#5

@dsu_barroha please follow the below code in github


#6

Thank you very much. It is helpful.


#7

@dsu_barroha You are welcome!


#8

Durga/Ashok, Do you know how i can set up cqlsh. I am having difficulty. I dont know where i can set up env variable. I am using mac to ssh itversity.


#9

I am unable to login to Cassandra. getting below mentioned error:
did set env variable as specified.
Connection error: (‘Unable to connect to any servers’, {‘144.217.156.70’: error(111, "Tried connecting to [(‘144.217.156.70’, 9042)]. Last error: Connection refused
")})


#10

@Usha_Potturu Use these details for connecting cassandra

Hostname: wn06.itversity.com
Port: 9042
To launch cqlsh, first set environment variable CQLSH_HOST - export CQLSH_HOST=wn06.itversity.com


#11

Hey ,

i follow above process but still i am not able to use cassandra.

Steps i used:

  1. Open putty session through gw03.itversity.com
  2. export CQLSH_HOST=wn06.itversity.com
  3. cqlsh

Error:

Connection error: (‘Unable to connect to any servers’, {‘172.16.1.108’: error(111, “Tried connecting to [(‘172.16.1.108’, 9042)]. Last error: Connection refused”)})

Please help

Thanks in advance


#12

@hardik_patira You no need to do anything. We have updated accessing Cassandra.
Now just type cqlsh to access it.


#13

Is cassandra active??

image

and also i am getting error NoHostAvaiable with below code

create keyspace perfmonitor
with replication = {‘class’ : ‘SimpleStrategy’ ,‘replication_factor’:‘1’};

use perfmonitor;

create table app_instance(
app_id int,
app_name varchar,
proc_id varchar,
host_id varchar,
os_priority int,
cpu_time int,
num_io_ops int,
primary key(host_id,proc_id))
with clustering order by (proc_id desc);

describe app_instance;

insert into app_instance
(app_id,host_id,proc_id,app_name,os_priority, cpu_time, num_io_ops)
values
(1, ‘Host1’, ‘Proc1’, ‘App1’, 90, 145, 250)


#14

@hardik_patira Cassandra service run’s on different hosts. You can access directly in gateway and now you can access your key space and tables.

image


#15

@hardik_patira:
Are you still facing this issue?
Correct keyspace code:

create keyspace perfmonitor
with replication = {‘class’ : ‘SimpleStrategy’,‘replication_factor’:1};

Issue:
Remove single quotes for 1. Just 1 enough.

Create table:
create table users
(
user_id int,
name text,
state text,
primary key(user_id)
);

Desc table:
CREATE TABLE killrvideo.users (
user_id int PRIMARY KEY,
name text,
state text
) WITH bloom_filter_fp_chance = 0.01
AND caching = {‘keys’: ‘ALL’, ‘rows_per_partition’: ‘NONE’}
AND comment = ‘’
AND compaction = {‘class’: ‘org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy’, ‘max_threshold’: ‘32’, ‘min_threshold’: ‘4’}
AND compression = {‘chunk_length_in_kb’: ‘64’, ‘class’: ‘org.apache.cassandra.io.compress.LZ4Compressor’}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = ‘99PERCENTILE’;

Hope this helps.
Thanks,Venkat