栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Cassandra On Docker

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Cassandra On Docker

创建

创建网络

docker network create cassandra

启动一个临时的cassandra(注意,只是测试,关闭docker后cassandra容器会删除)

docker run --rm -d --name cassandra --hostname cassandra --network cassandra cassandra

连接cassandra

# 直接进docker连接
docker exec -it cassandra sh
# 无用户名
docker run -it --network cassandra --rm cassandra cqlsh cassandra
# 使用用户名
docker run -it --network cassandra --rm cassandra cqlsh -u cassandra -pcassandra cassandra

使用

cassandra语法与sql很像

# 查看keyspaces(相当于数据库)
describe keyspaces;
# 创建keyspaces
CREATE KEYSPACE IF NOT EXISTS mycasdb WITH REPLICATION = {'class': 'SimpleStrategy','replication_factor':3};
# ---- 注意class,replication_factor参数
# 使用数据库
 use mycasdb ;
 #创建表
 CREATE TABLE user (id int,user_name varchar,PRIMARY KEY (id));
 #查看所有表
DESCRIBE TABLES ;
#插入数据
INSERT INTO user (id,user_name) VALUES (1,'sxj');
#查看数据
SELECt * FROM user ;
#删除数据
delete from user where id=1;

参考:
https://cassandra.apache.org/_/quickstart.html
https://hub.docker.com/_/cassandra

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/854989.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号