Wednesday, December 26, 2012

Setting up Cassandra - ubuntu Amazon EC2


Download Cassandra
sudo apt-get install cassandra

The config is located in:
/etc/cassandra/conf/cassandra.yml

Create the following directories or modify these settings in conf/cassandra.yml if necessary
data_file_directories (/var/lib/cassandra/data)
commitlog_directory (/var/lib/cassandra/commitlog)
saved_caches_directory (/var/lib/cassandra/saved_caches)

Modify log directory in conf/log4j-server.properties
log4j.appender.R.File=/var/log/cassandra/system.log

By default, Cassandra uses between 1/4 and 1/2 of the available RAM.

If you are getting OutOfMemory exceptions or massive garbage collections, change the following in conf/cassandra-env.sh
#MAX_HEAP_SIZE="4G"
#HEAP_NEWSIZE="800M"

Rule of thumb - HEAP_NEWSIZE = 1/4 of MAX_HEAP_SIZE

Start Cassandra (-f means run in background):
bin/cassandra -f

Accessing the Cassandra CLI:
bin/cassandra-cli

Cassandra Commands:
assume                  Apply client side validation.
connect                 Connect to a Cassandra node.
consistencylevel        Sets consisteny level for the client to use.
count                   Count columns or super columns.
create column family    Add a column family to an existing keyspace.
create keyspace         Add a keyspace to the cluster.
del                     Delete a column, super column or row.
decr                    Decrements a counter column.
describe cluster        Describe the cluster configuration.
describe                Describe a keyspace and its column families or column family in current keyspace.
drop column family      Remove a column family and its data.
drop keyspace           Remove a keyspace and its data.
drop index              Remove an existing index from specific column.
get                     Get rows and columns.
incr                    Increments a counter column.
list                    List rows in a column family.
set                     Set columns.
show api version        Show the server API version.
show cluster name       Show the cluster name.
show keyspaces          Show all keyspaces and their column families.
show schema             Show a cli script to create keyspaces and column families.
truncate                Drop the data in a column family.
update column family    Update the settings for a column family.
update keyspace         Update the settings for a keyspace.
use                     Switch to a keyspace.

No comments:

Post a Comment