【问题标题】:How can we connect to remote Cassandra server with python driver我们如何使用 python 驱动程序连接到远程 Cassandra 服务器
【发布时间】:2020-11-19 12:34:01
【问题描述】:

我正在尝试使用 python 驱动程序连接到 Cassandra:

from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider

auth_provider = PlainTextAuthProvider(username='yyyy',password='zzzzz')
cluster = Cluster(['xx.xx.xx.xx'], control_connection_timeout=10,  port=9042,auth_provider=auth_provider)
session = cluster.connect()

错误:

NoHostAvailable: ('Unable to connect to any servers', {'xx.xx.xx.xx:9042': ConnectionRefusedError(111, "Tried connecting to [('xx.xx.xx.xx ', 9042)]. Last error: Connection refused")}) 

我还在yaml文件中设置了rpc地址:0.0.0.0

【问题讨论】:

    标签: python cassandra connection cassandra-python-driver


    【解决方案1】:

    端口9042 可能会绑定到您节点的私有 IP,因为您设置了:

    rpc_address: 0.0.0.0
    

    您需要将rpc_address 设置为节点的公共IP 或应用服务器可远程访问的IP。通常你应该有:

    listen_address: private_ip
    rpc_address: public_ip
    

    如果有帮助,我在这篇文章中提供了一些额外的细节——https://community.datastax.com/questions/6019/。干杯!

    【讨论】:

      猜你喜欢
      • 2015-08-16
      • 2017-08-07
      • 2022-01-23
      • 2016-02-18
      • 2012-07-24
      • 1970-01-01
      • 2016-12-22
      • 2016-07-26
      • 2020-01-06
      相关资源
      最近更新 更多