Helenus 无法连接

Helenus isn't able to connect

我正在使用 helenus 在 nodejs 中使用 cassandra 驱动程序开发应用程序。 helenus 的版本是 0.6.10

这是app.js

var helenus = require('helenus');

var pool = new helenus.ConnectionPool({
    hosts: ['localhost:9160'],
    keyspace: 'test_dev',
    user: '',
    password: ''
});
pool.connect(function(err, keyspace) {
    if (err) throw err;
    console.log('Listening on port 3000....');
});
pool.on('error', function(err) {
    if (err) throw err;
});

当我们调用 pool.connect 时,它会在回调中抛出以下错误。

错误名称:"HelenusNoAvailableNodesException"

错误信息:"Could Not Connect To Any Nodes"

当我解决完问题后。我发现 Connection.prototype.use 方法中的 onDescribe 方法抛出错误 "NotFoundException".

我做错了什么?任何帮助。

首先检查您的 Cassandra 版本。如果您正在 运行ning Cassandra 1.2 或更高版本,那么您真的应该使用 the Datastax NodeJS Driver。确实没有任何理由在 1.2 或更高版本中使用 Thrift,因为 CQL 的性能和特性大大超过了 Thrift。此外,虽然 Thrift 服务器仍然可用,但没有对其进行任何开发工作。

如果您完全确定需要使用 Thrift,那么首先要确保密钥空间存在。 Helenus 需要一个键空间才能连接,因此如果键空间不存在,它将无法连接到任何节点。如果键空间存在则 运行:

nodetool statusthrift

如果它说的不是 running,那么 运行 nodetool enablethrift 然后重试。

如果 thrift 是 运行ning 那么我会检查你的 cassandra.yaml 中配置的接口。 rpc_address 应该匹配您从客户端连接到的接口。如果您不确定接口,则只需将其设置为 0.0.0.0rpc_port 应该是 9160。更改 cassandra.yaml 中的任何设置后,您需要在集群中的每个节点上重新启动 cassandra 服务。