I have been playing with Cassandra couple days recently, I will summarize the prerequisites to run a cluster in a single PC. here it comes a tutorial to run/create a Cassandra cluster on windows.
before you try to run/create a cluster, please check the following requirements.
- Install a JDK/JRE
- 32/64 bit jvm
- Pickup three/four TCP Ports
- Cassandra storage
- default is 7000
- Thrift Listener
- for the remote client connection
- default is 9160
- JMX monitoring port for two nodes, one is 8080, another one is 9080
- JWDP debugging port (optional)
- Cassandra storage
- At least two IP address you can use. each member need one dedicated IP address.
- for windows , you may just pick up any ip between 127.0.0.1 and 127.0.0.255. for linux mac, check how to setup multi ip address on one network card for Linux /MAC MACBOOK
- we will use the following two ips
- 127.0.0.1
- 127.0.0.2
in this given example, I will setup one cluster named HelloCassendra with two storage nodes.
- Download the Cassandra bits from http://cassandra.apache.org/ , . I downloaded 0.6.3.
- unzip it to a folder like C:\apache-cassandra-0.6.3
- Copy two Conf folders, and rename that at conf1, conf2. We are going to use one codebase, but create two separate configurations.
- C:\apache-cassandra-0.6.3\conf1
- C:\apache-cassandra-0.6.3\conf2
- go to conf1 folder, change two cong files. Conf1 will listen on 127.0.0.1 and acts as the seed node. (Cassandra use the gossip-based clustering protocol. we will config this node as the seed node.)
- C:\apache-cassandra-0.6.3\conf1\log4j.properties
- # Edit the next line to point to your logs directory
log4j.appender.R.File=/var/log/cassandra/system.log - change the folder to =/var/log/cassandra/c1/system.log
- so this node will put the log to c:/var/log/cassandra/c1/system.log
- # Edit the next line to point to your logs directory
- C:\apache-cassandra-0.6.3\conf1\storage-conf.xml
- Change the clustername to HelloCassandra
- <ClusterName>
Test Cluster</ClusterName> - <ClusterName>HelloCassandra</ClusterName>
- <ClusterName>
- change the commitlogdirectory and DataFileDirectory
- <CommitLogDirectory>/var/lib/cassandra/C1/commitlog</CommitLogDirectory>
<DataFileDirectories>
<DataFileDirectory>/var/lib/cassandra/C1/data</DataFileDirectory>
</DataFileDirectories>
- <CommitLogDirectory>/var/lib/cassandra/C1/commitlog</CommitLogDirectory>
- replacethe localhost with 127.0.0.1 explicitly.
- <ListenAddress>127.0.0.1</ListenAddress>
- <ThriftAddress>127.0.0.1</ThriftAddress>
- Change the clustername to HelloCassandra
- C:\apache-cassandra-0.6.3\conf1\log4j.properties
- go to conf2 folder, change two cong files. Conf2 will listen on 127.0.0.2 and acts as the regular node. will talk to seed node 127.0.0.1 for membership information)
- C:\apache-cassandra-0.6.3\conf2\log4j.properties
- # Edit the next line to point to your logs directory
log4j.appender.R.File=/var/log/cassandra/system.log - change the folder to =/var/log/cassandra/c2/system.log
- so this node will put the log to c:/var/log/cassandra/c2/system.log
- # Edit the next line to point to your logs directory
- C:\apache-cassandra-0.6.3\conf2\storage-conf.xml
- Change the clustername to HelloCassandra
- <ClusterName>
Test Cluster</ClusterName> - <ClusterName>HelloCassandra</ClusterName>
- <ClusterName>
- change the commitlogdirectory and DataFileDirectory
- <CommitLogDirectory>/var/lib/cassandra/C2/commitlog</CommitLogDirectory>
<DataFileDirectories>
<DataFileDirectory>/var/lib/cassandra/C3/data</DataFileDirectory>
</DataFileDirectories>
- <CommitLogDirectory>/var/lib/cassandra/C2/commitlog</CommitLogDirectory>
- replace the localhost with 127.0.0.2 explicitly.
- <ListenAddress>127.0.0.2</ListenAddress>
- <ThriftAddress>127.0.0.2</ThriftAddress>
- enable the auto bootstrap mode
- <AutoBootstrap>false</AutoBootstrap>
- Change the clustername to HelloCassandra
- C:\apache-cassandra-0.6.3\conf2\log4j.properties
- Go to C:\apache-cassandra-0.6.3\bin, copy cassandra.bat as c1.bat and c2.bat. each bat will be the bootstrap of different instance.
- C:\apache-cassandra-0.6.3\bin\c1.bat
- C:\apache-cassandra-0.6.3\bin\c2.bat
- EDIT c1.bat, point to the conf1 folder, and change the default JMX PORT and Debug Port
- if NOT DEFINED CASSANDRA_CONF set CASSANDRA_CONF=%CASSANDRA_HOME%\conf
- if NOT DEFINED CASSANDRA_CONF set CASSANDRA_CONF=%CASSANDRA_HOME%\conf1
- disable the debugging by remove the follow line
-Xrunjdwp:transport=dt_socket,server=y,address=8888,suspend=n^
- for the C1 instance, keep the default jmx port 8080
- -Dcom.sun.management.jmxremote.port=8080^
- if NOT DEFINED CASSANDRA_CONF set CASSANDRA_CONF=%CASSANDRA_HOME%\conf
- EDIT c2.bat, point to the conf2 folder, and change the default JMX PORT and Debug Port
- if NOT DEFINED CASSANDRA_CONF set CASSANDRA_CONF=%CASSANDRA_HOME%\conf
- if NOT DEFINED CASSANDRA_CONF set CASSANDRA_CONF=%CASSANDRA_HOME%\conf2
- disable the debugging by remove the follow line
-Xrunjdwp:transport=dt_socket,server=y,address=8888,suspend=n^
- for the C2 instance, change the default jmx port 8080 to 9080
- -Dcom.sun.management.jmxremote.port=9080^
- if NOT DEFINED CASSANDRA_CONF set CASSANDRA_CONF=%CASSANDRA_HOME%\conf
- Click to start c1.bat and c2.bat
When you start C1.bat. you might get the following information. it will tell you that this node is confgured to be a seed node. its thrift port.
Starting Cassandra Server |
then you may run a tcpview to check how many ports instance 1 is listening.
here, 7000 is the storage port, 8080 is the jmx port, so you may use jconsole to connect and monitor this jvm. 9160 is the thrift port. How about 60625 and 60626?
now, there is only one node in the cluster.
C:\apache-cassandra-0.6.3>bin\nodetool --host 127.0.0.1 --port 8080 ring |
time to kick off the c2.bat, after that, you will notice that C2 joins the cluster. and wait for some time to do some housekeeping thing, might take 120 seconds.
Starting Cassandra Server |
run tcpview again, you will see two nodes are get established via the storage port.
run the ring query again.
C:\apache-cassandra-0.6.3>bin\nodetool --host 127.0.0.1 --port 8080 ring |
Also you can use the Jconsole to monitor the Nodes.
run jconsole which is located in the java sdk bin directly. connect to the node 1 by localhost:8080, node 2 by localhost:9080.
unfold those mbeans, you will be able to see a lot counters.
Now, everything is set. enjoy you exploring.
More open source solutions.
5 comments:
Hi there, I created a post about setting up a Cassandra cluster on a single PC via virtual machines, it's a differente approach (more resource-consuming...).
Check it out:
http://silicoholic.com/2010/09/14/cluster-cassandra-ubuntu-virtualbox/
Hi dude I'm using cassandra latest 0.8x version. I dunno what is seed provider in it. I'm not getting the result u are getting on creating clusters in a single machine
Hi,
I am looking for a Windows Server 2008 R2 multiple node cluster to install and run a commercial Windows program. Can I do this using Cassandra? I appreciate your help.
With kind regards,
Andy
To ACE,
No, Cassandra is basically a java application which provides the distributed storage service.
Thanks for sharing such beautiful information for Cassandra cluster related & you are deeply information suggest me.
Post a Comment