- Learning Apache Cassandra(Second Edition)
- Sandeep Yarabarla
- 271字
- 2021-07-03 00:19:28
How to configure keyspaces
In the previous chapter, we learned a little bit about keyspaces. A keyspace is essentially a namespace for various tables in a cluster. It is somewhat analogous to a database in the relational world. All data will reside within some keyspace. The main function of declaring keyspaces over declaring tables directly is not to serve as a mapping layer, but to control the replication of closely related tables.
Let's create the keyspace for our MyStatus application by executing the following command in CQL shell:
CREATE KEYSPACE "my_status"
WITH REPLICATION = {
'class': 'SimpleStrategy', 'replication_factor': 1
};
When creating a keyspace, you have to specify certain configuration parameters such as the replication strategy and the replication factor. The replication strategy tells the Cassandra cluster how to distribute various copies of the same data across the different data centers and racks of cluster. The replication factor specifies how many copies of each record to store. There is another configuration parameter called durable writes, which we will learn about later.
For now, we will use SimpleStrategy and a replication factor of 1 since we have a single node cluster running. This keyspace will serve as the namespace for all the tables we create in the rest of the book.
In CQL, you select the keyspace to use via the USE command. To ensure all the future tables reside within the my_status keyspace, we enter the following statement:
USE "my_status";
Another way to select a keyspace is to prefix a table name with the keyspace name wherever we use it, such as <keyspace_name> and <table_name>.
- 我的J2EE成功之路
- 實時流計算系統(tǒng)設(shè)計與實現(xiàn)
- 數(shù)據(jù)中心建設(shè)與管理指南
- 返璞歸真:UNIX技術(shù)內(nèi)幕
- 計算機(jī)網(wǎng)絡(luò)技術(shù)基礎(chǔ)
- Arduino &樂高創(chuàng)意機(jī)器人制作教程
- 網(wǎng)絡(luò)化分布式系統(tǒng)預(yù)測控制
- Mastering Exploratory Analysis with pandas
- 智能鼠原理與制作(進(jìn)階篇)
- 網(wǎng)絡(luò)服務(wù)器搭建與管理
- 中文版AutoCAD 2013高手速成
- 生成對抗網(wǎng)絡(luò)項目實戰(zhàn)
- 工業(yè)機(jī)器人入門實用教程
- Unreal Development Kit Game Design Cookbook
- 貫通Hibernate開發(fā)