Database Reference
In-Depth Information
parameters:
# seeds is actually a comma-delimited list
of addresses.
# Ex: "<ip1>,<ip2>,<ip3>"
- seeds: "127.0.0.1"
CQL: The Cassandra Query Language
CQL is the recommended mechanism for development of all new Cassandra
applications. It implements a subset of the Structured Query Language
(SQL), making it familiar to many developers. However, it does not
implement many of SQL's features and the structure of Cassandra tables
may be a surprise to many developers.
CQL commands can be executed through three different mechanisms. The
first is the CQL shell,
cqlsh
, which is a Python application shipped with
Cassandra. This is different than
cassandra-cli
, which uses the Thrift
API. It can be found in the same directory as the Cassandra server binary.
The second is through a “native” CQL driver. Newer versions of Cassandra
implement a protocol that works only with CQL statements, similar to
protocols used by relational databases. Finally, CQL commands can be
executed using older clients that employ Cassandra's Thrift protocol using
the
execute_cql3_query
remote procedure call (RPC) command.
Keyspaces and Column Families
All Cassandra data is held in a keyspace. This is a form of namespace,
roughly equivalent to a database in MongoDB or a schema in a relational
database. When keyspaces are created, they define a replication strategy as
well as a replication factor. The replication factor is simply the number of
copiesofanygivenpieceofdatakeptinthecluster.Thestrategydefineshow
these replicas are distributed. To get started, create a
metrics
keyspace
with a replication factor of 1 using
cqlsh
:
cqlsh> CREATE KEYSPACE metrics WITH REPLICATION =
{'class':'SimpleStrategy','replication_factor':1};
These settings can be changed later using the
ALTER KEYSPACE
command.
In particular, if the cluster is to be used in a production environment with
multiple nodes, the replication strategy defined by
class
should be the