gpt4 book ai didi

python - 我无法使用 DataStax Python 驱动程序连接到 Cassandra

转载 作者:行者123 更新时间:2023-11-28 18:34:33 28 4
gpt4 key购买 nike

我在使用 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()

该服务似乎在正确的端口上监听:

网络统计-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 的交互式控制台。

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

谢谢

最佳答案

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

关于python - 我无法使用 DataStax Python 驱动程序连接到 Cassandra,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33743143/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com