关于NoSql数据存储方式的优劣这里不再讨论,可以关注
http://www.iteye.com/topic/524977
这里简要介绍一下Cassandra入门,即安装和简单实用。
下载cassandra,http://cassandra.apache.org/download/
解压到 D:\apache-cassandra-0.5.1
创建环境变量 CASSANDRA_HOME = D:\apache-cassandra-0.5.1
设置conf/storage-conf.xml中的目录路径
<CommitLogDirectory>D:/cassandra/commitlog</CommitLogDirectory>
<DataFileDirectories>
<DataFileDirectory>D:/cassandra/data</DataFileDirectory>
</DataFileDirectories>
<CalloutLocation>D:/cassandra/callouts</CalloutLocation>
<StagingFileDirectory>D:/cassandra/staging</StagingFileDirectory>
运行 D:\apache-cassandra-0.5.1\bin>cassandra -f
启动后如下所示:
[img]http://dl.iteye.com/upload/attachment/233113/2fc097d2-9045-36b0-b8f6-f0e2c7cd5712.jpg[/img]
这里服务端便启动完毕,现在开启另一个cmd,在bin目录下运行cassandra-cli,即cassandra客户端。进入客户端后,键入connect localhost/9160 链接服务器。链接后如图:
[img]http://dl.iteye.com/upload/attachment/233116/4c38109a-b4bc-3a8e-a978-83a6979dc528.jpg[/img]
以下读写cassandra数据
cassandra> set Keyspace1.Standard1['jsmith']['first'] = 'John'
Value inserted.
cassandra> set Keyspace1.Standard1['jsmith']['last'] = 'Smith'
Value inserted.
cassandra> set Keyspace1.Standard1['jsmith']['age'] = '42'
Value inserted.
cassandra> get Keyspace1.Standard1['jsmith']
(column=age, value=42; timestamp=1249930062801)
(column=first, value=John; timestamp=1249930053103)
(column=last, value=Smith; timestamp=1249930058345)
Returned 3 rows.
cassandra>
Data stored in Cassandra is associated with a column family (Standard1),
which in turn is associated with a keyspace (Keyspace1). In the example
above, we set the value 'John' in the 'first' column for key 'jsmith'.
http://www.iteye.com/topic/524977
这里简要介绍一下Cassandra入门,即安装和简单实用。
下载cassandra,http://cassandra.apache.org/download/
解压到 D:\apache-cassandra-0.5.1
创建环境变量 CASSANDRA_HOME = D:\apache-cassandra-0.5.1
设置conf/storage-conf.xml中的目录路径
<CommitLogDirectory>D:/cassandra/commitlog</CommitLogDirectory>
<DataFileDirectories>
<DataFileDirectory>D:/cassandra/data</DataFileDirectory>
</DataFileDirectories>
<CalloutLocation>D:/cassandra/callouts</CalloutLocation>
<StagingFileDirectory>D:/cassandra/staging</StagingFileDirectory>
运行 D:\apache-cassandra-0.5.1\bin>cassandra -f
启动后如下所示:
[img]http://dl.iteye.com/upload/attachment/233113/2fc097d2-9045-36b0-b8f6-f0e2c7cd5712.jpg[/img]
这里服务端便启动完毕,现在开启另一个cmd,在bin目录下运行cassandra-cli,即cassandra客户端。进入客户端后,键入connect localhost/9160 链接服务器。链接后如图:
[img]http://dl.iteye.com/upload/attachment/233116/4c38109a-b4bc-3a8e-a978-83a6979dc528.jpg[/img]
以下读写cassandra数据
cassandra> set Keyspace1.Standard1['jsmith']['first'] = 'John'
Value inserted.
cassandra> set Keyspace1.Standard1['jsmith']['last'] = 'Smith'
Value inserted.
cassandra> set Keyspace1.Standard1['jsmith']['age'] = '42'
Value inserted.
cassandra> get Keyspace1.Standard1['jsmith']
(column=age, value=42; timestamp=1249930062801)
(column=first, value=John; timestamp=1249930053103)
(column=last, value=Smith; timestamp=1249930058345)
Returned 3 rows.
cassandra>
set Keyspace1.Standard1['jsmith']['first'] = 'John'
\ \ \ \ \
\ \ \_ key \ \_ value
\ \ \_ column
\_ keyspace \_ column family
Data stored in Cassandra is associated with a column family (Standard1),
which in turn is associated with a keyspace (Keyspace1). In the example
above, we set the value 'John' in the 'first' column for key 'jsmith'.