Skip to content

Instantly share code, notes, and snippets.

@andrewschaaf
Created February 12, 2012 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewschaaf/1811222 to your computer and use it in GitHub Desktop.
Save andrewschaaf/1811222 to your computer and use it in GitHub Desktop.
Cassandra notes
sudo apt-get install -y openjdk-6-jdk
wget http://apache.tradebit.com/pub//cassandra/1.0.7/apache-cassandra-1.0.7-bin.tar.gz
openssl sha1 apache-cassandra-1.0.7-bin.tar.gz
# SHA1(apache-cassandra-1.0.7-bin.tar.gz)= 8ae535821b29eead5b7dc7788a0e66ecf1ac267e
tar xzf apache-cassandra-1.0.7-bin.tar.gz
rm apache-cassandra-1.0.7-bin.tar.gz
mv apache-cassandra-1.0.7 cassandra
cassandra/conf/cassandra.yaml
RandomPartitioner -> ByteOrderedPartitioner
listen_address: ...IP on local network...
rpc_address: ...IP on local network...
sudo mkdir /var/lib/cassandra
sudo chown YOUR_USER /var/lib/cassandra
# try it in the foreground
bin/cassandra -f
# k, spawn it as a daemon
bin/cassandra
bin/cassandra-cli -host localhost -port 9160
CREATE KEYSPACE Events;
USE Events;
CREATE COLUMN FAMILY Events WITH comparator = BytesType AND compression_options = {sstable_compression:SnappyCompressor};
# sudo pip install pycassa
# Automatic failover and operation retries
# Connection pooling
# Multithreading support
# A batch interface
import pycassa
pool = pycassa.ConnectionPool('SomeKeyspace', server_list=["192.168.123.456"])
cf = pycassa.ColumnFamily(pool, 'SomeColfam')
cf.insert('row1', {'col1':'val1'})
cf.get('r1')
# http://pycassa.github.com/pycassa/api/pycassa/columnfamily.html#pycassa.columnfamily.ColumnFamily.get_range
for k, cols in cf.get_range(...):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment