如何使用Gremlin配置Cassandra db进行远程连接?不工作

时间:2017-10-11 12:20:43

标签: node.js cassandra datastax-enterprise gremlin spark-cassandra-connector

我在Node Js中使用Cassandra DB,DSE图,gremlin查询。我能够获得价值并访问localhost中的数据库。每当我尝试连接到远程服务器时(例如http://remoteservercassandra.in)都无法连接。如何连接远程服务器?

我的代码是

var dse = require('dse-driver');

var client = new dse.Client({
   contactPoints: ['127.0.0.1'],
    authProvider: new dse.auth.DsePlainTextAuthProvider('username','password'),
   protocolOptions: {
     port: 9042
   },
   graphOptions: {
    name: 'mygraphname'
   }
});

当我尝试收到此错误时

{
    "innerErrors": null,
    "info": "Represents an error when a query cannot be performed because no host is available or could be reached by the driver.",
    "message": "No host could be resolved"
}

如果我尝试连接远程服务器URL(例如http://remoteservercassandra.in),我收到此错误。

var dse = require('dse-driver');

var client = new dse.Client({
   contactPoints: ['remoteservercassandra.in'],
    authProvider: new dse.auth.DsePlainTextAuthProvider('username','password'),
   protocolOptions: {
     port: 9042
   },
   graphOptions: {
    name: 'mygraphname'
   }
});

我收到此错误。

{
    "innerErrors": {
        "12.234.78.134:9042": { // based on host name this IP address
            "code": "ECONNREFUSED",
            "errno": "ECONNREFUSED",
            "syscall": "connect",
            "address": "12.234.78.134",
            "port": 9042
        }
    },
    "info": "Represents an error when a query cannot be performed because no host is available or could be reached by the driver.",
    "message": "All host(s) tried for query failed. First host tried, 12.234.78.134:9042: Error: connect ECONNREFUSED 12.234.78.134:9042. See innerErrors."
}

如何解决此错误以及如何连接到远程服务器?

1 个答案:

答案 0 :(得分:1)

确认远程服务器正在运行并正在侦听正确的界面:

lsof -i:9042

乍一看,这看起来像是一个RPC_ADRESS问题。