Cassandra

為什麼我得到 NoHostAvailable:?

  • March 6, 2017

如果我執行這個簡單的查詢:

SELECT * from myapp.latests WHERE organization_id = 1 and user_id = 1;

我得到錯誤:

NoHostAvailable:

執行nodetool status結果:

Datacenter: eu-central
======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens       Owns (effective)  Host ID                               Rack
UN  10.0.0.53  190.96 KiB  256          0.0%              80f8bf0a-c46d-41ce-bb2e-498def5b3792  1a
UN  10.0.20.5  189.35 KiB  256          0.0%              f25fe4bf-29b2-4403-8e3e-4e973a5f26ab  1b
UN  10.0.0.54  183.13 KiB  256          0.0%              c46ac05a-6cb2-48f1-a776-2c57c33e7719  1a

這是描述:

DESCRIBE myapp;

CREATE KEYSPACE myapp WITH replication = {'class': 'NetworkTopologyStrategy', 'eu-central-1': '2'}  AND durable_writes = true;

CREATE TABLE myapp.locations (
   organization_id int,
   user_id int,
   date text,
   unix_time bigint,
   lat double,
   long double,
   PRIMARY KEY ((organization_id, user_id, date), unix_time)
) WITH CLUSTERING ORDER BY (unix_time ASC)
   AND 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', 'max_threshold': '32', 'min_threshold': '4'}
   AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
   AND crc_check_chance = 1.0
   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 = '99PERCENTILE';

CREATE TABLE myapp.latests (
   organization_id int,
   user_id int,
   lat double,
   long double,
   unix_time bigint,
   PRIMARY KEY (organization_id, user_id)
) WITH CLUSTERING ORDER BY (user_id ASC)
   AND 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', 'max_threshold': '32', 'min_threshold': '4'}
   AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
   AND crc_check_chance = 1.0
   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 = '99PERCENTILE';

任何想法?

複製說 eu-central-1 但實際名稱是 eu-central。它找不到 eu-central-1,因為它不存在,所以它拋出 NoHostAvailable。更改複製策略以匹配 DC 名稱。

引用自:https://dba.stackexchange.com/questions/166334