【发布时间】: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