How to change connection to Cassandra on Windows and make it remote?

677 views Asked by At

I have setted Cassandra on Windows and received several issues:

It is working but only localy. How can I change it?

Some explanation:

To run cassandra, I am running cassandra.bat file (From C:\Cassandra\bin). It shows some information but also show this:

Starting listening for CQL client on localhost/127.0.0.1:9042
Binding thrift service to localhost/127.0.0.1:9060
Listhening for thrift clients...

As I understand, this meant that casssandra is running localy.

In my application I have second code:

using (var cluster = Cluster.Builder().AddContactPoint("localhost").Build())
            {
                using (var session = cluster.Connect())
                {
                    session.CreateKeyspaceIfNotExists("autoparks");
                    session.ChangeKeyspace("autoparks");

                    session.GetTable<tvehicle>().CreateIfNotExists();
                    session.GetTable<tvehicletype>().CreateIfNotExists();
                    session.GetTable<tdriver>().CreateIfNotExists();
                    session.GetTable<tfirma>().CreateIfNotExists();
                }
            }

My issue is that now I need to run my application from another computer and somehow to get to the computer where cassandra are running.

I read that I need to open several ports in firewall: 9042 and 9160. But as I understand, I also need to change localhost to... to what? And how it supposed to look? Should I also create some VPN connection for it?

Excuse me for stupid question but this is really hard to me.

1

There are 1 answers

0
Rdesmond On

Edit the cassandra.yaml file in the C:\Cassandr\conf folder.

Specifically, the listen_address and the rpc_address to your public or VPN ip address instead of localhost. Additionally, set the start_rpc and start_native_transport values to "true". I think the last thing you need to change is the "seeds" property to reflect the seed node's respective ip addresses in your cluster.

Of course, as you mentioned, you need to open specific ports (http://docs.datastax.com/en/cassandra/2.0/cassandra/security/secureFireWall_r.html) to do various tasks such as remote monitoring, connecting to the cluster, and executing rpc commands or cql sessions.