【问题标题】:Unable to complete the operation against any hosts cassandra无法完成对任何主机 cassandra 的操作
【发布时间】:2017-03-24 13:52:17
【问题描述】:

我已经尝试过前面提到的herehere 的解决方案。我正在通过 datastax 使用 cassandra-driver。我的 cassandra 版本是 2.2.8。我在其中创建了键空间 CT_KEYSPACECT_TABLE。我通过cqlsh 提示在 CT_TABLE 中插入了值。以下是检索行的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_KEYSPACE 的输出:

cqlsh> describe ct_keyspace

CREATE KEYSPACE ct_keyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}  AND durable_writes = true;

CREATE TABLE ct_keyspace.ct_table (
    attribute text PRIMARY KEY,
    value int
) WITH bloom_filter_fp_chance = 0.01
    AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'}
    AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99.0PERCENTILE';

以下是我得到的错误:

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', {})

非常感谢任何帮助。

【问题讨论】:

    标签: python cassandra datastax


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      我遇到了同样的错误,经过一些检查后,我了解到我的磁盘驱动器空间已满,并且我的服务器操作系统无法为 Cassandra 分配任何磁盘空间。

      【讨论】:

        猜你喜欢
        • 2021-07-27
        • 2016-07-11
        • 1970-01-01
        • 2018-01-16
        • 2021-01-28
        • 1970-01-01
        • 2019-05-27
        • 2014-04-15
        • 2013-10-31
        相关资源
        最近更新 更多