`
sillycat
  • 浏览: 2542593 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Cassandra Database(1)Begin from the GettingStarted

 
阅读更多
Cassandra Database(1)Begin from the GettingStarted

1. Data Model Introduction
COLUMN  name value timestamp 
SUPERCOLUMN    name, value [ NAME1 : COLUMN1, NAME2 : COLUMN2, ...]
COLUMNFAMILY  RDBMS-Table
                Standard      key, Columns
                Super          key, SuperColumns
KEYSPACE

2. Installation
2.1 Download the zip file
>wget http://apache.mirrors.pair.com/cassandra/1.2.4/apache-cassandra-1.2.4-bin.tar.gz
Unzip this file and copy to working directory. Link to my default working directory.
>cd /opt/cassandra

Prepare the log directory
>sudo mkdir -p /var/log/cassandra

>whoami
carl

Put the right authority to the directory
>sudo chown -R carl /var/log/cassandra

>sudo mkdir -p /var/lib/cassandra
>sudo chown -R carl /var/lib/cassandra

Here are the path for log and data storage.

Put that in the path
>sudo vi ~/.profile
export CASSANDRA_HOME=/opt/cassandra
export PATH=/opt/cassandra/bin:$PATH

>. ~/.profile

2.2 Check the configuration
In the conf/cassandra.yaml, we can find all the configuration
data_file_directories:
            - /var/lib/cassandra/data

commitlog_directory: /var/lib/cassandra/commitlog

saved_caches_directory: /var/lib/cassandra/saved_caches

The Log configuration is conf/log4j-server.properties
log4j.appender.R.File=/var/log/cassandra/system.log

Usually, the cassandra uses the 1/4 ~ 1/2 of my memory. It is configured here.
conf/cassandra-env.sh
uncomments these lines and change the value
#MAX_HEAP_SIZE="4G"
#HEAP_NEWSIZE="800M"

2.3 Start the cassandra DB
>./cassandra -f

2.4 Using cassandra-cli
>cassandra-cli
cassandra-cli>help;

Creating KeySpace
cassandra-cli>create keyspace DEMO
...         with placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy'
...         and strategy_options = {replication_factor:1};

Change to DEMO
cassandra-cli>use DEMO;

Create Users column family
cassandra-cli>create column family Users
...     with key_validation_class = 'UTF8Type'
...     and comparator = 'UTF8Type'
...     and default_validation_class = 'UTF8Type';
7ad2d938-930e-360c-8163-fd71c719d3f8

Store data into Users column family
cassandra-cli>set Users[1234][name] = carl;
cassandra-cli>set Users[1234][password] = 111111;

It seems to me that there is table Users and one row with name = carl, password = 111111.

Fetch the data from DB
cassandra-cli>get Users[1234];
=> (column=name, value=carl, timestamp=1368728151201000)
=> (column=password, value=111111, timestamp=1368728169110000)
Returned 2 results.

We can also use cassandra-cli like this
>cassandra-cli -host localhost -port 9160

3. Configuring Multinode Cluster
Multiple nodes communicate with each other with Gossip and Thrift.

Configure and Find the configuration file conf/cassandra.yaml
a, listen_address: 192.168.11.15   // for the nodes communicate
b, rpc_address: 0.0.0.0                 // for the client
c, seeds: - "192.168.11.15"
              - "192.168.11.16"

a, listen_address: 192.168.11.16
b, rpc_address: 0.0.0.0
c, seeds: -"192.168.11.15"
              -"192.168.11.16"

a, listen_address: 192.168.11.17
b, rpc_address: 0.0.0.0
c, seeds: -"192.168.11.15"
              -"192.168.11.16"

>nodetool -h 192.168.11.15 ring
>nodetool -h 192.168.11.15 -port 8080 ring


References:
http://www.cnblogs.com/gpcuster/archive/2010/03/12/1684072.html
http://www.cnblogs.com/gpcuster/archive/2010/03/25/1695490.html
GettingStarted
http://wiki.apache.org/cassandra/GettingStarted
Cassandra-cli
http://wiki.apache.org/cassandra/CassandraCli
Multiple Nodes
http://rdc.taobao.com/blog/cs/?p=3
http://blog.csdn.net/computerchao/article/details/8538126
http://dongxicheng.org/nosql/cassandra-install/

分享到:
评论

相关推荐

    Getting Started with Storm-带书签目录超清文字版.pdf

    《Getting Started with Storm》这本书是入门Apache Storm的绝佳资源,它深入浅出地介绍了这个分布式实时计算系统的原理、架构以及实际应用。Apache Storm是一个开源的流处理系统,它能够处理无限的数据流,并确保每...

    storm学习入门《Getting started with Storm》中英文版

    "storm学习入门《Getting started with Storm》中英文版" 指的是一个关于Apache Storm的初学者教程资源,包含了该技术的入门介绍。Apache Storm是一个开源的分布式实时计算系统,用于处理流数据,即持续不断的数据流...

    apress.beginning.apache.cassandra.development.1484201434

    and JavaScript are the most commonly used programming/scripting languages, author Vivek Mishra includes complete coverage of accessing Cassandra database with these languages and developing ...

    Cassandra The Definitive Guide(2nd) azw3

    Cassandra The Definitive Guide(2nd) 英文azw3 第2版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除

    Cassandra

    Discover how Cassandra's distributed design lets you add or remove nodes from the cluster as your application requires, Get examples for writing clients in Java, Python, and C#, Extend Cassandra by ...

    Learning Apache Cassandra - Second Edition

    Master the advanced features available in Cassandra 3.x through a step-by-step tutorial and build a scalable, high performance database layer Book Description Cassandra is a distributed database ...

    NoSQL Web Development with Apache Cassandra(2015)

    Apache Cassandra is the most commonly used NoSQL database written in Java and is renowned in the industry as the only NoSQL solution that can accommodate the complex requirements of today’s modern ...

    Beginning Apache Cassandra Development

    Beginning Apache Cassandra Development introduces you to one of the most robust and best-performing NoSQL database platforms on the planet. Apache Cassandra is a document database following the JSON ...

    Cassandra The Definitive Guide(2nd) mobi

    Cassandra The Definitive Guide(2nd) 英文mobi 第2版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除

    Cassandra-The-Definitive-Guide.pdf

    ness problems, freeing you from the burden of plumbing. Using connectivity compo- nents has never been easier, because you don’t have to implement JMS message listeners or FTP clients, deal with ...

    Packt.Mastering.Apache.Cassandra.3rd.Edition

    Build, manage, and configure high-performing, reliable NoSQL database for your applications with Cassandra Key Features Write programs more efficiently using Cassandra's features with the help of ...

    Cassandra The Definitive Guide(2nd) epub

    Cassandra The Definitive Guide(2nd) 英文epub 第2版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除

    cassandra-benchmark

    This technical report presents the results of a benchmark test conducted by Locomatix, Inc., on Apache’s Cassandra open-source distributed database management system (DBMS), utilizing the Violin ...

Global site tag (gtag.js) - Google Analytics