【问题标题】:how to connect with cassandra installed of different server using node js如何使用节点 js 连接安装在不同服务器上的 cassandra
【发布时间】:2019-08-28 21:40:18
【问题描述】:

我正在使用节点 js 连接到 cassandra 数据库。目前的数据库正在同一台服务器上工作。但是现在我们有了新的 cassandra 服务器。现在我没有得到连接到 cassandra 所需的更改。 当前代码:

var cassandra = require('cassandra-driver'); var client = new cassandra.Client({ contactPoints: ['localhost'], keyspace: 'ipop' });

【问题讨论】:

    标签: node.js cassandra


    【解决方案1】:

    您应该使用新 cassandra 服务器的 ip 而不是 localhost。此外,如果您的 Cassandra 使用其他端口而不是默认的 9042 来监听客户端连接,您应该使用选项 protocolOptions.port

    【讨论】:

    • 我试过了,但它无法连接到该 IP。我不知道为什么会这样。我已经检查了可能的解决方案。我发现很多地方我们需要在 cassandra.yaml 文件中进行一些更改。 var PlainTextAuthProvider = cassandra.auth.PlainTextAuthProvider; var client = new cassandra.Client({ contactPoints:['myserver:9042'], authProvider: new PlainTextAuthProvider('cassandra', 'cassandra')};
    • 确保您的 cassandra 节点确实在接口上侦听,而不仅仅是在本地主机上
    • 我该怎么做。我需要在 cassandra.yaml 中进行更改吗?如果是,那么我应该做些什么改变。
    • 检查 cassandra.yaml 文件中的 listen_address 和 listen_interface。
    • 我已将 listen_address 设置为与我在 contactPoints 中传递的 ip 相同。但它仍然拒绝连接。
    猜你喜欢
    • 2016-02-06
    • 2013-11-10
    • 2017-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多