2015-01-07 109 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服務。