Created
December 18, 2013 07:55
-
-
Save oldsharp/8018782 to your computer and use it in GitHub Desktop.
a simple sample-script to create cassandra cluster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import shutil | |
import ccmlib.cluster | |
CLEAR = True | |
NODE_NUM = 4 | |
CLUSTER_NAME = 'mushroom' | |
WORKSPACE = '/path/to/.ccm' | |
CASSANDR_DIR = '/path/to/apache-cassandra-1.2.2-src' | |
if __name__ == '__main__': | |
os.makedirs(WORKSPACE) | |
cluster = ccmlib.cluster.Cluster(WORKSPACE, CLUSTER_NAME, cassandra_dir=CASSANDR_DIR) | |
cluster.set_log_level('INFO') | |
try: | |
print 'populating' | |
cluster.populate(NODE_NUM) | |
cluster.start() | |
print 'populate OK' | |
except Exception as e: | |
raise | |
finally: | |
if CLEAR: | |
cluster.remove() | |
shutil.rmtree(WORKSPACE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment