2015-01-07 53 views
3

我正在用cassandra驱动程序使用helenus在nodejs中开发应用程序。 版本的helenus0.6.10Helenus无法连接

这是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”

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

+0

我在连接helenus时遇到同样的问题。 – ashishkumar148

+0

什么版本的NodeJS和Cassandra使用什么版本? –

回答

3

首先检查你的卡桑德拉版本。如果你运行Cassandra 1.2或更高版本,你应该真的使用the Datastax NodeJS Driver。由于CQL的性能和功能大大超过Thrift,因此在1.2或更高版本中使用Thrift确实没有任何理由。此外,虽然Thrift服务器仍可供使用,但不会为此付出任何开发费用。

如果您确定需要使用Thrift,请首先确保存在密钥空间。 Helenus需要一个密钥空间来连接,所以如果密钥空间不存在,它将无法连接到任何节点。如果再密钥空间存在运行:

nodetool statusthrift

如果说不是running任何其他然后运行nodetool enablethrift,然后再试一次。

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