官网
http://cassandra.apache.org/
下载后
wget http://mirror.bit.edu.cn/apache/cassandra/3.11.1/apache-cassandra-3.11.1-bin.tar.gz
解压
tar -xvf apache-cassandra-3.11.1-bin.tar.gz
cd apache-cassandra-3.11.1
修改配置文件
通用配置
vim conf/cassandra.yaml
jvm配置
vim conf/jvm.options
启动
[root@rabbit1 apache-cassandra-3.11.1]# bin/cqlsh localhost
Connected to Test Cluster at localhost:9042.
[cqlsh 5.0.1 | Cassandra 3.11.1 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
创建keyspace
tables由keyspace维护
CQL stores data in tables, whose schema defines the layout of said data in the table, and those tables are grouped in keyspaces.
官网原话
cqlsh> CREATE KEYSPACE Excelsior
... WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 3};
cqlsh> use Excelsior;
cqlsh:excelsior> CREATE TABLE t (
... pk int,
... t int,
... v text,
... s text static,
... PRIMARY KEY (pk, t)
... );
cqlsh:excelsior>
cqlsh:excelsior> INSERT INTO t (pk, t, v, s) VALUES (0, 0, 'val0', 'static0');
cqlsh:excelsior> INSERT INTO t (pk, t, v, s) VALUES (0, 1, 'val1', 'static1');
cqlsh:excelsior>
cqlsh:excelsior> SELECT * FROM t;
pk | t | s | v
----+---+---------+------
0 | 0 | static1 | val0
0 | 1 | static1 | val1