Cassandra NoHostAvailable: error in CQLSH - cassandra

I just finished creating my table in cassandra. I attempted to insert data into the table and I was given this error:
cqlsh:test> INSERT into qw (id, user, pass, email, phoneNum) VALUES (1, 'scman', '123','sc#gmaail.com','123-456-7890');
NoHostAvailable:
I checked that my server was running. What could be causing this problem.

This is too late to answer. But I wanted to share my experience.
If you have a single node cluster and use NetworkTopologyStrategy, then it throws this error. Check your keyspace configuration.
Error during inserting data: NoHostAvailable:

My CQL command to update the replication
ALTER KEYSPACE my_keyspace WITH replication = {'class' : 'NetworkTopologyStrategy', 'DC1' : 1 ,'DC2' :2 };
was slightly different from the config files : conf/cassandra-rackdc.properties
# These properties are used with GossipingPropertyFileSnitch and will
# indicate the rack and dc for this node
dc=dc1
rack=rack1
resulting in a
cqlsh: my_keyspace> select * from world where message_id = 'hello_world';
NoHostAvailable:
the replication strategy is case sensitive and copy/paste from documentation may lead you to a mistake.
Fix : Changing the replication info so that it match the config files
ALTER KEYSPACE my_keyspace WITH replication = {'class' : 'NetworkTopologyStrategy', 'dc1' : 1 ,'dc2' :2 };
And execute on each node :
bin/nodetool repair --full my_keyspace
Got replication set on every node

Related

DSE Loading Data using Bulk Loader

Currently, I have successfully installed the necessary nodes and datacenters through the usage of the OpsCenter.
I have also generated the necessary table and Keyspace using Cassandra through DataStax Studio
KeySpace Generated
CREATE KEYSPACE graph_tables WITH REPLICATION = {'class':'SimpleStrategy', 'replication_factor':1};
Table Generated
CREATE TABLE people_node (id text, name text, age int, location 'PointType', gender text, dob timestamp, PRIMARY KEY(id));
Sample Data
id, name , age, location, gender, dob
0, Betsy, 15 , 10 15 , F , 1997-09-21T12:55:54
Assuming we have a node_1 with the IP Address 1.1.1.1 and second node called node_2 with the IP Address 2.2.2.2. These will be the two nodes that the OpsCenter have installed Cassandra on
From here I attempted to insert the necessary data using dsbulk
dsbulk load -url ./people_node_csv -k graph_tables -t people_node -h '1.1.1.1, 2.2.2.2 ' -header true
However, this results in an error stating "Operation Load_..... failed: Authentication error on host /1.1.1.1:9042: Host /1.1.1.1:9042 requires authentication, but no authenticator found in Cluster Configurations". I attempted to resolve this by adding in "driver.ssl.keystone.password = cassandra" as shown in the Document. But the error still persist. Any advise on solving this issue will be greatly appreciated.
You need to provide following settings as described in documentation:
-u - to specify user name
-p - to specify password
--driver.auth.provider DsePlainTextAuthProvider - to select corresponding authentication provider.

Creating keyspace on Cassandra

I am new to Cassandra, I wrote a blog in French that narrate all the unpleasant experiences that I have because of him (like always having Unable to find java executable when launching it after rebooting or the 7199 always already in use...). I created a github repository to share my cassandra directory.
But until now I can manage them unti this new one that didn't appeared last time I tried to launch Cassandra.
I try to create a keyspace about Cassandra with the help of the tutorialspoint tutorial but there is a problem: When I make the command to create a Keyspace:
;CREATE KEYSPACE k1 WITH
strategy_class = 'SimpleStrategy'
AND trategy_otpions:replication_factor = '1';
...
Or even :
cqlsh> CREATE KEYSPACE k1 WITH
... replication = {'class': 'strategy_class = 'SimpleStrategy'
... AND trategy_otpions:replication_factor = '1';
...
It just won't compile even after a semicolon ...
Do you have an idea ?
Do you have a good tutorial on Cassandra ?
Edit 28/11
I don't know why but this command worked :
cqlsh> CREATE KEYSPACE IF NOT EXISTS k1 WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
My next question will be on how to import a very large csv file one can found on the open platform of French public data there is at least 150 column which can all have the vartext type but the first one which is numeric.
I think your syntax for cqlsh it's wrong, if the one that you pasted is the one that you used.
The correct syntax for cqlsh is CREATE KEYSPACE test WITH replication = {'class':'SimpleStrategy', 'replication_factor' : 3};.
For importing data from a csv file you should read on this https://docs.datastax.com/en/cql/3.3/cql/cql_using/useInsertCopyCSV.html

Cassandra Datastax Node.js driver can't find keyspace

Just installed Cassandra (3.11.1) and Datastax node.js driver (3.3.0).
Created a simple structure:
CREATE KEYSPACE CaseBox
WITH REPLICATION={
'class': 'SimpleStrategy',
'replication_factor': 1};
USE CaseBox;
CREATE TABLE Regions (
regionId int,
name varchar,
PRIMARY KEY ((regionId))
);
Trying connect to the keyspace with no success:
const client = new cassandra.Client({
contactPoints: ['localhost'],
keyspace: 'CaseBox'
});
await client.connect();
Error: Keyspace 'CaseBox' does not exist.
If I change the desired kayspace to system it works.
What's wrong? Please assist.
You can find my full Cassandra config, CQL and js scripts here.
Keyspace names are forced lower case when unquoted in CQL.
Use CREATE KEYSPACE "CaseBox" in CQL or keyspace: 'casebox' in Node.
Generally just use snake_case names as you won't get trapped like this as often.

"Drop keyspace" command in cassandra

i created a key space named 'hello' in Cassandra and started using it(use command). so the commands were typed after cqlsh:hello> in the cql. i then dropped the key space hello, but still it is showing cqlsh:hello> at beginning of each command. why so ?
The keyspace is gone, but you need to reset your session context with the 'use' command.
cqlsh:test> create keyspace xyz with replication = {'class':'SimpleStrategy', 'replication_factor':1} ;
cqlsh:test> use xyz;
cqlsh:xyz> drop keyspace xyz;
cqlsh:xyz> describe keyspace
Keyspace 'xyz' not found.
cqlsh:xyz>

Altering keyspace to change strategy class is not working in cassandra-cli

I have tried to alter the keypace with strategy class and options using below command in cassandra-cli of version cassandra 1.1.6 but it says 'Syntax error at position 0: no viable alternative at input 'ALTER'.
ALTER KEYSPACE system_auth WITH REPLICATION =
{'class' : 'NetworkTopologyStrategy', 'dc1' : 3, 'dc2' : 2};
What is wrong here?
What is happening, is that you are using CQL syntax to update a keyspace from within the (deprecated) cassandra-cli tool. If you were using the cqlsh tool, your command would work just fine. But with cassandra-cli, that's not going to work. As Yasmeen indicated, the correct syntax that you will want to use is UPDATE KEYSPACE:
UPDATE KEYSPACE system_auth with placement_strategy = 'NetworkTopologyStrategy'
and strategy_options = {'dc1' : 3, 'dc2' : 2};
I do recommend that you use cqlsh in the future. The cassandra-cli is deprecated, and will not receive any further updates.
Also, you should also see about upgrading your cluster to a more recent version of Cassandra. While you are missing out on several new features, there have been many bugs fixed since 1.1.6 (bugs that you are probably running into).
UPDATE KEYSPACE demo
WITH placement_strategy = 'NetworkTopologyStrategy'
AND strategy_options = {'dc1' : 3, 'dc2' : 2};

Resources