问题
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