Cassandra

Install Cassandra

$ wget http://www.carfab.com/apachesoftware/cassandra/2.2.3/apache-cassandra-2.2.3-bin.tar.gz

$ tar -xzvf apache-cassandra-2.2.3-bin.tar.gz

$ cd apache-cassandra-2.2.3

Configure Cassandra

$ sudo mkdir /opt/lib

$ sudo mkdir /opt/lib/cassandra/

$ sudo mkdir /opt/lib/cassandra/data

$ cd conf/

$ cp cassandra.yaml cassandra.yaml.orig

$vi cassandra.yaml

Old

# The name of the cluster. This is mainly used to prevent machines in

# one logical cluster from joining another.

cluster_name: 'Test Cluster'

New

cluster_name: 'Policy-Cluster'

Old\New - Leave this as it is

# If you already have a cluster with 1 token per node, and wish to migrate to

# multiple tokens per node, see http://wiki.apache.org/cassandra/Operations

num_tokens: 256

Old

# - AllowAllAuthenticator performs no checks - set it to disable authentication.

# - PasswordAuthenticator relies on username/password pairs to authenticate

# users. It keeps usernames and hashed passwords in system_auth.credentials table.

# Please increase system_auth keyspace replication factor if you use this authenticator.

# If using PasswordAuthenticator, CassandraRoleManager must also be used (see below)

authenticator: AllowAllAuthenticator

New

authenticator: PasswordAuthenticator

Old

# - AllowAllAuthorizer allows any action to any user - set it to disable authorization.

# - CassandraAuthorizer stores permissions in system_auth.permissions table. Please

# increase system_auth keyspace replication factor if you use this authorizer.

authorizer: AllowAllAuthorizer

New

authorizer: CassandraAuthorizer

Old\New - Use existing only

# Besides Murmur3Partitioner, partitioners included for backwards

# compatibility include RandomPartitioner, ByteOrderedPartitioner, and

# OrderPreservingPartitioner.

#

partitioner: org.apache.cassandra.dht.Murmur3Partitioner

Old

# Directories where Cassandra should store data on disk. Cassandra

# will spread data evenly across them, subject to the granularity of

# the configured compaction strategy.

# If not set, the default directory is $CASSANDRA_HOME/data/data.

# data_file_directories:

# - /var/lib/cassandra/data

New - Ensure no-space before data_file_directories

# If not set, the default directory is $CASSANDRA_HOME/data/data.

data_file_directories:

- /opt/lib/cassandra/data

Old

# commit log. when running on magnetic HDD, this should be a

# separate spindle than the data directories.

# If not set, the default directory is $CASSANDRA_HOME/data/commitlog.

# commitlog_directory: /var/lib/cassandra/commitlog

New - Ensure no-space before commlilog

# If not set, the default directory is $CASSANDRA_HOME/data/commitlog.

# commitlog_directory: /var/lib/cassandra/commitlog

commitlog_directory: /opt/lib/cassandra/commitlog

Old

saved caches

# If not set, the default directory is $CASSANDRA_HOME/data/saved_caches.

# saved_caches_directory: /var/lib/cassandra/saved_caches

New

# saved_caches_directory: /var/lib/cassandra/saved_caches

saved_caches_directory: /opt/lib/cassandra/saved_caches

Old\New - No change for now, need to change for cluster

# any class that implements the SeedProvider interface and has a

# constructor that takes a Map<String, String> of parameters will do.

seed_provider:

# Addresses of hosts that are deemed contact points.

# Cassandra nodes use this list of hosts to find each other and learn

# the topology of the ring. You must change this if you are running

# multiple nodes!

- class_name: org.apache.cassandra.locator.SimpleSeedProvider

parameters:

# seeds is actually a comma-delimited list of addresses.

# Ex: "<ip1>,<ip2>,<ip3>"

- seeds: "127.0.0.1"

Old

# ipv4. If there is only one address it will be selected regardless of ipv4/ipv6.

listen_address: localhost

New

# ipv4. If there is only one address it will be selected regardless of ipv4/ipv6.

listen_address: 127.0.0.1

Old

# If you choose to specify the interface by name and the interface has an ipv4 and an ipv6 address

# you can specify which should be chosen using rpc_interface_prefer_ipv6. If false the first ipv4

# address will be used. If true the first ipv6 address will be used. Defaults to false preferring

# ipv4. If there is only one address it will be selected regardless of ipv4/ipv6.

rpc_address: localhost

New

# ipv4. If there is only one address it will be selected regardless of ipv4/ipv6.

rpc_address: 127.0.0.1

Old\New - Same, In production use GossipingPropertyFileSnitch, single node use simplesnitch

# You can use a custom Snitch by setting this to the full class name

# of the snitch, which will be assumed to be on your classpath.

endpoint_snitch: SimpleSnitch

if use GossipingPropertyFileSnitch, chance as per your topology

# These properties are used with GossipingPropertyFileSnitch and will

# indicate the rack and dc for this node

dc=DC1

rack=RAC1

Start Cassandra

$ cd /home/cisco/bin/cassandra/apache-cassandra-2.2.3/bin/

$ ./cassandra &

Cassandra Tools

$ cd /home/cisco/bin/cassandra/apache-cassandra-2.2.3/bin/

$ ./nodetool help

$ ./cqlsh --help

$ ./nodetool version

ReleaseVersion: 2.2.3

$ ./nodetool status

Datacenter: datacenter1

=======================

Status=Up/Down

|/ State=Normal/Leaving/Joining/Moving

-- Address Load Tokens Owns Host ID Rack

UN 127.0.0.1 97.03 KB 256 ? 19e6bc13-282b-4a7f-84e6-b03d9c8c62b7 rack1

$ ./cqlsh -u cassandra -p cassandra

Connected to Policy-Cluster at 127.0.0.1:9042.

[cqlsh 5.0.1 | Cassandra 2.2.3 | CQL spec 3.3.1 | Native protocol v4]

Use HELP for help.

References