我最近设置了一个有两个节点的 Cassandra 集群。复制因子设置为 2,如果两个节点都打开,它们似乎都运行良好。现在我怎样才能以这种方式使用赫克托,以便它在至少一个节点启动时继续工作?截至目前,我有类似以下的内容。
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}];
我确信我错过了一些非常微不足道的东西,任何帮助将不胜感激。谢谢