`
sillycat
  • 浏览: 2489397 次
  • 性别: 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/

分享到:
评论

相关推荐

    Cassandra The Definitive Guide(2nd) azw3

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

    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

    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 ...

    Cassandra.The.Definitive.Guide.2nd.Edition.Early.Release

    Updated for Cassandra 3.0, this second edition provides the technical details and practical examples you need to assess this database management system and put it to work in a production environment....

    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.3.x.High.Availability.2nd.Edition.1786462109

    Apache Cassandra is a massively scalable, peer-to-peer database designed for 100 percent uptime, with deployments in the tens of thousands of nodes, all supporting petabytes of data. This book offers ...

    Cassandra The Definitive Guide Distributed Data at Web Scale, 2nd Edition

    Cassandra 高清英文原版 第二版! 无水印,无第三方链接!

    Mastering.Apache.Cassandra.2nd.Edition.1784392618

    The book is aimed at intermediate developers with an understanding of core database concepts and want to become a master implementing Cassandra for their application. Table of Contents Chapter 1. ...

    cassandra 实战

    cassandra 实战cassandra 实战cassandra 实战cassandra 实战cassandra 实战cassandra 实战cassandra 实战cassandra 实战cassandra 实战cassandra 实战cassandra 实战cassandra 实战cassandra 实战cassandra 实战...

    Cassandra The Definitive Guide

    Cassandra The Definitive Guide

Global site tag (gtag.js) - Google Analytics