[英]Cassandra load balancing with TokenAwarePolicy and shuffleReplicas
[英]Cassandra Hector Load balancing
我最近設置了具有兩個節點的Cassandra集群。 復制因子設置為2,並且如果兩個節點都打開,它們似乎都工作良好。 現在,我該如何使用hector使其保持工作狀態,直到至少一個節點啟動? 截至目前,我有類似以下內容。
CassandraHostConfigurator cassandraHostConfigurator = new CassandraHostConfigurator(
"localhost:9160,xx.xx.13.22:9160");
cassandraHostConfigurator.setMaxActive(20);
cassandraHostConfigurator.setMaxIdle(5);
cassandraHostConfigurator.setCassandraThriftSocketTimeout(3000);
cassandraHostConfigurator.setMaxWaitTimeWhenExhausted(4000);
Cluster cluster = HFactory.getOrCreateCluster("structspeech",
cassandraHostConfigurator);
Keyspace keyspace = HFactory.createKeyspace("structspeech", cluster);
....
假設主機xx.xx.13.22發生故障,那么我在控制台中收到以下消息,並且所有插入均失敗,直到該節點出現為止。
Downed xx.xx.13.22(xx.xx.13.22):9160 host still appears to be down: Unable to open transport to xx.xx.13.22(xx.xx.13.22):9160 , java.net.ConnectException: Connection refused: connect
這就是我的鍵空間的定義方式
update keyspace structspeech with placement_strategy =
'org.apache.cassandra.locator.SimpleStrategy'
and strategy_options =[{replication_factor:2}];
我確信我缺少一些瑣碎的東西,任何幫助將不勝感激。 謝謝
默認情況下,Hector使用Quorum的一致性級別,因此如果您的某個節點發生故障,則無法滿足該級別。
當RF = 2仲裁時,意味着您需要讀寫兩個節點,因此,如果其中一個發生故障,則無法執行。
這是一個不錯的在線工具,可演示NRW(N =復制因子,R =讀取一致性,W =寫入一致性) http://www.ecyrd.com/cassandracalculator/
要在寫入/讀取使用時更改一致性級別,例如AllOneConsistencyLevelPolicy HFactory.createKeyspace(String, Cluster, ConsistencyLevelPolicy)
插入時您使用什么一致性級別? 如果您使用QUORUM或ALL進行寫入,則需要兩個節點都可以復制系數為2進行寫入(2個節點的法定數量為2,這就是為什么典型的Cassandra群集將奇數用作復制因子的原因)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.