-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Learning Apache Cassandra
By :
A keyspace is a collection of related tables, equivalent to a database in a relational system. To create the keyspace for our MyStatus application, issue the following statement in the CQL shell:
CREATE KEYSPACE "my_status"
WITH REPLICATION = {
'class': 'SimpleStrategy', 'replication_factor': 1
};Here we created a keyspace called my_status, which we will use for the remainder of this book. When we create a keyspace, we have to specify replication options. Cassandra provides several strategies for managing replication of data; SimpleStrategy is the best strategy as long as your Cassandra deployment does not span multiple data centers. The replication_factor value tells Cassandra how many copies of each piece of data are to be kept in the cluster; since we are only running a single instance of Cassandra, there is no point in keeping more than one copy of the data. In a production deployment, you would certainly want a higher replication factor; 3 is a good place to start.
A few things at this point are worth noting about CQL's syntax:
Once you've created a keyspace, you would want to use it. In order to do this, employ the USE command:
USE "my_status";
This tells Cassandra that all future commands will implicitly refer to tables inside the my_status keyspace. If you close the CQL shell and reopen it, you'll need to reissue this command.
Change the font size
Change margin width
Change background colour