Skip to content
jmcteePublic

About

Example of using Cassandra Cluster Manager

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 

Repository files navigation

Cassandra Cluster Manager

Intro

  • Links to CCM Intro and setup

  • Creates virtual cluster on one box

  • Only works with localhost

  • Adding more loopbacks on Mac

  sudo ifconfig lo0 alias 127.0.0.2
  ifconfig
  • Good for data modeling experimentation

  • Also good for exploring C* features

  • Let’s explore Consistency Level and Hinted Handoff using CCM!

Example

[jmctee@Philae ~]$ ccm create -v 2.2.1 -n 5 mycluster
Current cluster is now: mycluster
[jmctee@Philae ~]$ ccm status
Cluster: 'mycluster'
--------------------
node1: DOWN (Not initialized)
node3: DOWN (Not initialized)
node2: DOWN (Not initialized)
node5: DOWN (Not initialized)
node4: DOWN (Not initialized)
[jmctee@Philae ~]$ ccm start
[node1 ERROR] objc[17230]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home//bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
[node3 ERROR] objc[17229]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home//bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
[node2 ERROR] objc[17231]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home//bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
[node5 ERROR] objc[17232]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home//bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
[node4 ERROR] objc[17233]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home//bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
[jmctee@Philae ~]$ ccm status
Cluster: 'mycluster'
--------------------
node1: UP
node3: UP
node2: UP
node5: UP
node4: UP
[jmctee@Philae ~]$ ccm node1 cqlsh
Connected to mycluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 2.2.1-SNAPSHOT | CQL spec 3.3.0 | Native protocol v4]
Use HELP for help.
cqlsh> describe keyspaces;

system_traces  system_auth  system  system_distributed

cqlsh> create keyspace mykeyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3};
cqlsh> describe keyspaces;

system_traces  system_auth  mykeyspace  system  system_distributed

cqlsh> use mykeyspace;
cqlsh:mykeyspace> consistency QUORUM;
Consistency level set to QUORUM.
cqlsh:mykeyspace> create TABLE mytable (id int PRIMARY KEY , name text, address text, phone text);
cqlsh:mykeyspace> select * from mytable;

 id | address | name | phone
----+---------+------+-------

(0 rows)
cqlsh:mykeyspace> insert into mytable (id, name, address, phone) values (1,'joe','co','303.489.0910');
cqlsh:mykeyspace> select * from mytable;

 id | address | name | phone
----+---------+------+--------------
  1 |      co |  joe | 303.489.0910

(1 rows)
cqlsh:mykeyspace> quit
[jmctee@Philae ~]$ ccm node1 nodetool getendpoints mykeyspace mytable 1
objc[17281]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home//bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.

127.0.0.3
127.0.0.4
127.0.0.5

[jmctee@Philae ~]$ ccm node1 nodetool getendpoints mykeyspace mytable 3
objc[17310]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home//bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.

127.0.0.1
127.0.0.2
127.0.0.3

[jmctee@Philae ~]$ ccm node4 stop
[jmctee@Philae ~]$ ccm status
Cluster: 'mycluster'
--------------------
node1: UP
node3: UP
node2: UP
node5: UP
node4: DOWN
[jmctee@Philae ~]$ ccm node1 cqlsh
Connected to mycluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 2.2.1-SNAPSHOT | CQL spec 3.3.0 | Native protocol v4]
Use HELP for help.
cqlsh> use mykeyspace;
consistency QUORUM;
cqlsh:mykeyspace> consistency QUORUM;
Consistency level set to QUORUM.
cqlsh:mykeyspace> select * from system.hints;

 target_id | hint_id | message_version | mutation
-----------+---------+-----------------+----------

(0 rows)
cqlsh:mykeyspace> update mytable set address='a-town, co' where id=1;
cqlsh:mykeyspace> select * from mytable;

 id | address    | name | phone
----+------------+------+--------------
  1 | a-town, co |  joe | 303.489.0910

(1 rows)
cqlsh:mykeyspace> select * from system.hints;

 target_id                            | hint_id                              | message_version | mutation
