简体   繁体   中英

Connecting to Cassandra from remote machine

I want to ask for your help on how can connect to my Cassandra DB on my droplet from remote machine. I did everything that is written in this article: Install Cassandra but when I try to connect from my C# code:

cluster = Cassandra.Cluster.Builder()
    .WithCredentials("abc", "abc")
    .AddContactPoints(new[] { "12.34.56.78" })
    .WithPort(9168)
    .Build();

var session = cluster.Connect();
var keyspace = "Test";
session.CreateKeyspaceIfNotExists(keyspace);
session.ChangeKeyspace(keyspace);

I'm getting an Exception:

'Cassandra.NoHostAvailableException' in Cassandra.dll

Additional information: None of the hosts tried for query are available
(tried: 12.34.56.78:9168)

I also tried from other Cassandra GUI Clients like DBeaver but I'm getting the same error.

My Droplet is Ubuntu 14.04. From localhost I have no problem with Cassandra my only problem is from remote.

Here is result from

sudo netstat -plunt

开放端口

Why could this be and how do I fix this?

You have to use port 9042.

listen_interface is used to setup inter-node communication.

The IP address or hostname that Cassandra binds to for connecting to other Cassandra nodes. Set this parameter or listen_interface, not both.

You have to change rpc_address and then restart cassandra daemon

(Default: localhost) The listen address for client connections (Thrift RPC service and native transport). Valid values are:

make sure you can run cqlsh locally, ie from the host where Cassandra is running. If you can not, check if Cassandra is running (check logs) and listens on the interface you are connecting to.

if you can connect locally, check you settings for rpc_address and rpc_broadcast_address for Cassandra. It should be set to other value than 'localhost' (which is set by default).

9042 port is for CQL by default, I suggest you not to reset it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM