forked from riptano/ccm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
143 lines (106 loc) · 4.68 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
CCM (for Cassandra Cluster Manager ... or something)
====================================================
A script/library to create, launch and remove a Apache Cassandra cluster on
localhost.
The goal of ccm and ccmlib is to make is easy to create, manage and destroy a
small cluster on a local box. It is meant for testing of a Cassandra cluster.
Requirements
------------
- A working python installation (tested to work with python 2.7).
- pyYAML (http://pyyaml.org/ -- 'sudo easy_install pyYaml')
- ccm works on localhost only for now. So if you want to create more than one
node clusters the simplest way is to use multiple loopback aliases. On
modern linux distribution you will probably have nothing to do, but
on mac os x, you would have to create such aliases with
sudo ifconfig lo0 alias 127.0.0.2 up
sudo ifconfig lo0 alias 127.0.0.3 up
...
Note that the usage section assumes that at least 127.0.0.1, 127.0.0.2 and
127.0.0.3 are available.
Known issues
------------
Windows only:
- Node start pops up a window, stealing focus.
- cli and cqlsh started from ccm show incorrect prompts on command-prompt
- non nodetool-based command-line options fail (sstablesplit, scrub, etc)
Installation
------------
ccm uses python distutils so from the source directory:
sudo ./setup.py install
MacPorts has ccm available as a port:
sudo port -v sync && sudo port -v install ccm
Usage
-----
Let's say you want to fire up a 3 nodes Cassandra cluster.
* Short version *
ccm create test -v 0.8.6
ccm populate -n 3
ccm start
* Longer version *
ccm works from a Cassandra source tree (not the jars). There is two way to
tell ccm how to find the sources:
1. if you have downloaded *and* compiled Cassandra sources, you can ask ccm
to use that by initiating a new cluster with:
ccm create test --cassandra-dir=<path/to/cassandra-sources>
or, from that source tree directory, simply
ccm create test
2. you can ask ccm to use a released version of Cassandra. For instance to
use Cassandra 0.8.6, do
ccm create test -v 0.8.6
When doing so, ccm will download the source (from http://archive.apache.org/dist/cassandra),
compile them and set the new cluster to use those. This means in
particular that this command can take a few minutes the first time you
create a cluster for a given version. After the first time, ccm keeps the
sources compile in ~/.ccm/repository/, so the same command will be fast
the next times (note however that if you create cluster with a lot of
different versions, this will take you disk space).
Once the cluster is created, you can populate it (with 3 nodes) and start all
the nodes with:
ccm populate -n 3
ccm start
That will start 3 nodes on IP 127.0.0.[1, 2, 3] on port 9160 for thrift, port
7000 for the internal cluster communication and ports 7100, 7200 and 7300 for JMX.
You can check that the cluster is correctly set up with
ccm node1 ring
You can then boostrap a 4th node with
ccm add node4 -i 127.0.0.4 -j 7400 -b
(populate is just a shortcut for adding multiple nodes initially)
ccm then provides a number of conveniences, like flushing all of the nodes of
the cluster:
ccm flush
or only one node:
ccm node2 flush
You can also easily look at the log file of a given node with:
ccm node1 showlog
Finally, you can get rid of the whole cluster (which will stop the node and
remove all the data) with
ccm remove
The list of other provided command is available through
ccm
then each command is then documented through the -h (or --help) flag. For
instance 'ccm add -h' describe the options for 'ccm add'.
Where are things stored
-----------------------
By default, ccm stores all the node data and configuration files under ~/.ccm/cluster_name/.
This can be overridden using the --config-dir option with each command.
CCM Lib
-------
The ccm facilities are available programmatically through ccmlib. This could
be use to implement automated tests again Cassandra. An hopefully self
explanatory simple example of use of ccmlib could be:
import ccmlib
CLUSTER_PATH="."
cluster = ccmlib.Cluster(CLUSTER_PATH, 'test', cassandra_version='0.8.6')
cluster.populate(3).start()
[node1, node2, node3] = cluster.nodelist()
# do some test on the cluster/nodes. To connect to a node through thrift,
# the host and port to a node is available through
# node.network_interfaces['thrift']
cluster.flush()
node2.compact()
# do some other test
# after the test, you can leave the cluster running, you can stop all nodes
# using cluster.stop() but keep the data around (in CLUSTER_PATH/test), or
# you can remove everything with cluster.remove()
--
Sylvain Lebresne <[email protected]>