--------------------------------------+--------------------------------------+-----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 a769f408-b9ac-48cf-839f-ff23a5320d7a | be53b8b0-690c-11e5-832c-ef2411fa9ca9 |               9 | 0x0004000000010000000101977ffe60690c11e5832cef2411fa9ca97fffffff80000000000000000000000000000001000a00076164647265737300000005211f777b6ad70000000a612d746f776e2c20636f

(1 rows)
cqlsh:mykeyspace> quit
[jmctee@Philae ~]$ ccm node4 start
[jmctee@Philae ~]$ ccm status
Cluster: 'mycluster'
--------------------
node1: UP
node3: UP
node2: UP
node5: UP
node4: UP
[jmctee@Philae ~]$ ccm node1 cqlsh
Connected to mycluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 2.2.1-SNAPSHOT | CQL spec 3.3.0 | Native protocol v4]
Use HELP for help.
cqlsh> use mykeyspace;
consistency QUORUM;
cqlsh:mykeyspace> consistency QUORUM;
Consistency level set to QUORUM.
cqlsh:mykeyspace> select * from system.hints;

 target_id | hint_id | message_version | mutation
-----------+---------+-----------------+----------

(0 rows)
cqlsh:mykeyspace> quit
[jmctee@Philae ~]$ ccm node4 stop
[jmctee@Philae ~]$ ccm node5 stop
[jmctee@Philae ~]$ ccm status
Cluster: 'mycluster'
--------------------
node1: UP
node3: UP
node2: UP
node5: DOWN
node4: DOWN
[jmctee@Philae ~]$ ccm node1 cqlsh
Connected to mycluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 2.2.1-SNAPSHOT | CQL spec 3.3.0 | Native protocol v4]
Use HELP for help.
cqlsh> use mykeyspace;
cqlsh:mykeyspace> consistency QUORUM;
Consistency level set to QUORUM.
cqlsh:mykeyspace> update mytable set address='aurora, co' where id=1;
Traceback (most recent call last):
  File "/Users/jmctee/.ccm/repository/2.2.1/bin/cqlsh.py", line 1166, in perform_simple_statement
    rows = future.result(self.session.default_timeout)
  File "/Users/jmctee/.ccm/repository/2.2.1/bin/../lib/cassandra-driver-internal-only-2.6.0c2.post.zip/cassandra-driver-2.6.0c2.post/cassandra/cluster.py", line 3296, in result
    raise self._final_exception
Unavailable: code=1000 [Unavailable exception] message="Cannot achieve consistency level QUORUM" info={'required_replicas': 2, 'alive_replicas': 1, 'consistency': 'QUORUM'}

cqlsh:mykeyspace> select * from system.hints;

 target_id | hint_id | message_version | mutation
-----------+---------+-----------------+----------

(0 rows)
cqlsh:mykeyspace> quit
[jmctee@Philae ~]$ ccm node4 start
[jmctee@Philae ~]$ ccm node5 start
[jmctee@Philae ~]$ ccm status
Cluster: 'mycluster'
--------------------
node1: UP
node3: UP
node2: UP
node5: UP
node4: UP
[jmctee@Philae ~]$ ccm node1 cqlsh
Connected to mycluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 2.2.1-SNAPSHOT | CQL spec 3.3.0 | Native protocol v4]
Use HELP for help.
cqlsh> use mykeyspace;
cqlsh:mykeyspace> consistency QUORUM;
Consistency level set to QUORUM.
cqlsh:mykeyspace> update mytable set address='aurora, co' where id=1;
cqlsh:mykeyspace> select * from mytable;

 id | address    | name | phone
----+------------+------+--------------
  1 | aurora, co |  joe | 303.489.0910

(1 rows)
cqlsh:mykeyspace> select * from system.hints;

 target_id | hint_id | message_version | mutation
-----------+---------+-----------------+----------

(0 rows)
cqlsh:mykeyspace> quit
[jmctee@Philae ~]$ ccm stop
[jmctee@Philae ~]$ ccm remove

About

Example of using Cassandra Cluster Manager

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors