wiki:waue/2011/0707

Version 4 (modified by waue, 13 years ago) (diff)

--

Cassandra 安裝與測試
0.8.1

1. download

下載 bin 版如 apache-cassandra-0.8.1-bin.tar.gz

2. single setup

mkdir /opt/cassandra/run
  • 修改 bin/cassandra.in.sh
    JAVA_HOME=/usr/lib/jvm/java-6-sun
    CASSANDRA_HOME=/opt/cassandra
    
  • 修改 conf/cassandra-env.sh
    max_heap_size_in_mb=1024
    
  • 修改 conf/log4j-server.properties
    log4j.appender.R.File=/opt/cassandra/run/system.log
    
  • 修改 conf/cassandra.yaml
    data_file_directories: /opt/cassandra/run/data
    commitlog_directory: /opt/cassandra/run/commitlog
    saved_caches_directory: /opt/cassandra/run/saved_caches
    

3. run

bin/cassandra  
...(程序跑於背景)

bin/cassandra-cli
[default@unknown] (進入指令交談模式)

4. 操作

create keyspace Keyspace1;

use Keyspace1;

create column family Users with comparator=UTF8Type and default_validation_class=UTF8Type and key_validation_class=UTF8Type;

set Users[jsmith][first] = 'John';

set Users[jsmith][last] = 'Smith';

set Users[jsmith][age] = long(42);

get Users[jsmith];
  set Users[jsmith][first] = 'John';
        \      \        \          \
         \      \_ key   \          \_ value
          \               \_ column
           \_ column family

ps. 注意

  • Cassandra0.6.x 以後版本,預設相容於 Hadoop0.20.x
  • thrift
  • hadoop
  • json