聚會時間公告: 因應COSCUP 2011, Kalug 8月份休會一次

十月 1, 2012
» Cassandra install on Ubuntu 1204

Add to /etc/apt/sources.list

deb http://www.apache.org/dist/cassandra/debian 11x main
deb-src http://www.apache.org/dist/cassandra/debian 11x main

Install command

gpg --keyserver pgp.mit.edu --recv-keys 4BD736A82B5C1B00
gpg --export --armor 4BD736A82B5C1B00|sudo apt-key add -
sudo apt-get update
sudo apt-get install cassandra

Install pycassa:

sudo apt-get install gcc python-dev python-pip # for thrift.protocol.fastbinary
sudo pip install pycassa

Also CQL: http://code.google.com/a/apache-extras.org/p/cassandra-dbapi2/

四月 29, 2010
» 最近很熱門的資料庫 cassandra

雖然go目前還沒有cassandra的connection library,不過已經有相關討論了。
(不管寫什麼都要置入性行銷一下go)

http://cassandra.apache.org/

cassandra 是Apache Top level Project之一,facebook,Digg 跟 Twitter 都有採用它作為一部分的資料庫.
cassandra 是一個cluster database 就像 BigTable 一樣,但他們還是不同的。
從CAP理論(http://devblog.streamy.com/2009/08/24/cap-theorem/)的角度來看
一致性(Consistency): “Is the data I’m looking at now the same if I look at it somewhere else?”
系統可用性(Availability): “What happens if my database goes down?”
分散容錯(Partition tolerance): “What if my data is on different networks?”

BigTable偏向於CA, 而cassandra則是AP。

Cassandra的API應用也相當廣泛. php, perl, python, ruby 甚至連haskell都有支援.

目前我只試過兩套python的api, lazyboy跟pycassa

簡單執行

git clone http://giturl
sudo python setup.py install

就可以安裝這兩套library了.

以下是lazyboy的example code.

from lazyboy import *
from lazyboy.key import Key

import time;

# Define your cluster(s)
begin = 0;
btime = time.time();
connection.add_pool('Keyspace1', ['192.168.23.168:9160', '192.168.23.169:9160','192.168.23.172:9160'])

for i in xrange(begin, begin + 500000):
if i!=begin and (i % 10000) == 0:
print time.time() - btime;
btime = time.time();

rc = record.Record({'value': i, 'text': "ruslan text"})
rc.key = Key("Keyspace1", "Standard1", str(i));
rc.save(0);

print time.time() - btime;

pycassa也是很nice

import pycassa
client = pycassa.connect(['192.168.23.168:9160', '192.168.23.169:9160'])

cf = pycassa.ColumnFamily(client, 'Keyspace1', 'Standard1')
cf.insert('foo', {'column1': 'val1'})
cf.get('foo')
print(cf.get('foo')['column1'])

nodetool

kevin@Office:~$ nodetool -host 192.168.23.168 -port 8080 ring
Address Status Load Range Ring
103440706267102512524414743070503313038
192.168.23.169Up 143.96 MB 10179247206633247959723284233859042110 |<--|
192.168.23.172Up 143.97 MB 24715272519024223240814048623324812800 | |
192.168.23.168Up 144.02 MB 103440706267102512524414743070503313038 |-->|
kevin@Office:~$ nodetool -host 192.168.23.168 -port 8080 info
103440706267102512524414743070503313038
Load : 144.02 MB
Generation No : 1272273320
Uptime (seconds) : 72795
Heap Memory (MB) : 128.90 / 1016.13

個人還是比較喜歡劍魂中的遊戲人物 cassandra :D

support:

biggo.com.tw

A Django site.