Apache Cassandra remote access

I have installed Apache Cassandra on the remote Ubuntu server. How to allow remote access for an Apache Cassandra database? And how to make a connection?

Answers


Remote access to Cassandra is via its thrift port (although note that the JMX port can be used to perform some limited operations).

The thrift port is defined in cassandra.yaml by the rpc_port parameter, which defaults to 9160. Your cassandra node should be bound to the IP address of your server's network card - it shouldn't be 127.0.0.1 or localhost which is the loopback interface's IP, binding to this will prevent direct remote access. You configure the bound address with the rpc_address parameter in cassandra.yaml. Setting this to 0.0.0.0 says "listen on all network interfaces" which may or may not be suitable for you.

To make a connection you can use:

  • The cassandra-cli in the cassandra distribution's bin directory provides simple get / set / list operations and depends on Java
  • The cqlsh shell which provides CQL access to cassandra, this depends on Python
  • A higher level interface such as Apollo

For anyone finding this question now, the top answer is out of date.

Apache Cassandra's thrift interface is deprecated and will be removed in Cassandra 4.0. The default client port is now 9042.

As noted by Tyler Hobbs, you will need to ensure that the rpc_address parameter is not set to 127.0.0.1 or localhost (it is localhost by default). If you set it to 0.0.0.0 to listen on all interfaces, you will also need to set broadcast_rpc_address to either the node's public or private IP address (depending on how you plan to connect to Cassandra)

Cassandra-cli is also deprecated and Apollo is no longer active. Use cqlsh in lieu of cassandra-cli and the Java driver in lieu of Apollo.

I do not recommend making the JMX port accessible remotely unless you secure it properly by enabling SSL and strong authentication.

Hope this is helpful.


For anyone using Azure, the issue may be that you need to create a public ip address since the virtual ip points to the cloud service itself and not the virtual machine. You can find more info in this post


cassandra 3.11.3

I did the following to get mine working. Changes in cassandra.yaml :

start_rpc: true

rpc_address: 0.0.0.0

broadcast_rpc_address: ***.***.***.***

broadcast_rpc_address is the address of machine where cassandra is installed

 seed_provider:
  - class_name: ...
    - seeds: "127.0.0.1, ***.***.***.***"

In seeds i added/appended the ip address of machine where cassandra was running.

I accessed it from windows using tableplus. In tableplus, I wrote the ip address of the cassandra machine, in the port section I wrote 9042 and used the username and password, which i used for ssh connection.


Need Your Help

How to wait for exit of non-children processes

c linux process wait

For child processes, the wait() and waitpid() functions can be used to suspends execution of the current process until a child has exited. But this function can not be used for non-child process...

How to avoid tripping over UTF-8 BOM when reading files

ruby file unicode byte-order-mark

I'm consuming a data feed that has recently added a Unicode BOM header (U+FEFF), and my rake task is now messed up by it.