2. CCM
A script/library to create, launch and remove an
Apache Cassandra cluster on localhost.
The goal of ccm and ccmlib is to make it easy to
create, manage and destroy a small Cassandra
cluster on a local box. It is meant for testing a
Cassandra cluster.
https://github.com/pcmanus/ccm
3. Useful for
Cassandra without installing
Testing failure scenarios
Testing Upgrades
Development with multiple nodes/versions
without the hardware
Version migrations
Integration testing
Python dtests
Java CCM Bridge
6. Create a cluster
clohfink-rmbp:~ clohfink$ ccm create -n 3 -v 1.2.19 cassandra1-2-19
Downloading {redacted} to {redacted}, (10.958MB)
6602752 [57.47%]
7. Create a cluster
clohfink-rmbp:~ clohfink$ ccm create -n 3 -v 1.2.19 cassandra1-2-19
Downloading {redacted} to {redacted}, (10.958MB)
11489812 [100.00%]
Extracting {redacted} as version 1.2.19 ...
Compiling Cassandra 1.2.19 ...
Current cluster is now: cassandra1-2-19
clohfink-rmbp:~ clohfink$
8. Create a cluster
clohfink-rmbp:~ clohfink$ ccm create -n 3 -v 1.2.19 cassandra1-2-19
Downloading {redacted} to {redacted}, (10.958MB)
11489812 [100.00%]
Extracting {redacted} as version 1.2.19 ...
Compiling Cassandra 1.2.19 ...
Current cluster is now: cassandra1-2-19
clohfink-rmbp:~ clohfink$ ccm status
Cluster: 'cassandra1-2-19'
--------------------------
node1: DOWN (Not initialized)
node3: DOWN (Not initialized)
node2: DOWN (Not initialized)
clohfink-rmbp:~ clohfink$
9. Start the cluster
Compiling Cassandra 1.2.19 ...
Current cluster is now: cassandra1-2-19
clohfink-rmbp:~ clohfink$ ccm status
Cluster: 'cassandra1-2-19'
--------------------------
node1: DOWN (Not initialized)
node3: DOWN (Not initialized)
node2: DOWN (Not initialized)
clohfink-rmbp:~ clohfink$ ccm start
clohfink-rmbp:~ clohfink$ ccm status
Cluster: 'cassandra1-2-19'
--------------------------
node1: UP
node3: UP
node2: UP
clohfink-rmbp:~ clohfink$
10. Replication Factor Example
clohfink-rmbp:~ clohfink$ ccm node1 cqlsh
Connected to cassandra1-2-19 at 127.0.0.1:9160.
[cqlsh 3.1.8 | Cassandra 1.2.19-SNAPSHOT ...]
Use HELP for help.
cqlsh>
11. Replication Factor Example
clohfink-rmbp:~ clohfink$ ccm node1 cqlsh
Connected to cassandra1-2-19 at 127.0.0.1:9160.
[cqlsh 3.1.8 | Cassandra 1.2.19-SNAPSHOT ...]
Use HELP for help.
cqlsh> CREATE KEYSPACE mspdemo WITH replication = {'class': 'SimpleStrategy',
'replication_factor' : 2};
12. Replication Factor Example
clohfink-rmbp:~ clohfink$ ccm node1 cqlsh
Connected to cassandra1-2-19 at 127.0.0.1:9160.
[cqlsh 3.1.8 | Cassandra 1.2.19-SNAPSHOT ...]
Use HELP for help.
cqlsh> CREATE KEYSPACE mspdemo WITH replication = {'class': 'SimpleStrategy',
'replication_factor' : 2};
cqlsh> use mspdemo;
cqlsh:mspdemo> CREATE TABLE users (name text, here boolean, PRIMARY KEY
(name));
13. Replication Factor Example
clohfink-rmbp:~ clohfink$ ccm node1 cqlsh
Connected to cassandra1-2-19 at 127.0.0.1:9160.
[cqlsh 3.1.8 | Cassandra 1.2.19-SNAPSHOT ...]
Use HELP for help.
cqlsh> CREATE KEYSPACE mspdemo WITH replication = {'class': 'SimpleStrategy',
'replication_factor' : 2};
cqlsh> use mspdemo;
cqlsh:mspdemo> CREATE TABLE users (name text, here boolean, PRIMARY KEY
(name));
cqlsh:mspdemo> INSERT INTO users (name, here) VALUES ('chris', true);
cqlsh:mspdemo> exit;
clohfink-rmbp:~ clohfink$ ccm flush
14. Replication Factor Example
clohfink-rmbp:~ clohfink$ ccm node1 cqlsh
Connected to cassandra1-2-19 at 127.0.0.1:9160.
[cqlsh 3.1.8 | Cassandra 1.2.19-SNAPSHOT ...]
Use HELP for help.
cqlsh> CREATE KEYSPACE mspdemo WITH replication = {'class': 'SimpleStrategy',
'replication_factor' : 2};
cqlsh> use mspdemo;
cqlsh:mspdemo> CREATE TABLE users (name text, here boolean, PRIMARY KEY
(name));
cqlsh:mspdemo> INSERT INTO users (name, here) VALUES ('chris', true);
cqlsh:mspdemo> exit;
clohfink-rmbp:~ clohfink$ ccm flush
clohfink-rmbp:~ clohfink$ ccm node1 json -k mspdemo -c users test;cat test
running
[’.../node1/data/mspdemo/users/mspdemo-users-jb-1-Data.db']
-- mspdemo-users-jb-1-Data.db -----
[
{"key": "6368726973","columns": [["","",14...000], ["here","true",14...000]]}
]