简体   繁体   English

从远程计算机连接到Cassandra

[英]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. 我想向您寻求有关如何从远程计算机连接到我的Droplet上的Cassandra DB的帮助。 I did everything that is written in this article: Install Cassandra but when I try to connect from my C# code: 我做了本文中写的所有事情: 安装Cassandra,但是当我尝试从C#代码进行连接时:

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 Cassandra.dll中的'Cassandra.NoHostAvailableException'

Additional information: None of the hosts tried for query are available 附加信息:尝试查询的主机均不可用
(tried: 12.34.56.78:9168) (尝试:12.34.56.78:9168)

I also tried from other Cassandra GUI Clients like DBeaver but I'm getting the same error. 我还尝试了其他Cassandra GUI客户端(如DBeaver),但遇到了同样的错误。

My Droplet is Ubuntu 14.04. 我的Droplet是Ubuntu 14.04。 From localhost I have no problem with Cassandra my only problem is from remote. 从本地主机,我对Cassandra没问题,我唯一的问题是来自远程。

Here is result from 这是来自的结果

sudo netstat -plunt 须藤netstat -plunt

开放端口

Why could this be and how do I fix this? 为什么会这样,我该如何解决?

You have to use port 9042. 您必须使用端口9042。

listen_interface is used to setup inter-node communication. listen_interface用于设置节点间通信。

The IP address or hostname that Cassandra binds to for connecting to other Cassandra nodes. Cassandra绑定到的IP地址或主机名,用于连接到其他Cassandra节点。 Set this parameter or listen_interface, not both. 设置此参数或listen_interface,不能两者都设置。

You have to change rpc_address and then restart cassandra daemon 您必须更改rpc_address,然后重新启动cassandra守护程序

(Default: localhost) The listen address for client connections (Thrift RPC service and native transport). (默认值:localhost)客户端连接(Thrift RPC服务和本机传输)的侦听地址。 Valid values are: 有效值为:

make sure you can run cqlsh locally, ie from the host where Cassandra is running. 确保可以在本地运行cqlsh,即从运行Cassandra的主机运行。 If you can not, check if Cassandra is running (check logs) and listens on the interface you are connecting to. 如果不能,请检查Cassandra是否正在运行(检查日志)并在您要连接的接口上进行侦听。

if you can connect locally, check you settings for rpc_address and rpc_broadcast_address for Cassandra. 如果您可以本地连接,请检查Cassandra的rpc_address和rpc_broadcast_address的设置。 It should be set to other value than 'localhost' (which is set by default). 它应该设置为'localhost'以外的其他值(默认设置)。

9042 port is for CQL by default, I suggest you not to reset it. 默认情况下,9042端口用于CQL,建议您不要将其重置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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