Cassandra: “Unable to complete the operation against any hosts” during session.execute()

♀尐吖头ヾ 提交于 2019-12-22 06:11:52

问题


Cassandra version: 1.2.2
Thrift API version: 19.35.0
CQL supported versions: 2.0.0,3.0.1 (default: 3.0.1)
cassandra-driver for python 3.4
running cassandra/bin/cassandra with sudo

Code sample:

from cassandra.cluster import Cluster
cluster = Cluster()
session = cluster.connect()    # 1
session.execute("use test")    # 2
cluster.shutdown()

Error message for # 2:
session.execute("use test")
File "cassandra/cluster.py", line 1581, in cassandra.cluster.Session.execute
File "cassandra/cluster.py", line 3145, in cassandra.cluster.ResponseFuture.result cassandra.cluster.NoHostAvailable: ('Unable to complete the operation against any hosts', {})

Confusion:
Since there's no error in # 1 in the code sample, the connection seems to be fine. But I don't quite understand why the query execution fails.


回答1:


Try to specify contact points for you cluster e.g:

from cassandra.cluster import Cluster
cluster = Cluster(['192.168.1.1', '192.168.1.2'])
session = cluster.connect()

More details on datastax documentation



来源:https://stackoverflow.com/questions/36191006/cassandra-unable-to-complete-the-operation-against-any-hosts-during-session-e

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!