2014-05-01 01:43:20 +08:00
Executive summary
-----------------
2012-07-12 00:38:54 +08:00
2014-05-01 01:43:20 +08:00
Cassandra is a partitioned row store. Rows are organized into tables with a required primary key.
2012-07-12 00:38:54 +08:00
2021-04-26 21:43:47 +08:00
https://cwiki.apache.org/confluence/display/CASSANDRA2/Partitioners[Partitioning] means that Cassandra can distribute your data across multiple machines in an application-transparent matter. Cassandra will automatically repartition as machines are added and removed from the cluster.
2009-04-26 02:52:40 +08:00
2021-04-26 21:43:47 +08:00
https://cwiki.apache.org/confluence/display/CASSANDRA2/DataModel[Row store] means that like relational databases, Cassandra organizes data by rows and columns. The Cassandra Query Language (CQL) is a close relative of SQL.
2009-05-02 00:05:13 +08:00
2014-05-01 01:43:20 +08:00
For more information, see http://cassandra.apache.org/[the Apache Cassandra web site].
2009-05-02 00:05:13 +08:00
2010-02-17 02:53:59 +08:00
Requirements
------------
2015-05-16 02:36:49 +08:00
. Java >= 1.8 (OpenJDK and Oracle JVMS have been tested)
2014-05-01 01:43:20 +08:00
. Python 2.7 (for cqlsh)
2009-05-02 00:05:13 +08:00
Getting started
---------------
This short guide will walk you through getting a basic one node cluster up
and running, and demonstrate some simple reads and writes.
2014-05-01 01:43:20 +08:00
First, we'll unpack our archive:
2009-05-02 00:05:13 +08:00
2014-05-01 01:43:20 +08:00
$ tar -zxvf apache-cassandra-$VERSION.tar.gz
$ cd apache-cassandra-$VERSION
2009-05-02 00:05:13 +08:00
2015-05-07 22:15:34 +08:00
After that we start the server. Running the startup script with the -f argument will cause
2014-05-01 01:43:20 +08:00
Cassandra to remain in the foreground and log to standard out; it can be stopped with ctrl-C.
2011-10-28 00:56:29 +08:00
2014-05-01 01:43:20 +08:00
$ bin/cassandra -f
****
Note for Windows users: to install Cassandra as a service, download
2014-05-01 01:50:05 +08:00
http://commons.apache.org/daemon/procrun.html[Procrun], set the
2014-05-01 01:43:20 +08:00
PRUNSRV environment variable to the full path of prunsrv (e.g.,
2011-10-28 00:56:29 +08:00
C:\procrun\prunsrv.exe), and run "bin\cassandra.bat install".
Similarly, "uninstall" will remove the service.
2014-05-01 01:43:20 +08:00
****
2009-05-02 00:05:13 +08:00
2012-07-12 00:38:54 +08:00
Now let's try to read and write some data using the Cassandra Query Language:
2009-05-02 00:05:13 +08:00
2014-05-01 01:43:20 +08:00
$ bin/cqlsh
2009-05-02 00:05:13 +08:00
The command line client is interactive so if everything worked you should
2014-05-01 01:43:20 +08:00
be sitting in front of a prompt:
2012-11-12 15:25:27 +08:00
2014-05-01 01:43:20 +08:00
----
Connected to Test Cluster at localhost:9160.
[cqlsh 2.2.0 | Cassandra 1.2.0 | CQL spec 3.0.0 | Thrift protocol 19.35.0]
Use HELP for help.
2020-07-27 19:48:29 +08:00
cqlsh>
2014-05-01 01:43:20 +08:00
----
2010-10-21 04:15:27 +08:00
2012-07-12 00:38:54 +08:00
As the banner says, you can use 'help;' or '?' to see what CQL has to
2010-11-27 10:16:31 +08:00
offer, and 'quit;' or 'exit;' when you've had enough fun. But lets try
2012-07-12 00:38:54 +08:00
something slightly more interesting:
2014-05-01 01:43:20 +08:00
----
2020-07-27 19:48:29 +08:00
cqlsh> CREATE KEYSPACE schema1
2014-05-01 01:43:20 +08:00
WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
cqlsh> USE schema1;
cqlsh:Schema1> CREATE TABLE users (
user_id varchar PRIMARY KEY,
first varchar,
last varchar,
age int
);
2020-07-27 19:48:29 +08:00
cqlsh:Schema1> INSERT INTO users (user_id, first, last, age)
2014-05-01 01:43:20 +08:00
VALUES ('jsmith', 'John', 'Smith', 42);
cqlsh:Schema1> SELECT * FROM users;
user_id | age | first | last
---------+-----+-------+-------
jsmith | 42 | john | smith
2020-07-27 19:48:29 +08:00
cqlsh:Schema1>
2014-05-01 01:43:20 +08:00
----
2009-05-02 00:05:13 +08:00
If your session looks similar to what's above, congrats, your single node
2020-07-27 19:48:29 +08:00
cluster is operational!
2009-05-02 00:05:13 +08:00
2012-11-12 15:25:27 +08:00
For more on what commands are supported by CQL, see
2014-05-01 01:43:20 +08:00
https://github.com/apache/cassandra/blob/trunk/doc/cql3/CQL.textile[the CQL reference]. A
reasonable way to think of it is as, "SQL minus joins and subqueries, plus collections."
2009-05-02 00:05:13 +08:00
2020-07-27 19:48:29 +08:00
Wondering where to go from here?
2009-05-02 00:05:13 +08:00
2012-07-12 00:38:54 +08:00
* Getting started: http://wiki.apache.org/cassandra/GettingStarted
* Join us in #cassandra on irc.freenode.net and ask questions
2009-05-02 00:05:13 +08:00
* Subscribe to the Users mailing list by sending a mail to
2010-05-08 04:55:33 +08:00
user-subscribe@cassandra.apache.org
2012-07-12 00:38:54 +08:00
* Planet Cassandra aggregates Cassandra articles and news:
http://planetcassandra.org/