Unable to connect to Cassandra in Presto - cassandra

I have setup Cassandra, and I've created a keyspace('mykeyspace') and a table in it. I started Cassandra as a service, added the cassandra.properties file like this, in the presto installation files:
connector.name=cassandra
cassandra.contact-points=localhost
cassandra.native-protocol-port=9142
cassandra.thrift-port=9160
After this I have issued this command in Presto but I'm not sure if it is connecting to the Cassandra data:
./presto --server localhost:8080 --catalog cassandra --schema mykeyspace
Now, when I give the command 'show tables', I get this Exception-message:
All host(s) tried for query failed (tried: localhost/127.0.0.1 (com.datastax.driver.core.TransportException: [localhost/127.0.0.1] Cannot connect))
I have used cqlsh, to view a created table in 'mykeyspace' in cassandra, and hence sure that cassandra is running.
I would really appreciate any help to clear this error.

If you have a default cassandra installation, the dafault native protocol port is 9042. If that is the case, you can remove cassandra.native-protocol-port and cassandra.thrift-port properties.
If you want to keep this ports, you can change cassandra.yaml configuration file, property native_transport_port
I hope it's helps.

Related

Not able to login to cqlsh in datastax Cassandra cluster hosted in Google cloud platform

I have set up a 2 node Casandra cluster in GCP.
But the issue is I am not able go to cqlsh.I am getting the belwo error
$ cqlsh
Connection error: ('Unable to connect to any servers', {'127.0.0.1':
First, as I mentioned to you in this answer, using cqlsh to connect to 127.0.0.1 simply will not work in a multi-node cluster. You will need to specify the IP address shown in the result of your nodetool status command.
Next, the second part of the error message should give a big clue on this one:
AuthenticationFailed('Remote end requires authentication'),)})
With authentication enabled, you will need to provide a valid username and password to log in. If you have not created any new users, then the username and password will both be defaulted to "cassandra."
$ cqlsh 10.138.0.3 -u cassandra -p cassandra
Try this:
cqlsh 10.138.0.3 9042

How to load data from cassandra into NIFI

I want to use the querycassandra processor, but i'm facing some troubles. I'm trying to do some very basic actions which is selecting all rows from a table and then send them to another ExcecuteStream processor(java program).
Here is the table :
Here is the processor configuration. I've also added the port 9042 to the HDP sandbox both from the port forwarding table and the start_sandbox script:
username/password: cassandra
a global schema showing the error:
all host(s) tried for query failed (tried: /127.0.0.1:9042 (com.datastax.driver.core.exceptions.TransportException:[/127.0.0.1] Cannot connect)

Cannot connect to Cassandra on localhost

First time using cassandra, I have attempted to configue the yaml file according to other related posts but had no luck so far. Any idea how do so on the localhost?
The specified host(s) could not be reached.
All host(s) tried for query failed (tried: localhost/0:0:0:0:0:0:0:1:9042 (com.datastax.driver.core.TransportException: [localhost/0:0:0:0:0:0:0:1:9042] Cannot connect), localhost/127.0.0.1:9042 (com.datastax.driver.core.TransportException: [localhost/127.0.0.1:9042] Cannot connect))
[localhost/0:0:0:0:0:0:0:1:9042] Cannot connect
[localhost/127.0.0.1:9042] Cannot connect
Inverse the process(s) you already executed. To run cassandra on localhost, you don't need to change anything so far. You don't need to change cassandra.yaml. It'll run by default on localhost. Read the documents carefully.
Learn more about cassandra.yaml:https://docs.datastax.com/en/cassandra/2.1/cassandra/configuration/configCassandra_yaml_r.html
Maybe you can stop the Cassandra server and start it again.
bin/cassandra -f -R
Further this link helps understand
https://docs.datastax.com/en/cassandra/2.1/cassandra/configuration/configCassandra_yaml_r.html
cassandra.yaml config parameters.
You can also make sure that the ports are set correctly native_transport(9042),native_transport_port_ssl(9142),Storage_port(7000),roc_port(9160) and JMX port(7199).
Lastly,
seeds - "127.0.0.1"
assuming you are working on single node cassandra setup.
Might be your DataStax Cassandra Community Server windows service is stopped. So, start it and reconnect. i hope you get success.
While you are trying to start this service and if it would stopped again then you have to delete the logs folder (where DataStax installed) and restart this service.

Cassandra Cluster Setup Error : UnavailableException: Cannot achieve consistency level QUORUM

We're setting up 3 node Cassandra cluster in AWS.
We performed the below steps ;
1) On all 3 nodes, installed the latest version of Oracle JDK 1.8.
On all 3 nodes, installed Cassandra 2.1.8.
On all 3 nodes, located cassandra.yaml and set the following properties:
cluster_name: 'ABC'
authenticator: PasswordAuthenticator
authorizer: CassandraAuthorizer
write_request_timeout_in_ms: 5000
2) In the same file, set both "listen_address" and "rpc_address" to a permanent address of a host (the one which is not changed after Amazon VM restart).
3) In the same file, under "seed_provider" property, set "seeds" property to a permanent address of a host (the one which is not changed after Amazon VM restart) which is choosen to be the seed.
4) Save all changes and close the file. Also open the required ports in firewall.
5) Started Cassandra on all nodes one by one and confirmed that all nodes are up.
Problem :
Connected to node 1 and executed the below query
root#ip-10-181-119-112:/etc/cassandra/bin# ./cqlsh -u cassandra -p cassandra 10-181-119-112
Connected to Dev Cluster at 10-181-119-112:9042.
[cqlsh 5.0.1 | Cassandra 2.1.8 | CQL spec 3.2.0 | Native protocol v3]
Use HELP for help.
cassandra#cqlsh> ALTER KEYSPACE system_auth WITH REPLICATION = { 'class': 'NetworkTopologyStrategy', 'us-east': 3 };
Tried to change the same on second node but I am not able to connect to second node facing below error.
root#ip-10-181-133-155:/etc/cassandra/bin# ./cqlsh -u cassandra -p cassandra 10-181-133-155
Connection error: ('Unable to connect to any servers', {'10-181-133-155': AuthenticationFailed(u'Failed to authenticate to 10-181-133-155: code=0100 [Bad credentials] message="org.apache.cassandra.exceptions.UnavailableException: Cannot achieve consistency level QUORUM"',)})
Please let me know what I am doing wrong here and help me in resolving this issue.
It seems like it can't read the authentication data for the default user. Try to nodetool repair the system_auth keyspace on all nodes. Also, make sure the datacenter name used in your replication settings ("us-east") matches what you see in nodetool status.

I can not get Datastax DevCenter to connect to a remote database

When I try to set up a connection, I get the error
Unable to connect to 'Test Cluster': All host(s) tried for query failed
Unexpected error during transport initialization ... (host ip adresses) Channel has been closed
The remote database is on port 9161, which I added on the "Native port protocol" line.
Additionally is has a username or password, which I also added in the set up. This is all on a 64bit Windows machine.
i did have same your error!!
you have to open cmd firt
type "cd "
type "cassandra" to run cassandra server
then, you try again in DevCenter with localhost and port: 9042
i hope it may help you! ^^
There is another common scenario where this might happen in case someone stumbles upon this thread in the future.
This type of thing typically happens when the host crashes expectantly resulting in the corruption of the sstables or commitlog files.
This is why it is really important to use replication since when you get into this situation you can run nodetool repair to repair the corrupted tables and data from other nodes.
If you are not fortunate enough to have replication configured, then you are in for some data loss. Clear the suspect file from \data\commitlogs, cry a little and restart the node.

Resources