shutyaev
shutyaev

Reputation: 287

can't connect to cassandra with jconsole

I have a cassandra installed on a remote server. The machine has 2 IPs - internal and external. In cassandra's jvm opts I have java.rmi.server.hostname set to the internal ip. nodetool connects just fine. However I'm not able to connect using jconsole via external ip - it hangs up for a long time and then (in -debug mode) prints a java.net.ConnectException with a timeout. This is not a firewall issue - there is no firewall on the server and also, I'm able to connect to the external ip and the jmx port using telnet. I also tried to connect to internal ip via ssh tunnel - but the result is still the same.

Can anyone help me with this?

Upvotes: 0

Views: 5015

Answers (4)

Alberto Massidda
Alberto Massidda

Reputation: 119

Key point is JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=x.x.x.x"

I am pasting here my full snippet to help others:

LOCAL_JMX=no

# Specifies the default port over which Cassandra will be available for
# JMX connections.
# For security reasons, you should not expose this port to the internet.  Firewall it if needed.
JMX_PORT="7199"

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"
  # if ssl is enabled the same port cannot be used for both jmx and rmi so either
  # pick another value for this property or comment out to use a random port (though see CASSANDRA-7087 for origins)
  JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=192.168.42.101"
  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT"
  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote"
  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false"

  # turn on JMX authentication. See below for further options
  JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false"

  # jmx ssl options
  #JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=true"
  #JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl.need.client.auth=true"
  #JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl.enabled.protocols=<enabled-protocols>"
  #JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl.enabled.cipher.suites=<enabled-cipher-suites>"
  #JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.keyStore=/path/to/keystore"
  #JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.keyStorePassword=<keystore-password>"
  #JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.trustStore=/path/to/truststore"
  #JVM_OPTS="$JVM_OPTS -Djavax.net.ssl.trustStorePassword=<truststore-password>"
fi

Upvotes: 0

Shrikant Salgar
Shrikant Salgar

Reputation: 151

By default Cassandra allows JMX accessible only from localhost. To enable remote JMX connection, you need to change
"LOCAL_JMX=yes" to "LOCAL_JMX=no"
this property from Cassandra-env.sh file.
Optionally if you want to enable authentication , you can set the properties related to authentication else keep them commented only.

Hope this will help you.

Upvotes: 2

rs_atl
rs_atl

Reputation: 8985

Most likely you have not configured remote JMX. This should help.

Upvotes: 1

Vlad Filimon
Vlad Filimon

Reputation: 544

conf/cassandra-env.sh

JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=public_name"

Upvotes: 2

Related Questions