无法完成对任何主机cassand的操作

2024-05-17 06:22:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经尝试过前面所述的here和{a2}的解决方案。我用的是数据税的卡桑德拉驱动程序。我的cassandra版本是2.2.8,我在其中创建了键空间CT_KEYSPACE和{}。我通过cqlsh提示符将值插入到CT_表中。下面是用于检索行的python代码

from cassandra.cluster import Cluster
cluster = Cluster()
session = cluster.connect('CT_KEYSPACE')
result = session.execute("select * from CT_TABLE")
print result.attribute, result.value

以下是DESCRIBE CT_keystpace的输出:

^{pr2}$

以下是我得到的错误:

Traceback (most recent call last):
  File "connection.py", line 4, in <module>
    result = session.execute("select * from CT_TABLE")
  File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 1998, in execute
    return self.execute_async(query, parameters, trace, custom_payload, timeout, execution_profile, paging_state).result()
  File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 3781, in result
    raise self._final_exception
cassandra.cluster.NoHostAvailable: ('Unable to complete the operation against any hosts', {})

非常感谢任何帮助。在


Tags: infrompyexecutesessionlinetableresult
2条回答

发生这种情况是因为您在connect中提供了错误的键空间名称。使用"ct_keyspace"代替"CT_KEYSPACE"。您可能还记得,在CQL中,未加引号的标识符不区分大小写(例如select语句)。但是,在参数传递的上下文中(如Cluster.connect(<keyspace>)),该文本不区分大小写。在

如果您启用日志记录,您将看到驱动程序一直未能在连接上设置该键空间。我创建了一个票证来改进这种情况下的错误处理:
https://datastax-oss.atlassian.net/browse/PYTHON-665

我也遇到了同样的错误,经过一些检查后,我了解到我的磁盘驱动器空间已满,而且我的服务器操作系统无法将任何磁盘空间分配给卡桑德拉。在

相关问题 更多 >