Cassandra简介

Download

java -version
# openjdk version "1.8.0_212" >= Java 8

python --version
# Python 3.5.2 >= 2.7

wget http://mirrors.tuna.tsinghua.edu.cn/apache/cassandra/3.11.5/apache-cassandra-3.11.5-bin.tar.gz

tar xf apache-cassandra-3.11.5-bin.tar.gz && cd apache-cassandra-3.11.5

Service

./bin/cassandra

./bin/cqlsh
CREATE KEYSPACE test WITH replication = {'class':'SimpleStrategy', 'replication_factor' : 1};
DESCRIBE test;
USE test;

CREATE TABLE student(  
   id int PRIMARY KEY,  
   name text,  
   phone varint  
);
INSERT INTO student(id, name, phone) VALUES(001, 'XiaoMing', 9999999999);
SELECT * FROM student;

ALTER TABLE student ADD favs map;
INSERT INTO student (id, name, favs) VALUES (002, 'XiaoWang', { 'fruit' : 'Apple', 'band' : 'Beatles' });
SELECT * FROM student WHERE favs['fruit'] = 'Apple' ALLOW FILTERING;

CREATE INDEX ON student (ENTRIES(favs));
SELECT * FROM student WHERE favs['fruit'] = 'Apple';

Consistency

分布式一致性的三个算法

1.Paxos => Apache ZooKeeper

2.Raft => 比Paxos更易理解和实施 => TiKV | etcd | RocketMQ DLedger

3.Gossip => 完全去中心化 => Bitcoin | Apache Cassandra

Reference

  • 4 Types of NoSQL Databases

  • NoSQL Tutorial: Learn NoSQL Features, Types, What is, Advantages

  • 关于 Cassandra 的错误观点

  • ALLOW FILTERING explained

  • NoSQl漫谈

  • 分布式一致性机制整理

  • Raft算法和Gossip协议

  • 认识Cassandra

  • Cassandra教程

  • Cassandra Tutorial for Beginners | Learn Apache Cassandra

  • Cassandra GUI Client for Mac — TablePlus now supports it!

你可能感兴趣的:(Cassandra简介)