Changes between Initial Version and Version 1 of java/Cassandra


Ignore:
Timestamp:
2010/10/12 23:20:17 (14 years ago)
Author:
yuna
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • java/Cassandra

    v1 v1  
     1== インストール == 
     2中身はJavaなので、ダウンロードして適当なディレクトリに解凍すればインストール完了。apache-cassandra-x.x.x/binディレクトリに移動して、 
     3{{{ 
     4> cassandra.bat 
     5}}} 
     6で起動。こんな感じのメッセージが表示される。 
     7{{{ 
     8Starting Cassandra Server 
     9Listening for transport dt_socket at address: 8888 
     10 INFO 13:17:34,504 Auto DiskAccessMode determined to be standard 
     11 INFO 13:17:34,648 Replaying \var\lib\cassandra\commitlog\CommitLog-127501974808 
     124.log 
     13 INFO 13:17:34,702 Creating new commitlog segment /var/lib/cassandra/commitlog\C 
     14ommitLog-1275020254702.log 
     15 INFO 13:17:34,735 Standard1 has reached its threshold; switching in a fresh Mem 
     16table at CommitLogContext(file='/var/lib/cassandra/commitlog\CommitLog-127502025 
     174702.log', position=121) 
     18 INFO 13:17:34,735 Enqueuing flush of Memtable(Standard1)@32110028 
     19 INFO 13:17:34,736 Writing Memtable(Standard1)@32110028 
     20 INFO 13:17:34,737 LocationInfo has reached its threshold; switching in a fresh 
     21Memtable at CommitLogContext(file='/var/lib/cassandra/commitlog\CommitLog-127502 
     220254702.log', position=121) 
     23 INFO 13:17:34,738 Enqueuing flush of Memtable(LocationInfo)@6292125 
     24 INFO 13:17:35,010 Completed flushing E:\var\lib\cassandra\data\Keyspace1\Standa 
     25rd1-1-Data.db 
     26 INFO 13:17:35,019 Writing Memtable(LocationInfo)@6292125 
     27 INFO 13:17:35,187 Completed flushing E:\var\lib\cassandra\data\system\LocationI 
     28nfo-1-Data.db 
     29 INFO 13:17:35,206 Log replay complete 
     30 INFO 13:17:35,254 Saved Token found: 127433031769127593372296726511185514191 
     31 INFO 13:17:35,254 Saved ClusterName found: Test Cluster 
     32 INFO 13:17:35,264 Starting up server gossip 
     33 INFO 13:17:35,297 Binding thrift service to localhost/127.0.0.1:9160 
     34 INFO 13:17:35,301 Cassandra starting up... 
     35}}} 
     36デフォルトのポートは9160の模様。 
     37== 接続 == 
     38サーバを起動したら、クライアントから接続してみよう。コマンドラインのクライアントcassandra-cliが用意されているので、それを使ってみる。 
     39{{{ 
     40cassandra-cli.bat -host localhost -port 9160 
     41-username todd -keyspace Keyspace1  -password blah 
     42Starting Cassandra Client 
     43Connected to: "Test Cluster" on localhost/9160 
     44Welcome to cassandra CLI. 
     45 
     46Type 'help' or '?' for help. Type 'quit' or 'exit' to quit. 
     47cassandra> 
     48}}} 
     49キースペース(RDBMSにおけるスキーマのようなもの)の一覧の確認。 
     50{{{ 
     51cassandra> show keyspaces 
     52Keyspace1 
     53system 
     54}}} 
     55Keyspace1とsystemが利用できることが確認できる。次に、キースペースの内容を確認する。 
     56{{{ 
     57cassandra> describe keyspace Keyspace1 
     58Keyspace1.Super1 
     59Column Family Type: Super 
     60Columns Sorted By: org.apache.cassandra.db.marshal.BytesType@128215d 
     61 
     62Column Family Type: Super 
     63Column Sorted By: org.apache.cassandra.db.marshal.BytesType 
     64flush period: null minutes 
     65------ 
     66Keyspace1.Standard2 
     67Column Family Type: Standard 
     68Columns Sorted By: org.apache.cassandra.db.marshal.UTF8Type@1a697a1 
     69 
     70Column Family Type: Standard 
     71Column Sorted By: org.apache.cassandra.db.marshal.UTF8Type 
     72flush period: null minutes 
     73------ 
     74Keyspace1.Super2 
     75Column Family Type: Super 
     76Columns Sorted By: org.apache.cassandra.db.marshal.UTF8Type@2cd728 
     77 
     78Column Family Type: Super 
     79Column Sorted By: org.apache.cassandra.db.marshal.UTF8Type 
     80flush period: null minutes 
     81------ 
     82Keyspace1.Standard1 
     83Column Family Type: Standard 
     84Columns Sorted By: org.apache.cassandra.db.marshal.BytesType@1e1a0ee 
     85 
     86Column Family Type: Standard 
     87Column Sorted By: org.apache.cassandra.db.marshal.BytesType 
     88flush period: null minutes 
     89------ 
     90Keyspace1.StandardByUUID1 
     91Column Family Type: Standard 
     92Columns Sorted By: org.apache.cassandra.db.marshal.TimeUUIDType@c954e 
     93 
     94Column Family Type: Standard 
     95Column Sorted By: org.apache.cassandra.db.marshal.TimeUUIDType 
     96flush period: null minutes 
     97------ 
     98cassandra> 
     99}}} 
     100Super1,Super2,Standard1,Standard2,StandardByUUID1のカラムファミリ(RDBMSにおけるテーブル)が存在する。 
     101Standard1に値の挿入と取得をやってみる。 
     102{{{ 
     103cassandra> set Keyspace1.Standard1['aaaa']['bbb']='ccc' 
     104Value inserted. 
     105cassandra> get Keyspace1.Standard1['aaaa'] 
     106=> (column=626262, value=ccc, timestamp=1275020194179000) 
     107Returned 1 results. 
     108}}} 
     109Standard2は、UTF8とみなしてソートしてくれるみたいなので、日本語を扱うならこっちの方がいいかも。 
     110{{{ 
     111Keyspace1.Standard2 
     112Column Family Type: Standard 
     113Columns Sorted By: org.apache.cassandra.db.marshal.UTF8Type@1a697a1 
     114}}}