2016-06-11 73 views
1

我的羣集大小爲6個機器。我的數據量非常小,只有30.000。但我經常讀取,寫入,刪除和更新操作,儘管數據量很低,但操作可能會很昂貴。由於數據量非常低,我不明白爲什麼會出現此錯誤消息。任何答案真的很感激。無法達到一致性級別LOCAL_ONE info = {required_replicas 1 alive_replicas:0,一致性:LOCAL_ONE}

當我的卡桑德拉集羣正忙,我經常收到此錯誤信息:

WARNING code=1000 [Unavailable exception] message="Cannot achieve consistency level LOCAL_ONE" info={'required_replicas': 1, 'alive_replicas': 0, 'consistency': 'LOCAL_ONE'} 

這是卡桑德拉Python代碼我讀:

cluster = Cluster(['localhost']); session = cluster.connect('keyspaace') 
kafka = KafkaClient('localhost'); producer = SimpleProducer(kafka) 
channels = session.execute("select id from channels;") 
channel_ids = [channel.id for channel in channels] 
sleep_time = 10*60/(len(channel_ids)+0.0) 
for channel in channel_ids: 
url = 'http://toutiao.com/m%s/?%s' % (channel, urllib.urlencode({'_': datetime.utcnow().replace(tzinfo=pytz.UTC).isoformat()})) 
producer.send_messages('toutiao.incoming_urls', json.dumps({'appid': 'articles', 'crawlid': 'channel-%s' % (channel), 'spiderid': 'toutiao', 'url': url, 'useragent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36', 'attrs': {'id': channel, '_': datetime.utcnow().replace(tzinfo=pytz.UTC).isoformat()}})) 
print url 
#   log.info(url) 
time.sleep(sleep_time) 

我附加了一些額外的信息,如密鑰空間,nodetool狀態等等。如果你能幫我解決這個問題,那會很好。

(1)EDIT卡桑德拉簇nodetool狀態:

Datacenter: Analytics 
===================== 
Status=Up/Down 
|/ State=Normal/Leaving/Joining/Moving 
-- Address  Load  Tokens Owns (effective) Host ID        Rack 
UN 192.168.183.30 34.22 GB 1  76.7%    29ab1909-087c-447b-afaa-0e7db664f06d rack1 
UN 192.168.183.109 22.57 GB 1  54.1%    c4bde944-6b94-44dd-9d09-c3934c3568c6 rack1 
UN 192.168.183.106 27.81 GB 1  65.9%    7c95ca0c-9727-4e5b-9736-368493bc87ab rack1 
UN 192.168.183.121 24.61 GB 1  60.0%    85537680-70fc-494d-8e1f-48da35e9c33b rack1 
UN 192.168.183.20 20.76 GB 1  43.3%    4572c3f5-a946-453d-89bc-5815361fced9 rack1 
Datacenter: Solr 
================ 
Status=Up/Down 
|/ State=Normal/Leaving/Joining/Moving 
-- Address  Load  Tokens Owns (effective) Host ID        Rack 
UN 192.168.182.142 25.77 GB 1  100.0%   34d5797f-7b84-4e16-8f4d-80aa574408d2 rack1 

(2)信道模式

CREATE TABLE toutiao.channels (
    id text PRIMARY KEY, 
    avatar text, 
    category text, 
    created_at timestamp, 
    last_crawled timestamp, 
    last_modified timestamp, 
    name text, 
    scheduled_for timestamp, 
    source text, 
    status text, 
    url text 
) 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'; 

(3)EDIT密鑰空間

CREATE KEYSPACE mykeyspace WITH replication = {'class': 'NetworkTopologyStrategy', 'Analytics': '3', 'Solr': '1'} AND durable_writes = true; 
+1

你正在使用哪一個Snitch? –

+0

我使用endpoint_snitch:com.datastax.bdp.snitch.DseSimpleSnitch。任何想法發生了什麼?我真的不明白。謝謝 – peter

+0

@PhilippBlum我在mykeyspace以及我編輯的nodetool狀態中出錯。如果你能再看一次謝謝,會很棒。 – peter

回答

2

你必須一個錯誤的複製con成形。您的數據中心分析中複製因子爲6,但該數據中心不存在。將其更改爲Ana並添加您的solr羣集。或者你可以在你的snitch配置中改變它。並且不要使用6的複製因子。請改用3或4。您的Ana集羣中只有5個節點。太高的複製因素可能會極大地降低羣集速度。一般來說,如果某些內容與您的snitch或複製配置不一致,則會出現此錯誤。