I am trying to run 3 instances of this application in Create a cluster of 3 embedded instances locally. Everyone looks at different cassandra.yaml on the file system. Each file has:
>same cluster name
> blank initial_token< br>>Unique listening address (all mapped to 127.0.0.1 in my hosts file)
>Unique rpc, storage and ssl_storage port
>Same seed (listening address of the first server (no Port))
>The only-Dcom.sun.management.jmxremote.port value passed when the application starts
When I start the application, all applications are fine, and in the file There are separate storage spaces on the system. However, when I check each with nodetool, each appears to be in a cluster:
C:\Program Files\DataStax Community\apache-cassandra\bin>nodetool -h 127.0.0.1 -p 7197 ring
Starting NodeTool
Datacenter: datacenter1
==========< br />Replicas: 1
Address Rack Status State Load Owns Token
127.0.0.1 rack1 Up Normal 198,15 KB 100,00% 8219116491729144532
C:\Program Files\DataStax Community\apache-cassandra\bin>nodetool -h 127.0.0.2 -p 7198 ring
Starting NodeTool
Datacenter: datacenter1
==========< br />Replicas: 1
Address Rack Status State Load Owns Token
127.0.0.2 rack1 Up Normal 152,13 KB 100,00% -3632227916915216562
< p>Online blogs and documentation indicate that this should be sufficient. Is it possible to cluster embedded instances? If so, does anyone know how my configuration or understanding is incorrect/inadequate?
The code to start the embedded instance is as follows. I hope you can help, thank you.
public class EmbeddedCassandraDemo {
private static final String CONF_PATH_FORMAT = "D:\\embedded_cassandra\\Node%d\\";
private ExecutorService executor = Executors.newSingleThreadExecutor();
private CassandraDaemon cassandraDaemon;
private int nodeNumber;
public EmbeddedCassandraDemo(int nodeNumber) {
this.nodeNumber = nodeNumber;
}
public static void main(String [] args ) throws InterruptedException, ConnectionException {
new EmbeddedCassandraDemo(Integer.parseInt(args[0])).run();
}
private void run() throws InterruptedException, ConnectionException {
setProperties();
activateDeamon();
}
private void activateDeamon() {
executor.execute( new Runnable (){
@Override
public void run() {
cassandraDaemon = new CassandraDaemon();
cassandraDaemon.activate();
}});
}
private void setProperties() {
System. setProperty("cassandra.config", String.format("file:%scassandra.yaml", String.format(CONF_PATH_FORMAT, nodeNumber)));
System.setProperty("log4j.configuration", String.format( "file:%slog4j-server.properties", String.format(CONF_PATH_FORMAT, nodeNumber)));
System.setProperty("cassandra-foreground", "true");
}
}
You are using a virtual node NS? If not, I would like to know that this might be your problem. You should define each computer with a different initial token. For a 3-node cluster, these initial tokens should increase to each other 56,713,727,820,156,410,577,229,101,238,628,035,242.
Use DataStax Python script to calculate the initial token, these values should suit your needs:
node 0: 0
node 1: 56713727820156410577229101238628035242
node 2: 113427455640312821154458202477256070485
Also, are you using endpoint_snitch? If you use “PropertyFileSnitch”, please make sure your cassandra-topology.properties file contains the definition of each node (and DC and rack).
Try it and see if it helps.
p>
I wrote a small application to start an embedded instance of Cassandra 1.2.
I am trying to run 3 of this application The instance creates a cluster of 3 embedded instances locally. Everyone views different cassandra.yaml on the file system. Each file has:
>same cluster name
> blank initial_token
>Unique listening address (all mapped to 127.0.0.1 in my hosts file)
>Unique rpc, storage and ssl_storage port
>Same seed (listening address of the first server (No port))
>The only -Dcom.sun.management.jmxremote.port value passed when the application starts
When I start the application, all applications are fine, and There are separate storage spaces on the file system. However, when I check each with nodetool, each appears to be in a cluster:
C:\Program Files \DataStax Community\apache-cassandra\bin>nodetool -h 127.0.0.1 -p 7197 ring
Starting NodeTool
Datacenter: datacenter1
========= =
Replicas: 1
Address Rack Status State Load Owns Token
127.0.0.1 rack1 Up Normal 198,15 KB 100,00% 8219116491729144532
C:\Program Files\DataStax Community\apache-cassandra\bin>nodetool -h 127.0.0. 2 -p 7198 ring
Starting NodeTool
Datacenter: datacenter1
==========
Replicas: 1
Address Rack Status State Load Owns Token
127.0.0.2 rack1 Up Normal 152,13 KB 100,00% -3632227916915216562
Online blogs and documentation indicate that this should be sufficient. Can embedded instances be clustered? If so, does anyone know how my configuration or understanding is incorrect/inadequate?
The code to start the embedded instance is as follows. I hope you can help, thank you.
public class EmbeddedCassandraDemo {
private static final String CONF_PATH_FORMAT = "D:\\embedded_cassandra\\Node%d\\";
private ExecutorService executor = Executors.newSingleThreadExecutor();
private CassandraDaemon cassandraDaemon;
private int nodeNumber;
public EmbeddedCassandraDemo(int nodeNumber) {
this.nodeNumber = nodeNumber;
}
public static void main(String [] args ) throws InterruptedException, ConnectionException {
new EmbeddedCassandraDemo(Integer.parseInt(args[0])).run();
}
private void run() throws InterruptedException, ConnectionException {
setProperties();
activateDeamon();
}
private void activateDeamon() {
executor.execute( new Runnable (){
@Override
public void run() {
cassandraDaemon = new CassandraDaemon();
cassandraDaemon.activate();
}});
}
private void setProperties() {
System. setProperty("cassandra.config", String.format("file:%scassandra.yaml", String.format(CONF_PATH_FORMAT, nodeNumber)));
System.setProperty("log4j.configuration", String.format( "file:%slog4j-server.properties", String.format(CONF_PATH_FORMAT, nodeNumber)));
System.setProperty("cassandra-foreground", "true");
}
}
“blank initial_token”
Are you using virtual nodes? If not, I would like to know that this might be your problem. You should define each computer with a different initial token. For a 3-node cluster, these initial tokens should increase to each other 56,713,727,820,156,410,577,229,101,238,628,035,242.
Use DataStax Python script to calculate the initial token, these values should suit your needs:
node 0: 0
node 1: 56713727820156410577229101238628035242
node 2: 113427455640312821154458202477256070485
Also, are you using endpoint_snitch? If you use “PropertyFileSnitch”, please make sure your cassandra-topology.properties file contains the definition of each node (and DC and rack).
Try it and see if it helps.
p>