New Survey: Leveraging real-time data delivers higher revenue growth and increased developer productivity. Learn more.
Cassandra Cluster Manager, or CCM for short, is a powerful tool that lets you spin up any number of Apache Cassandra instances, create a cluster, and perform many cluster operations on localhost. It has been around for while but it wasn’t until the recent 2.0 release that Windows support was added, allowing the ability to natively run Cassandra instances on Windows. This post will go over the steps for getting CCM set up and running on Windows as well as some helpful tips on running Cassandra in the Windows environment via the command prompt.
CCM is a Python-based tool and it is now available via PyPi. CCM can be installed through pip:
Linux and Windows:
pip install ccm
On Windows, pip will install ccm into the C:\Python27\Scripts directory. Navigate to this directory and rename "ccm" to "ccm.py". This will allow you to run CCM via “ccm” rather than “python ccm”.
On Windows only (critical):
You must set the execution policy of Windows Powershell to allow CCM to launch instances of Cassandra. Open up a Powershell and type: “Set-ExecutionPolicy Unrestricted” and press Y in the resulting prompt. An unrestricted execution policy will also allow CCM to run on the regular command prompt (cmd) as well as Windows Powershell:
Running CCM on a Windows-based system is similar to running it on a Linux-based system (in this post, I will assume Ubuntu-based), and requires a few dependencies if not already installed. Although the dependencies between the two platforms are largely the same, installing the dependencies on Windows is slightly more complicated and must be configured properly for CCM to run.
First and foremost, a Java Development Kit (JDK) must be installed in order for CCM to build and run the requested instance(s) of Cassandra. The version of the JDK to install depends on the version of Cassandra you want to use and should match the architecture of operating system you are using (32-bit or 64-bit). JDK7 should be used for any recent recent Cassandra release.
sudo apt-get install python-software-properties sudo add-apt-repository ppa:webupd8team/java sudo apt-get update
sudo apt-get install oracle-java7-installer
After JDK installation, create a new system variable called JAVA_HOME and point it to the root of your JDK installation directory. In addition, add %JAVA_HOME%\bin to your system Path variable:
JAVA_HOME -> C:\Program Files\Java\<jdk_root>\ PATH: %JAVA_HOME%\bin;
As an aside, if you want to use the SSL functionality available in Cassandra, you will also need to install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files
sudo apt-get install oracle-java7-unlimited-jce-policy
Download the jar files from the above link, and place them into C:\Program Files\Java\<jdk_root>\jre\lib\security\
Next, install Apache Ant:
sudo apt-get install ant
Ant should be unzipped and moved to a permanent directory such as C:\apache-ant-1.9.4. Create a new system variable ANT_HOME and point it to this directory, and add %ANT_HOME%\bin to your Path variable:
ANT_HOME -> C:\<ant_root>\ PATH: %ANT_HOME%\bin;
Python 2.7 should be installed and should once again match the architecture of your operating system:
sudo apt-get install python
After Python installation, create a new system variable %PYTHON_HOME% and point it to the root directory of the Python installation. Add %PYTHON_HOME% and %PYTHON_HOME%\Scripts to your Path variable. In addition, add .PY to your PATHEXT to allow the direct execution of Python files:
PYTHON_HOME -> C:\<python_root>\ PATH: %PYTHON_HOME%; %PYTHON_HOME%\Scripts; PATHEXT: .PY;
On Windows only:
Finally, download and install the Python 2.7 version of psutil manually via the MS Windows Installer that matches the architecture of Windows. This is the only Windows-only dependency and must be installed via the .exe to work correctly.
Creating a Cluster
To create a CCM Cassandra cluster, you need to specify the cluster name, Cassandra version and the number of nodes in the cluster. For example:
ccm create test -v 2.1.2
ccm populate -n 3
Let’s have a look at each of these steps individually.
The “create” command downloads a source tarball of the specified Cassandra version and uses ant to compile it. On Windows, this is placed into C:\Users\<user>\.ccm\repository\ directory and in this case, it will download and compile Cassandra 2.1.2 into \.ccm\repository\2.1.2\. CCM will download and compile the source tarball the first time a specific version of Cassandra is used and thus will take some time. Thereafter, a previously compiled version will be used and should be quick.
The “populate” command creates X number of directories under \.ccm\<cluster_name>\, where each X is a node number such as \.ccm\<cluster_name>\node1. Inside of each of these node directories is a simple compiled copy of Cassandra from \.ccm\repository\2.1.2\, as well as a node.conf which holds the configuration information for that specific node such as interfaces, ports and initial token values.
The “start” command launches into the background an independent java process running Cassandra per each node, listening on 127.0.0.X, where X is the node number. If a Cassandra version prior to 2.1 is being launched, a number of new windows will pop up running Cassandra, rather than running in the background.
Similarly, “stop” can be used to stop all running Cassandra processes and “remove” will destroy the cluster and all configurations for the current cluster.
Command Line Interface
Mutliple CCM clusters can be configured concurrently. For example “ccm create test2 -v 2.1.2” will create a new CCM cluster called “test2” and switch to it. However, to start new this cluster, any previous clusters must be stopped first. “ccm list” can show a list of all configured CCM clusters (with the active cluster denoted via an asterisk *), and “ccm switch” can be used to switch between any CCM cluster.
Once a cluster is up and running, it can be accessed via cqlsh, nodetool or any DataStax driver. For example, “ccm node1 cqlsh” will launch and connect to cqlsh on node1. Similarly, “ccm node1 nodetool status” will launch and run many nodetool command on node1 of the cluster.
The following example demonstrates the use of CCM programmatically in a simple test case using the DataStax Ruby Driver:
CCM provides full functionality of a real Apache Cassandra cluster for development purposes, and now it is also supported on Windows. It should not be used in any production or benchmarking environments. Although Cassandra 1.2.X and 2.0.X are not officially supported on Windows, they do work on CCM. Cassandra 2.1.X currently has beta support and full Windows support is planned in Cassandra 3.0. We hope you give CCM a test drive on Windows and as always, pull requests are appreciated on GitHub.