我最近设置了一个Cassandra集群和两个节点。复制因子设置为2,并且如果两个节点都打开,它们似乎都工作正常。 现在我怎样才能以这样的方式使用hector,使它至少能够在至少一个节点上运行?截至目前,我有如下的东西。Cassandra 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}];
我相信我失去了一些东西很琐碎,任何帮助将不胜感激。 谢谢
链接真的很有帮助 – Sap