`
风中有雨
  • 浏览: 8868 次
  • 性别: Icon_minigender_2
  • 来自: 西安
最近访客 更多访客>>
社区版块
存档分类
最新评论

cassandra初探

 
阅读更多

1 下载安装文件:http://cassandra.apache.org 目前的最新版本是1.0.8

2 设置cassandra_home环境变量:

右击我的电脑->高级->环境变量->新建->变量名输入:Cassandra_home变量值就将Cassandra 解压在目录复制到里面

3 启动cassandra服务器:bin目录下 cassandra.bat文件。

4 客户端连接服务器: bin 目录下 cassandra-cli.bat文件。双击该文件:

Starting Cassandra Client
Welcome to Cassandra CLI version 1.0.8

Type 'help;' or '?' for help.
Type 'quit;' or 'exit;' to quit.

[default@unknown] connect localhost/9160; (连接服务器) ----PAT:注意分号结尾,否则会一直出现 。。。而且不会去主动连接服务器
Connected to: "Test Cluster" on localhost/9160
[default@unknown] show cluster name; (显示集群名称)
Test Cluster
[default@unknown] show keyspaces; (显示keyspace)
Keyspace: system:
  Replication Strategy: org.apache.cassandra.locator.LocalStrategy
  Durable Writes: true
    Options: [replication_factor:1]
  Column Families:
    ColumnFamily: HintsColumnFamily (Super)
    "hinted handoff data"
      Key Validation Class: org.apache.cassandra.db.marshal.BytesType
      Default column value validator: org.apache.cassandra.db.marshal.BytesType
      Columns sorted by: org.apache.cassandra.db.marshal.BytesType/org.apache.ca
ssandra.db.marshal.BytesType
      Row cache size / save period in seconds / keys to save : 0.0/0/all
      Row Cache Provider: org.apache.cassandra.cache.ConcurrentLinkedHashCachePr
ovider
      Key cache size / save period in seconds: 0.01/0
      GC grace seconds: 0
      Compaction min/max thresholds: 4/32
      Read repair chance: 0.0
      Replicate on write: true
      Bloom Filter FP chance: default
      Built indexes: []
      Compaction Strategy: org.apache.cassandra.db.compaction.SizeTieredCompacti
onStrategy
    ColumnFamily: IndexInfo
    "indexes that have been completed"
      Key Validation Class: org.apache.cassandra.db.marshal.BytesType
      Default column value validator: org.apache.cassandra.db.marshal.BytesType
      Columns sorted by: org.apache.cassandra.db.marshal.UTF8Type
      Row cache size / save period in seconds / keys to save : 0.0/0/all
      Row Cache Provider: org.apache.cassandra.cache.ConcurrentLinkedHashCachePr
ovider
      Key cache size / save period in seconds: 0.01/0
      GC grace seconds: 0
      Compaction min/max thresholds: 4/32
      Read repair chance: 0.0
      Replicate on write: true
      Bloom Filter FP chance: default
      Built indexes: []
      Compaction Strategy: org.apache.cassandra.db.compaction.SizeTieredCompacti
onStrategy
    ColumnFamily: LocationInfo
    "persistent metadata for the local node"
      Key Validation Class: org.apache.cassandra.db.marshal.BytesType
      Default column value validator: org.apache.cassandra.db.marshal.BytesType
      Columns sorted by: org.apache.cassandra.db.marshal.BytesType
      Row cache size / save period in seconds / keys to save : 0.0/0/all
      Row Cache Provider: org.apache.cassandra.cache.ConcurrentLinkedHashCachePr
ovider
      Key cache size / save period in seconds: 0.01/0
      GC grace seconds: 0
      Compaction min/max thresholds: 4/32
      Read repair chance: 0.0
      Replicate on write: true
      Bloom Filter FP chance: default
      Built indexes: []
      Compaction Strategy: org.apache.cassandra.db.compaction.SizeTieredCompacti
onStrategy
    ColumnFamily: Migrations
    "individual schema mutations"
      Key Validation Class: org.apache.cassandra.db.marshal.BytesType
      Default column value validator: org.apache.cassandra.db.marshal.BytesType
      Columns sorted by: org.apache.cassandra.db.marshal.TimeUUIDType
      Row cache size / save period in seconds / keys to save : 0.0/0/all
      Row Cache Provider: org.apache.cassandra.cache.ConcurrentLinkedHashCachePr
ovider
      Key cache size / save period in seconds: 0.01/0
      GC grace seconds: 0
      Compaction min/max thresholds: 4/32
      Read repair chance: 0.0
      Replicate on write: true
      Bloom Filter FP chance: default
      Built indexes: []
      Compaction Strategy: org.apache.cassandra.db.compaction.SizeTieredCompacti
onStrategy
    ColumnFamily: NodeIdInfo
    "nodeId and their metadata"
      Key Validation Class: org.apache.cassandra.db.marshal.BytesType
      Default column value validator: org.apache.cassandra.db.marshal.BytesType
      Columns sorted by: org.apache.cassandra.db.marshal.TimeUUIDType
      Row cache size / save period in seconds / keys to save : 0.0/0/all
      Row Cache Provider: org.apache.cassandra.cache.ConcurrentLinkedHashCachePr
ovider
      Key cache size / save period in seconds: 0.01/0
      GC grace seconds: 0
      Compaction min/max thresholds: 4/32
      Read repair chance: 0.0
      Replicate on write: true
      Bloom Filter FP chance: default
      Built indexes: []
      Compaction Strategy: org.apache.cassandra.db.compaction.SizeTieredCompacti
onStrategy
    ColumnFamily: Schema
    "current state of the schema"
      Key Validation Class: org.apache.cassandra.db.marshal.BytesType
      Default column value validator: org.apache.cassandra.db.marshal.BytesType
      Columns sorted by: org.apache.cassandra.db.marshal.UTF8Type
      Row cache size / save period in seconds / keys to save : 0.0/0/all
      Row Cache Provider: org.apache.cassandra.cache.ConcurrentLinkedHashCachePr
ovider
      Key cache size / save period in seconds: 0.01/0
      GC grace seconds: 0
      Compaction min/max thresholds: 4/32
      Read repair chance: 0.0
      Replicate on write: true
      Bloom Filter FP chance: default
      Built indexes: []
      Compaction Strategy: org.apache.cassandra.db.compaction.SizeTieredCompacti
onStrategy
    ColumnFamily: Versions
    "server version information"
      Key Validation Class: org.apache.cassandra.db.marshal.UTF8Type
      Default column value validator: org.apache.cassandra.db.marshal.BytesType
      Columns sorted by: org.apache.cassandra.db.marshal.UTF8Type
      Row cache size / save period in seconds / keys to save : 0.0/0/all
      Row Cache Provider: org.apache.cassandra.cache.ConcurrentLinkedHashCachePr
ovider
      Key cache size / save period in seconds: 0.01/0
      GC grace seconds: 0
      Compaction min/max thresholds: 4/32
      Read repair chance: 0.0
      Replicate on write: true
      Bloom Filter FP chance: default
      Built indexes: []
      Column Metadata:
        Column Name: version
          Validation Class: org.apache.cassandra.db.marshal.UTF8Type
      Compaction Strategy: org.apache.cassandra.db.compaction.SizeTieredCompacti
onStrategy
[default@unknown] show api version;(显示API版本号)
19.20.0

(创建keyspace)-----PAT: 该命令为0.8以上的版本命令,和之前的略有不同,在使用的时候需要注意。

[default@unknown] create keyspace MyKeyspace with placement_strategy='org.apache
.cassandra.locator.SimpleStrategy' and strategy_options={replication_factor:1};
9c0b4b30-669d-11e1-0000-242d50cf1f9f
Waiting for schema agreement...
... schemas agree across the cluster

(进入新创建的keyspace)
[default@unknown] use MyKeyspace;
Authenticated to keyspace: MyKeyspace

 

(创建列族)

[default@MyKeyspace] create column family user
...     with comparator= UTF8Type
...      and key_validation_class=UTF8Type
...      and column_metadata = [
...     {column_name:fname,validation_class:UTF8Type}
...     {column_name:email,validation_class:UTF8Type}
...     ];
73ad74d0-66a5-11e1-0000-242d50cf1f9f
Waiting for schema agreement...
... schemas agree across the cluster

 

(向列族中写入数据)
[default@MyKeyspace] set user['ehewitt']['fname']='Eben';
Value inserted.
Elapsed time: 78 msec(s).
[default@MyKeyspace] set user['ehewitt']['email']='me@example.com';
Value inserted.
Elapsed time: 16 msec(s).

(计算插入的列数)
[default@MyKeyspace] count user['ehewitt'];
2 columns

(读取数据)
[default@MyKeyspace] get user['ehewitt'];
=> (column=email, value=me@example.com, timestamp=1330939726609000)
=> (column=fname, value=Eben, timestamp=1330939699750000)
Returned 2 results.
Elapsed time: 47 msec(s).

(删除列)

[default@MyKeyspace] del user['ehewitt']['email'];
column removed.
[default@MyKeyspace] get user['ehewitt'];
=> (column=fname, value=Eben, timestamp=1330939699750000)
Returned 1 results.
Elapsed time: 0 msec(s).
[default@MyKeyspace]

分享到:
评论

相关推荐

    spring boot与cassandra集成,使用JPA方式。

    在本文中,我们将深入探讨如何将Spring Boot框架与Cassandra数据库集成,并利用Java Persistence API (JPA) 进行数据操作。Spring Boot以其简洁的配置和开箱即用的特性,已经成为Java开发中的首选框架之一。而...

    Learning_Apache_Cassandra

    在本文档中,标题“Learning_Apache_Cassandra”透露了内容的主题,即学习Apache Cassandra。Cassandra是一个开源的NoSQL分布式数据库管理系统,它以高可用性和分布式架构著称。该书详细介绍了Cassandra的基本概念、...

    DevCenter cassandra客户端

    DevCenter 是一个强大的工具,专为数据科学家、开发人员和管理员设计,用于与Apache Cassandra数据库进行交互。这个工具提供了一个直观的用户界面,使得管理、查询和开发Cassandra数据库变得简单易行。Cassandra是一...

    cassandra-3.11.3下载

    Cassandra是一款分布式、高度可扩展的NoSQL数据库系统,由Facebook于2008年开源,并在随后被Apache软件基金会接纳为顶级项目。Cassandra的设计灵感来源于Google的Bigtable,旨在处理大规模的数据存储需求,特别适合...

    Cassandra(apache-cassandra-3.11.11-bin.tar.gz)

    Cassandra(apache-cassandra-3.11.11-bin.tar.gz)是一套开源分布式NoSQL数据库系统。它最初由Facebook开发,用于储存收件箱等简单格式数据,集GoogleBigTable的数据模型与Amazon Dynamo的完全分布式的架构于一身...

    cassandra-operator,apache-cassandra的kubernetes算子.zip

    Cassandra-Operator是针对Apache Cassandra在Kubernetes集群中部署和管理的一个开源项目。它使得在Kubernetes环境中运行和扩展Cassandra数据库变得更加简单和自动化。在这个压缩包“cassandra-operator,apache-...

    Cassandra JDBC Driver

    Cassandra JDBC Driver是一款专为Apache Cassandra数据库设计的Java数据库连接(JDBC)驱动程序,它使得Java应用程序能够通过遵循标准JDBC接口的方式来访问和操作Cassandra数据。Cassandra是一款分布式NoSQL数据库...

    Cassandra_概要指南

    ### Cassandra概要指南 #### 一、Cassandra的诞生与背景 Cassandra作为一个高可靠性的大规模分布式存储系统,它的诞生背景源于互联网Web2.0应用的飞速发展以及云计算技术的普及。随着用户数据量的爆炸性增长和对...

    ycsb cassandra 压力测试工具

    **ycsb cassandra 压力测试工具** YCSB(Yahoo! Cloud Serving Benchmark)是 Yahoo 开源的一个云服务性能基准测试工具,它主要用于评估分布式数据库、键值存储和其他云服务的性能。Cassandra 是一个分布式NoSQL...

    apache-cassandra-3.11.13

    Apache Cassandra 是一个分布式数据库系统,特别设计用于处理大规模数据,具备高可用性、线性可扩展性和优秀的性能。在这个"apache-cassandra-3.11.13"版本中,我们探讨的是Cassandra项目的其中一个稳定版本,它包含...

    java NoSql Cassandra hector

    Java NoSQL Cassandra Hector详解 在当今大数据时代,非关系型数据库(NoSQL)因其灵活性、高可扩展性和高性能,越来越受到开发者的青睐。Cassandra,作为NoSQL数据库家族中的重要一员,尤其在大规模分布式存储系统...

    Cassandra在饿了么的应用

    标题中提到的"Cassandra在饿了么的应用"意味着文章将讨论Apache Cassandra这个大规模分布式NoSQL数据库系统在著名的中国本地生活服务平台饿了么中的实际应用案例。描述中重复多次提及"Cassandra",这表明主题将专注...

    Cassandra(apache-cassandra-4.0.1-bin.tar.gz)

    Cassandra(apache-cassandra-4.0.1-bin.tar.gz)是一套开源分布式NoSQL数据库系统。它最初由Facebook开发,用于储存收件箱等简单格式数据,集GoogleBigTable的数据模型与Amazon Dynamo的完全分布式的架构于一身...

    Cassandra

    The rising popularity of Apache Cassandra rests on its ability to handle very large data sets that include hundreds of terabytes -- and that's why this distributed database has been chosen by ...

    基于Cassandra的实时气象数据分布式存储系统.pdf

    "基于Cassandra的实时气象数据分布式存储系统" 本文主要介绍了基于Cassandra的实时气象数据分布式存储系统的设计和实现。该系统采用Cassandra作为分布式存储解决方案,旨在满足气象数据存储的高可用性和性能要求。 ...

    cassandra cli 命令 大全

    Cassandra CLI是Apache Cassandra数据库系统的一个命令行工具,它提供了与Cassandra集群交互的能力,包括连接到远程节点、创建或更新模式(schema)、设置和检索记录及列,以及查询节点和集群元数据。这个工具主要...

    Cassandra实战.pdf

    在深入探讨《Cassandra实战.pdf》这一资源时,我们聚焦于Apache Cassandra数据库系统的全面解析与实践应用,这是一份详尽的技术文档,旨在为数据库管理员、开发者以及对分布式数据库技术感兴趣的专业人士提供深入...

    Cassandra JDBC Driver 0.8.2

    Cassandra JDBC Driver 0.8.2 是一个专门为 Cassandra 数据库设计的 Java 数据库连接器(JDBC)驱动程序。这个驱动程序使得开发者能够通过使用标准的 JDBC API 来与 Cassandra 数据库进行交互,这对于那些熟悉 JDBC ...

Global site tag (gtag.js) - Google Analytics