Cassandra 入门

这篇博客介绍了Cassandra的基本概念,包括Primary Key、Partition Key、Clustering Key以及集合类型和自定义类型。同时,提供了Windows上安装Cassandra 2.1.14的详细步骤,包括配置JDK、设置环境变量、修改配置文件以及启动和验证Cassandra服务。还提到了Cassandra常用端口和客户端工具的使用建议。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一. 基本概念

1. Primary Key, Partition Key, Clustering Key

以下面的Table为例子:

create table sample(

      k_part_one text,

      k_part_two int,

      k_clust_one text,

      k_clust_two int,

      k_clust_three uuid,

      data text,

      PRIMARY KEY((k_part_one,k_part_two),k_clust_one, k_clust_two, k_clust_three)     

  ) with CLUSTERING ORDER BY (k_clust_one DESC, k_clust_two ASC);


Primary Key=Partition Key + Clustering Key, Partition Key是(k_part_one,k_part_two),Clustering Key是k_clust_one, k_clust_two, k_clust_three

Partition Key决定了数据存储在集群的哪个节点,Primary Key决定数据在当前节点的排序。


2. 集合类型

1) set      如:set<text>,  有序集合 {'f@baggins.com', 'baggins@gmail.com'}

2) list      如:list<text>,  数组 ['rivendell', 'rohan' ]

3) map   如:map<timestamp, text>, 字典 { '2013-9-22 12:01' : 'birthday wishes to Bilbo', '2013-10-1 18:00': 'Check into Inn of Pracing Pony'}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值