Cassandra入门

关于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>


  
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'.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值