Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

zoyan173_192891 avatar image
zoyan173_192891 asked ·

How do I run cassandra-stress on Academy VM DS201?

When running the command from step 8), it throw following exception, previous steps all passed without any issue:

java.lang.RuntimeException: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: localhost/0:0:0:0:0:0:0:1:9041 (com.datastax.driver.core.exceptions.TransportException: [localhost/0:0:0:0:0:0:0:1:9041] Cannot connect), localhost/127.0.0.1:9041 (com.datastax.driver.core.exceptions.TransportException: [localhost/127.0.0.1:9041] Cannot connect))
at org.apache.cassandra.stress.settings.StressSettings.getJavaDriverClient(StressSettings.java:148)
at org.apache.cassandra.stress.settings.StressSettings.getJavaDriverClient(StressSettings.java:116)
at org.apache.cassandra.stress.settings.SettingsSchema.createKeySpaces(SettingsSchema.java:66)
at org.apache.cassandra.stress.settings.StressSettings.maybeCreateKeyspaces(StressSettings.java:156)
at org.apache.cassandra.stress.StressAction.run(StressAction.java:56)
at org.apache.cassandra.stress.Stress.run(Stress.java:143)
at org.apache.cassandra.stress.Stress.main(Stress.java:62)
Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: localhost/0:0:0:0:0:0:0:1:9041 (com.datastax.driver.core.exceptions.TransportException: [localhost/0:0:0:0:0:0:0:1:9041] Cannot connect), localhost/127.0.0.1:9041 (com.datastax.driver.core.exceptions.TransportException: [localhost/127.0.0.1:9041] Cannot connect))
at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:237)
at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:84)
at com.datastax.driver.core.Cluster$Manager.negotiateProtocolVersionAndConnect(Cluster.java:1622)
at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1540)
at com.datastax.driver.core.Cluster.getMetadata(Cluster.java:402)
at org.apache.cassandra.stress.util.JavaDriverClient.connect(JavaDriverClient.java:177)
at org.apache.cassandra.stress.settings.StressSettings.getJavaDriverClient(StressSettings.java:139)
... 6 more


academyds201
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

bettina.swynnerton avatar image
bettina.swynnerton answered ·

Hi @zoyan173_192891,

try specifying the node to connect to explicitly:

/home/ubuntu/node/resources/cassandra/tools/bin/cassandra-stress
   write no-warmup n=250000 -node 127.0.0.1 -port native=9041 -rate threads=1

From the error trace it seems that it doesn't pick the right IP address in this setup.

I quickly tested this on my VM, and the above command launched cassandra-stress correctly.

Let us know how you get on.

3 comments Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tried with above command and still fail, but this remind me the issue of IP and Port, so finally I found it is on different port. It is just so confusing, for same IP for example here it is 127.0.0.1, the port can be different. In my case, it is 9042, NOT 9041. Once I put correct port, it is working now. Really wondering how this assigned at the back ??

1 Like 1 · ·

Happy to hear that it is working now.

And regarding the ports, it is a special situation with the VM, as we want to create several nodes on the same physical machine, and we only have the localhost address available. This is not how you would install a cluster for real, it is a workaround to help with the multi node exercises. It is a challenge to teach distributed system concepts on a single VM :)

1 Like 1 · ·
sriyer-dev avatar image sriyer-dev zoyan173_192891 ·

Thank you both for this thread and answer. I faced the same issue, and it turned out to be the port number (9042).

0 Likes 0 · ·