Configure cassandra 3.11.2 to accept remote connection on ec2 - cassandra

Hey guys i tried many of the solutions posted on different sites and stackoverflow too, but none of them worked for me.
I have eximented with the following cassandra.yaml paramters-
rpc_address
rpc_broadcast_address
listen_address
Most of the solutions are out dated, little help is highly appreciated

As discussed in chat, there was a typo while adding private ip address for listen_address in the cassandra.yaml. Due to this error, Cassandra never got started and hence no output for the following commands.
nodetool status
- Failed to connect to '127.0.0.1:7199' - ConnectException: 'Connection refused (Connection refused)
netstat -an | grep 9042
- returns nothing
As always, the first place to look at the errors is cassandra system log. And it clearly indicated the following problem.
ERROR [main] 2018-05-08 02:01:26,541 CassandraDaemon.java:708 - Exception encountered during startup: Invalid yaml: file:/etc/cassandra/cassan$
Error: while scanning a simple key; could not found expected ':'; in 'reader', line 678, column 1:
# Set rpc_address OR rpc_interfa ...
After fixing the ":" error in cassandra.yaml file, Cassandra came up smoothly.

Related

Cassandra : nodetool reporting error: Failed to connetc IP address [duplicate]

Cassandra nodetool throws an error after updating OpenJDK
nodetool status
nodetool: Failed to connect to '127.0.0.1:7199' - URISyntaxException: 'Malformed IPv6 address at index 7: rmi://[127.0.0.1]:7199'.
This also affects the current official Docker-Hub Image https://hub.docker.com/_/cassandra version 3.11.12
How can I fix this error?
There seems to be an issue with "improved" IPv6 address parsing in the latest jdk update.
The workaround would be to use the IPv6 notation of localhost
nodetool -h ::FFFF:127.0.0.1 status
You can upgrade to Apache Cassandra 3.11.13 or use this command:
nodetool -Dcom.sun.jndi.rmiURLParsing=legacy status
Another way is to add this -Dcom.sun.jndi.rmiURLParsing=legacy to JAVA_TOOL_OPTIONS environment variable.

Is there any solution for "nodetool: Failed to connect to '127.0.0.1:7199' - ConnectException: 'Connection refused (Connection refused)'"?

In my cassandra cluster , all nodes are available.
But for one node, when I check the status it is showing like:
"nodetool: Failed to connect to '127.0.0.1:7199' - ConnectException: 'Connection refused (Connection refused)'."
As I've seen some corrections, I tried restarting cassandra service after setting JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=127.0.0.1". But again it is giving the same status as:
"nodetool: Failed to connect to '127.0.0.1:7199' - ConnectException: 'Connection refused (Connection refused)'."
Can someone suggest another solution?
Can you edit your question with the actual nodetool status command being run?
Also are you using the standard, default cassandra-env.sh file? Or has it been changed? Regarding local/remote JMX, there are logic checks like this:
if [ "x$LOCAL_JMX" = "x" ]; then
LOCAL_JMX=yes
fi
if [ "$LOCAL_JMX" = "yes" ]; then
JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.local.port=$JMX_PORT"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
else
JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.remote.port=$JMX_PORT"
...
First of all, LOCAL_JMX is not defined by default. So if you want to enable remote JMX, you'll need to adjust the code. Secondly, adjusting the rmi.server.hostname needs to be done in the correct section.
Enabling remote JMX also allows JMX to work from the local machine. But the idea is that the port being used (7199, by default) is bound to the same IP that the Cassandra node itself is.
Essentially, if you were to comment-out the local/remote if constructs, these settings should allow JMX (and nodetool) to function. Note: assume an external IP address of 10.2.3.5.
JVM_OPTS="$JVM_OPTS -Dcassandra.jmx.remote.port=$JMX_PORT"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT"
JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT"
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=10.2.3.5"
Basically, the rmi.server.hostname should match the IP used to connect to the node.
If you continue having problems, start by checking your system.log. At startup, each node should have a line like this:
StartupChecks.java:176 - JMX is enabled to receive remote connections on port: 7199
or:
StartupChecks.java:169 - JMX is not enabled to receive remote connections. Please see cassandra-env.sh for more info.

Why is DBeaver trying random ports when trying to connect to Cassandra?

I have Cassandra running on a host that i can assess via SSH. When I want to connect with DBeaver, I am using the following connection settings:
Connection:
Host/Port: localhost:9042
SSH-Tunnel
Host/Port: my.remote.host:37938
On connect, I am getting the following error message:
com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1:35836 (com.datastax.driver.core.exceptions.TransportException: [/127.0.0.1:35836] Channel has been closed))
When I try again, I am getting the same error for a different port number:
com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1:48799 (com.datastax.driver.core.exceptions.TransportException: [/127.0.0.1:48799] Channel has been closed))
I had this behavior with Version 3 of DBeaver and also now with the newest Version 4.0.4
Why doesn't DBeaver use the configured port number to connect but a random one?
Try it with port 22, it works for me.
Does regular ssh on port 37938 working? Make sure the port is open. JMX can use these ports, so maybe you are interfering with it.
Which version of Cassandra you are using?
Set your HOST ip of your server to rpc_address in cassandra.yaml and restart your cassandra service.
Ex : If your cluster IP is 10.40.60.23
then cassandra.yaml in /etc/cassandra/ folder, incase of Ubuntu :
rpc_address : 10.40.60.23

Apache Cassandra - cqlsh operation timeout

I am trying to start cqlsh and this is what I get:
/bin$ ./cqlsh
Connection error: ('Unable to connect to any servers', {'127.0.0.1':
OperationTimedOut('errors=None, last_host=None',)})
I tried removing ~/.cassandra, did not work. I also compared cassandra.yaml with a version that worked.
Any ideas?
posting on this old thread as a memo for others, as i couln't managed to find any info to resolve these symptoms without debugging up to now:
got the same issue with a slow testing cluster, and i resolved it by setting a missing control_connection_timeout kwargs in Cluster() init, in cqlsh.py file.
issue opened and patch proposal provided at https://issues.apache.org/jira/browse/CASSANDRA-10959
Depending on your version and configuration, check the values specified for listen_address and/or rpc_address in your cassandra.yaml. If they are defined to anything other than localhost, you will need to provide that address when connecting with cqlsh.
$ grep listen_address: /etc/cassandra/cassandra.yaml
listen_address: 210.156.89.15
$ cqlsh 210.156.89.15 -u aploetz -p aploetz
Connected to PermanentWaves at 210.156.89.15.
[cqlsh 5.0.1 | Cassandra 2.1.4 | CQL spec 3.2.0 | Native protocol v3]
Use HELP for help.
aploetz#cqlsh>

cassandra: Exception connecting to localhost/9160. Reason: Connection refused

I am unable to connect to to the cassandra. By this I mean that when I try cassandra-CLI, or pycassaShell I get the following error:
Exception connecting to localhost/9160. Reason: Connection refused.
I have tried using a few non-defaul ports but to no joy.
I am running cassandra version 1.0.7
I have tried bounding the service, using restart, stop, start, and force-restart.
Run jps command under root user and kill CassandraDaemon if you will see it. After this you will start Cassandra again.
My problem was cassandra was not even starting. Solution was to start Cassandra!
I had the same issue in cassandra, After rename var/lib/cassandra/data to var/lib/cassandra/data1 then cassandra is working fine, If cassandra alloted maximum memory is full then it will throw connection refuse exception

Resources