问题
I have 02 nodes, one runs on 127.0.0.1 and another runs on 127.0.0.2
Will data that I add to my cluster will appear both on two nodes? As current, when I stop node 1, there is no similar data in the second node, it also throws some exceptions when I use list command:
Using default limit of 100
Using default column limit of 100
null
UnavailableException()
at org.apache.cassandra.thrift.Cassandra$get_range_slices_result.read(Cassandra.java:12346)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
at org.apache.cassandra.thrift.Cassandra$Client.recv_get_range_slices(Cassandra.java:692)
at org.apache.cassandra.thrift.Cassandra$Client.get_range_slices(Cassandra.java:676)
at org.apache.cassandra.cli.CliClient.executeList(CliClient.java:1425)
at org.apache.cassandra.cli.CliClient.executeCLIStatement(CliClient.java:273)
at org.apache.cassandra.cli.CliMain.processStatementInteractive(CliMain.java:219)
at org.apache.cassandra.cli.CliMain.main(CliMain.java:346)
One more thing is I use kundera to connect to cassandra db in my java application (Built on Play FW 2.0.4), my persistence file is as below:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="cassandra_pu">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<properties>
<property name="kundera.nodes" value="localhost"/>
<property name="kundera.port" value="9160"/>
<property name="kundera.keyspace" value="LSYCS"/>
<property name="kundera.dialect" value="cassandra"/>
<property name="kundera.client.lookup.class" value="com.impetus.client.cassandra.pelops.PelopsClientFactory" />
<property name="kundera.cache.provider.class" value="com.impetus.kundera.cache.ehcache.EhCacheProvider"/>
<property name="kundera.cache.config.resource" value="/ehcache-test.xml"/>
</properties>
</persistence-unit>
</persistence>
I assumed that when node 1 is down, the application will still able to connect to second node, but it wasnot able to do that. Is something really really wrong here ? What I expects is when 127.0.0.1 is offline, 127.0.0.2 will able to handle the jobs, or do they need a top application to manage them?
P/S: I setup on my computer thus both 127.0.0.1 and 127.0.0.2 point to localhost
回答1:
Did you change replication_factor (default is 1) for cassandra connections. Have a look at:
https://github.com/impetus-opensource/Kundera/wiki/Cassandra-Specific-Features
For configuring cassandra settings within kundera.
-Vivek
回答2:
You should read about Cassandra replication here: http://www.datastax.com/docs/1.1/cluster_architecture/replication
来源:https://stackoverflow.com/questions/13114190/sync-02-nodes-in-cassandra