3

我正在使用 cassandra 驱动程序在 nodejs 中使用 helenus 开发一个应用程序。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”

错误消息:“无法连接到任何节点”

当我完成故障排除后。我发现 Connection.prototype.use 方法中的 onDescribe 方法正在引发错误,即"NotFoundException"

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

4

1 回答 1

3

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

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

nodetool statusthrift

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

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

于 2015-01-07T15:05:19.237 回答