| 1 | == インストール == |
| 2 | 中身はJavaなので、ダウンロードして適当なディレクトリに解凍すればインストール完了。apache-cassandra-x.x.x/binディレクトリに移動して、 |
| 3 | {{{ |
| 4 | > cassandra.bat |
| 5 | }}} |
| 6 | で起動。こんな感じのメッセージが表示される。 |
| 7 | {{{ |
| 8 | Starting Cassandra Server |
| 9 | Listening 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 |
| 12 | 4.log |
| 13 | INFO 13:17:34,702 Creating new commitlog segment /var/lib/cassandra/commitlog\C |
| 14 | ommitLog-1275020254702.log |
| 15 | INFO 13:17:34,735 Standard1 has reached its threshold; switching in a fresh Mem |
| 16 | table at CommitLogContext(file='/var/lib/cassandra/commitlog\CommitLog-127502025 |
| 17 | 4702.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 |
| 21 | Memtable at CommitLogContext(file='/var/lib/cassandra/commitlog\CommitLog-127502 |
| 22 | 0254702.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 |
| 25 | rd1-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 |
| 28 | nfo-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 | {{{ |
| 40 | cassandra-cli.bat -host localhost -port 9160 |
| 41 | -username todd -keyspace Keyspace1 -password blah |
| 42 | Starting Cassandra Client |
| 43 | Connected to: "Test Cluster" on localhost/9160 |
| 44 | Welcome to cassandra CLI. |
| 45 | |
| 46 | Type 'help' or '?' for help. Type 'quit' or 'exit' to quit. |
| 47 | cassandra> |
| 48 | }}} |
| 49 | キースペース(RDBMSにおけるスキーマのようなもの)の一覧の確認。 |
| 50 | {{{ |
| 51 | cassandra> show keyspaces |
| 52 | Keyspace1 |
| 53 | system |
| 54 | }}} |
| 55 | Keyspace1とsystemが利用できることが確認できる。次に、キースペースの内容を確認する。 |
| 56 | {{{ |
| 57 | cassandra> describe keyspace Keyspace1 |
| 58 | Keyspace1.Super1 |
| 59 | Column Family Type: Super |
| 60 | Columns Sorted By: org.apache.cassandra.db.marshal.BytesType@128215d |
| 61 | |
| 62 | Column Family Type: Super |
| 63 | Column Sorted By: org.apache.cassandra.db.marshal.BytesType |
| 64 | flush period: null minutes |
| 65 | ------ |
| 66 | Keyspace1.Standard2 |
| 67 | Column Family Type: Standard |
| 68 | Columns Sorted By: org.apache.cassandra.db.marshal.UTF8Type@1a697a1 |
| 69 | |
| 70 | Column Family Type: Standard |
| 71 | Column Sorted By: org.apache.cassandra.db.marshal.UTF8Type |
| 72 | flush period: null minutes |
| 73 | ------ |
| 74 | Keyspace1.Super2 |
| 75 | Column Family Type: Super |
| 76 | Columns Sorted By: org.apache.cassandra.db.marshal.UTF8Type@2cd728 |
| 77 | |
| 78 | Column Family Type: Super |
| 79 | Column Sorted By: org.apache.cassandra.db.marshal.UTF8Type |
| 80 | flush period: null minutes |
| 81 | ------ |
| 82 | Keyspace1.Standard1 |
| 83 | Column Family Type: Standard |
| 84 | Columns Sorted By: org.apache.cassandra.db.marshal.BytesType@1e1a0ee |
| 85 | |
| 86 | Column Family Type: Standard |
| 87 | Column Sorted By: org.apache.cassandra.db.marshal.BytesType |
| 88 | flush period: null minutes |
| 89 | ------ |
| 90 | Keyspace1.StandardByUUID1 |
| 91 | Column Family Type: Standard |
| 92 | Columns Sorted By: org.apache.cassandra.db.marshal.TimeUUIDType@c954e |
| 93 | |
| 94 | Column Family Type: Standard |
| 95 | Column Sorted By: org.apache.cassandra.db.marshal.TimeUUIDType |
| 96 | flush period: null minutes |
| 97 | ------ |
| 98 | cassandra> |
| 99 | }}} |
| 100 | Super1,Super2,Standard1,Standard2,StandardByUUID1のカラムファミリ(RDBMSにおけるテーブル)が存在する。 |
| 101 | Standard1に値の挿入と取得をやってみる。 |
| 102 | {{{ |
| 103 | cassandra> set Keyspace1.Standard1['aaaa']['bbb']='ccc' |
| 104 | Value inserted. |
| 105 | cassandra> get Keyspace1.Standard1['aaaa'] |
| 106 | => (column=626262, value=ccc, timestamp=1275020194179000) |
| 107 | Returned 1 results. |
| 108 | }}} |
| 109 | Standard2は、UTF8とみなしてソートしてくれるみたいなので、日本語を扱うならこっちの方がいいかも。 |
| 110 | {{{ |
| 111 | Keyspace1.Standard2 |
| 112 | Column Family Type: Standard |
| 113 | Columns Sorted By: org.apache.cassandra.db.marshal.UTF8Type@1a697a1 |
| 114 | }}} |