Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Connect to Cassandra Remotely Using DevCenter

I setup the DataStax Cassandra Sandbox on Azure using their image. I was able to run OpsCenter locally on the server without any issues. The install is Ubuntu which I am very new to.

Per this post Apache Cassandra remote access, I should be able to set my rpc_address to 0.0.0.0 to allow remote access to my database. However it says unable to connect when attempting a connection from DevCenter on my local Windows 8 PC.

Here are my settings: enter image description here

The contact host address is the virtual ip address shown in Azure for my VM. The port is the same one shown in the cassandra.yaml config file. I haven't configured any authorization and from what I have read I should just be able to connect using .NET or the management tools but neither works.

enter image description here

I also checked to see if the ports are open which they are as far as I can tell: enter image description here

Far I know it would be either 9160 or 9042.

like image 807
KingOfHypocrites Avatar asked Jan 09 '23 11:01

KingOfHypocrites


2 Answers

Thanks to everyone who helped me figured this out. Ultimately the issue was that when setting up an Azure VM, the Virtual IP that is assigned is for the cloud service itself and not the virtual machine. Therefore even though it appears that the proper ports are exposed you are not able to access them from an external computer.

More info about it here (but read my instructions below first since this is much easier to do in the Azure Management Console).

You will notice when setting up your virtual machine that Azure automatically creates an endpoint for your SSH connection such as 55xxx. You won't be able to connect to the configured port of 22 as shown on the box itself, but instead will have to use the endpoint port of 55xxx, etc.

This is important to note because the same goes for the Cassandra ports 8888 (OpsCenter), and 9042 (native transport).

So you can either:

  1. Create endpoints for these ports and use them when connecting remotely.
  2. Create a public IP address that points to the VM itself rather than the cloud service.

I couldn't get the endpoints to work at first, but later got them working. This lead me to setup a public ip address. I did it the hard way using the Azure Powershell. This was painful and a lot of research. But, after spending the time to do this, I realized it can now be done in the preview console. Simply go to the IP Addresses settings on your VM and enable the "Instance IP Address" option.

Then you should be able to connect remotely to OpsCenter using the ip address that is returned after the setup is complete via your browser: (The New IP Address):8888

...then in DevCenter using the new ip address and port 9042.

If you used endpoints instead of setting up a public static ip (which you will want to do for security reasons and enable user access control via ip filters), then you will want to use those newly created port numbers instead along with your virtual ip address.

Secondly... you will need to set rpc_address to 0.0.0.0 in the cassandra.yaml file.

like image 141
KingOfHypocrites Avatar answered Jan 11 '23 22:01

KingOfHypocrites


Far I know it would be either 9160 or 9042.

As you can see from your connection settings screenshot, DevCenter connects to Cassandra via the "Native Protocol." This refers to the Native Binary Protocol which (unless you altered native_transport_port in your cassandra.yaml) runs on port 9042. Thrift connects via port 9160, and I do not believe that you can configure DevCenter to connect with Thrift.

Next, check the values of listen_address and broadcast_address in your cassandra.yaml. At least one of these should be defined with your hostname or external IP address.

Set your "Native Protocol port" to 9042. Then try to connect to your external IP address.

Edit:

Check your system.log file and look for a line like this:

Starting listening for CQL clients on localhost/127.0.0.1:9042...

Whichever address you see there is the address that you need to connect to via DevCenter or a client. If that line shows 127.0.0.1, you have work to do.

Also, here are links to a similar question that I have helped out with in the past: How do I connect to local cassandra db

Did either of you have to assign a public IP to your vm?

Our (cloud based) Cassandra servers (in prod) have both internal and external IP addresses. I'll have to double-check tomorrow, but our Cassandra 2.0 configs had listen_address set to our external (public) IP and rpc_address either blank or set to the same.

Here are some docs that might help you get this configured:

  • DataStax Cassandra 2.0 documentation on configuring the cassandra.yaml.
  • Running Cassandra with Linux on Azure and Accessing it from Node.js by Mike Wasson
  • Showing Off Cassandra on Azure by Luke Tillman
  • Running Cassandra on Azure — step-by-step, gotcha-by-gotcha by kurtroy
like image 28
Aaron Avatar answered Jan 11 '23 23:01

Aaron