【问题标题】:I can't connect to Cassandra with DataStax Python driver我无法使用 DataStax Python 驱动程序连接到 Cassandra
【发布时间】:2016-02-18 00:13:57
【问题描述】:

我在使用适用于 Cassandra 的 DataStax Python 驱动程序本地连接到 Cassandra(在 EC2 节点上运行)时遇到问题:(类似于 this question

from cassandra.cluster import Cluster
cluster = Cluster(['127.0.0.1'], port=9042)
cluster.connect()

我明白了:

cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers', {'127.0.0.1': OperationTimedOut('errors=Timed out creating connection (5 seconds), last_host=None',)})

如果我运行也一样:

cluster = Cluster(['127.0.0.1'], port=9160)
cluster.connect()

服务似乎侦听了正确的端口:

netstat -nltp | grep 9042 (无法读取“-p”的信息:geteuid()=1000,但您应该是 root。) tcp6 0 0 127.0.0.1:9042 :::* 听 -

命令cqlsh 127.0.0.1 9042 也可以完美运行。

我在文件 cassandra.yaml 上有默认设置:

start_native_transport: true
native_transport_port: 9042
rpc_address: localhost
rpc_port: 9160

我还尝试使用我的 ec2 实例的 PRIVATE_IP 更改 rpc_address,但没有任何改变。

我不使用 PyCharm,我在我的实例上使用 python 的交互式控制台。

有人可以向我解释我做错了什么吗?

谢谢

【问题讨论】:

    标签: python amazon-ec2 cassandra datastax datastax-enterprise


    【解决方案1】:

    通过在 Amazon AWS 上使用 DataStax Community AMI 重新安装 cassandra 解决。可能是 Cassandra 和 Datastax python 驱动版本的问题。

    【讨论】:

      【解决方案2】:

      here 所述:

      我了解到gevent 模块会干扰cassandra-driver

      • cassandra 驱动程序 (3.10)
      • gevent (1.1.1)

      卸载 gevent 为我解决了问题

      pip uninstall gevent
      

      【讨论】:

        猜你喜欢
        • 2015-08-16
        • 2018-04-16
        • 2016-07-26
        • 2013-12-23
        • 2017-08-07
        • 1970-01-01
        • 1970-01-01
        • 2015-10-27
        • 2023-03-21
        相关资源
        最近更新 更多