|   | 1 |  | 
                  
                          |   | 2 | {{{ | 
                  
                          |   | 3 | #!html | 
                  
                          |   | 4 | <div style="text-align: center; color:#151B8D"><big style="font-weight: bold;"><big><big> | 
                  
                          |   | 5 | Cassandra 安裝與測試 | 
                  
                          |   | 6 | </big></big></big></div> <div style="text-align: center; color:#7E2217"><big style="font-weight: bold;"><big> | 
                  
                          |   | 7 |  0.8.1 | 
                  
                          |   | 8 | </big></big></div> | 
                  
                          |   | 9 | }}} | 
                  
                          |   | 10 | [[PageOutline]] | 
                  
                          |   | 11 |  | 
                  
                          |   | 12 |  | 
                  
                          |   | 13 |  == 1. download  == | 
                  
                          |   | 14 | 下載 bin 版如 apache-cassandra-0.8.1-bin.tar.gz | 
                  
                          |   | 15 |  | 
                  
                          |   | 16 |  == 2. single setup == | 
                  
                          |   | 17 |  | 
                  
                          |   | 18 |  * 修改 conf/cassandra_env.sh | 
                  
                          |   | 19 | {{{ | 
                  
                          |   | 20 | #!text | 
                  
                          |   | 21 | max_heap_size_in_mb=1024 | 
                  
                          |   | 22 | }}} | 
                  
                          |   | 23 |  | 
                  
                          |   | 24 |  * 修改 conf/log4j-server.properties | 
                  
                          |   | 25 | {{{ | 
                  
                          |   | 26 | #!text | 
                  
                          |   | 27 | log4j.appender.R.File=/opt/cassandra/run/system.log | 
                  
                          |   | 28 | }}} | 
                  
                          |   | 29 |  | 
                  
                          |   | 30 |  * 修改 conf/cassandra.yaml | 
                  
                          |   | 31 | {{{ | 
                  
                          |   | 32 | #!text | 
                  
                          |   | 33 | data_file_directories: /opt/cassandra/run/data | 
                  
                          |   | 34 | commitlog_directory: /opt/cassandra/run/commitlog | 
                  
                          |   | 35 | saved_caches_directory: /opt/cassandra/run/saved_caches | 
                  
                          |   | 36 | }}} | 
                  
                          |   | 37 |  | 
                  
                          |   | 38 |  == 3. run == | 
                  
                          |   | 39 |  | 
                  
                          |   | 40 | {{{ | 
                  
                          |   | 41 | bin/cassandra   | 
                  
                          |   | 42 | ...(程序跑於背景) | 
                  
                          |   | 43 |  | 
                  
                          |   | 44 | bin/cassandra-cli | 
                  
                          |   | 45 | [default@unknown] (進入指令交談模式) | 
                  
                          |   | 46 | }}} | 
                  
                          |   | 47 |  | 
                  
                          |   | 48 |  == 4. 操作 == | 
                  
                          |   | 49 | {{{ | 
                  
                          |   | 50 | create keyspace Keyspace1; | 
                  
                          |   | 51 |  | 
                  
                          |   | 52 | use Keyspace1; | 
                  
                          |   | 53 |  | 
                  
                          |   | 54 | create column family Users with comparator=UTF8Type and default_validation_class=UTF8Type and key_validation_class=UTF8Type; | 
                  
                          |   | 55 |  | 
                  
                          |   | 56 | set Users[jsmith][first] = 'John'; | 
                  
                          |   | 57 |  | 
                  
                          |   | 58 | set Users[jsmith][last] = 'Smith'; | 
                  
                          |   | 59 |  | 
                  
                          |   | 60 | set Users[jsmith][age] = long(42); | 
                  
                          |   | 61 |  | 
                  
                          |   | 62 | get Users[jsmith]; | 
                  
                          |   | 63 | }}} | 
                  
                          |   | 64 |  | 
                  
                          |   | 65 | {{{ | 
                  
                          |   | 66 | #!text | 
                  
                          |   | 67 |   set Users[jsmith][first] = 'John'; | 
                  
                          |   | 68 |         \      \        \          \ | 
                  
                          |   | 69 |          \      \_ key   \          \_ value | 
                  
                          |   | 70 |           \               \_ column | 
                  
                          |   | 71 |            \_ column family | 
                  
                          |   | 72 |  | 
                  
                          |   | 73 | }}} | 
                  
                          |   | 74 |  | 
                  
                          |   | 75 |  | 
                  
                          |   | 76 | == ps. 注意 == | 
                  
                          |   | 77 |  * 在Cassandra0.6.x中,默認實現的是與Hadoop0.20.x的整合 | 
                  
                          |   | 78 |  |