A node interface for Cassandra Cluster Manager (CCM), used for managing instances of Cassandra clusters and nodes from Node.
- CCM and all of its requirements
- Install with
brew install ccm
orpip install ccm
- Install with
import ccm from 'node-ccm';
const options = {
clusterName: 'myCluster',
nodes: 2,
version: '3.9',
};
const cluster = ccm.createCluster(options);
cluster.initialize()
.then(() => cluster.populateNodes())
.then(() => cluster.start())
.then(() => {
// Cluster ready here
/* ... */
// Stop the cluster and purge its data...
cluster.remove();
// or just stop the cluster, leaving its data intact
cluster.shutdown();
});
This will create a new instance of a cluster.
cluster.initialize
- creates a new cluster instance in CCMcluster.populateNodes
- create the number of nodes specified in options within the clustercluster.remove
- stop the cluster and purge its associated datacluster.shutdown
- shut down the cluster, leaving the associated data intactcluster.start
- start the created cluster instance and spin up any populated nodes
clusterConfig
(Object) - An object containing configuration values to update all nodes in the cluster with. (default:null
)clusterName
(String) - The name of the cluster (default:'node-ccm'
)configureLoopbackAliases
(Boolean) - If true, system loopback aliases will be configured automatically if needed. NOTEsudo
privileges are require for this action. (default:true
)jmxPort
(Number) - The port to use for JMX debugging for the first node in the cluster. You should only need to change this if port7100
if already taken on the host machine (like if Cassandra is already running externally). Subsequent nodes will increment this number accordingly. (default:7100
)nodes
(Integer) - The number of nodes to create for the cluster (default:1
)purge
(Boolean) - If true and the specified cluster already exists, remove the cluster and purge its data before initializing the new cluster (default:false
)startAddress
(String|Number) - The address to assign for your first node. Subsequent nodes will increment the last part of the address. Specifying a number instead of a string will define the last part of the address instead, resulting in an address like127.0.0.{startAddress}
. (default:'127.0.0.1'
)verbose
(Boolean) - Log all errors and messages from CCM (default:false
)version
(String) - The version of Cassandra to use for this cluster (default:'3.9'
)
To support multiple node clusters in OS X, you'll need to setup loopback aliases for as many nodes as you'll be using. This is done using the following commands:
sudo ifconfig lo0 alias 127.0.0.2 up
sudo ifconfig lo0 alias 127.0.0.3 up
...
See the CCM Requirements documentation for more information.