最近的项目里用到了cassandra,所谓的nosql数据库,big data的大载体。其实都是扯淡,什么大数据,都是用来忽悠人的。(声明:技术选择不是本人)所以这次项目里它只是用来做缓存的。cassandra主要的特性自己可以在网上找到,实在找不到就百度百科。我不会写文章,所以我只简单罗列一些遇到的问题,希望能帮到大家,当然你也可以打打酱油神马的。我用的是1.2.11版本,没用最新的2.0。理解万岁。。。
1、cassandra有一套类似sql的语句叫cql,最新的是3.0版。这些相关API在网上都有,大家可以没事瞅两眼。当然要用这种东西得有宇宙神器python的支持。
cqlsh的安装
a. 安装python,下载http://www.python.org/getit/
配置path环境变量如:D:\Python27。只支持Python2.6或2.7。Python3.x版本不支持。
b. Cassandra1.2中的python驱动程序是在..\ Cassandra\pylib目录下的。
DOS命令 下转到\Cassandra\pylib目录,运行python setup.py install命令安装驱动。
c. windos下cqlsh启动方法:
用doc命令进入cassandra的bin目录下,
编写命令:python cqlsh localhost 9160(注:后面不要带任何符号)
这样就ok了。你接下来就可已使用类似以下的语句了:
create table users(
id int primary key,
username text,
password text,
email text,
phone text,
age int,
);
insert in to t_user(id,username,password,email,phone,age)values('1','zhangsan','111','xxxx@sina.com','***',21) USING TTL 60;
2、cassandra数据库连接时用的jdbc,配置跟关系型数据库一样。暂时还不支持现有的持久层框架。如下:
driver=org.apache.cassandra.cql.jdbc.CassandraDriver
url=jdbc\:cassandra\://localhost\:9160/xxxx?version\=3.0.0
xxxx是keyspace名称,version是cql版本。在这我遇到一个密码问题,在网上我查了好多资料配置相关的文件,但始终不能用在这个版本。所以用户名和密码一直闲置。希望有经验的传授一下下。不胜感激!
3、访问远程cassandra数据库
其实cassandra就是一个本地的存储文件。所以跟他相关的好多东西都要在文件里直接配置。假设远程服务器叫A,你使用的电脑为B。在A的电脑上找到Cassandra目录下conf,找到Cassandra.yaml文件打开:
rpc_address: 0.0.0.0 设定能够连接到本机的ip ,专业点叫nodes,设置多个电脑ip直接逗号隔开。
listen_address: x.x.x.xxx这个写远程服务器本机ip地址,然后就ok了。
4、cassandra除了cql来向习惯那样写sql,还能用java直接操作,此处略去。cassandra不像oracle或mysql之类有自增的主键id。所以我们用的是日期。在使用cql过程中,会遇到很多想不到的小知识点,致使你的工作不能进行。当让也有好用的功能,比如在第一点里插入语句最后的一句USING TTL 60;就是在60ms后删除该条数据。在遇到条件查询语句如:SELECT TTL (name) from clicks WHERE url = 'http://apache.org' ALLOW FILTERING;记住ALLOW FILTERING一定要写!否则你会哭!
5、CQL在客户端中式不支持中文直接insert,即cql里面不能带有中文,会报错:Bad Request:Input length = 1。如果直接用jdbc存储的话就能直接用,不用担心编码的问题!
6、学习cql,一定要仔细研读这个文档http://www.datastax.com/documentation/cql/3.0/index.html
以上只是很小的一部分问题,但是让人头疼,至于其他的东西网上的资料很多,大家可以自己查找学习。
以后想起什么东西再补上。。。
http://tech.chinaunix.net/a2010/1225/1142/000001142663.shtml
相关推荐
Cassandra是一个混合型的非关系的数据库,类似于Google的BigTable。其主要功能比Dynomite(分布式的Key-Value存储系统)更丰富,但支持度却不如文档存储MongoDB(介于关系数据库和非关系数据库之间的开源产品,是非...
Cassandra(apache-cassandra-3.11.11-bin.tar.gz)是一套开源分布式NoSQL数据库系统。它最初由Facebook开发,用于储存收件箱等简单格式数据,集GoogleBigTable的数据模型与Amazon Dynamo的完全分布式的架构于一身...
Title: Mastering Apache Cassandra, 2nd Edition Author: Nishant Neeraj Length: 322 pages Edition: 2 Language: English Publisher: Packt Publishing Publication Date: 2015-02-27 ISBN-10: 1784392618 ISBN-...
Cassandra(apache-cassandra-4.0.1-bin.tar.gz)是一套开源分布式NoSQL数据库系统。它最初由Facebook开发,用于储存收件箱等简单格式数据,集GoogleBigTable的数据模型与Amazon Dynamo的完全分布式的架构于一身...
Cassandra(apache-cassandra-3.0.25-bin.tar.gz)是一套开源分布式NoSQL数据库系统。它最初由Facebook开发,用于储存收件箱等简单格式数据,集GoogleBigTable的数据模型与Amazon Dynamo的完全分布式的架构于一身...
See how to get 100 percent uptime with your Cassandra applications using this easy-follow guide Learn how to avoid common and not-so-common mistakes while working with Cassandra using this highly ...
With this hands-on guide, you'll learn how Apache Cassandra handles hundreds of terabytes of data while remaining highly available across multiple data centers—capabilities that have attracted ...
Learning Apache Cassandra - Second Edition by Sandeep Yarabarla English | 25 Apr. 2017 | ASIN: B01N52R0B5 | 360 Pages | AZW3 | 10.68 MB Key Features Install Cassandra and set up multi-node clusters ...
cassandra
DevCenter cassandra客户端 DevCenter cassandra客户端 DevCenter cassandra客户端
Learning_Apache_Cassandra .pdf
apache-cassandra-3.11.13 官网原版
关于Cassandra数据模型的简单介绍
1.CAP定理理与Cassandra 1.1 Cassandra优势 2.Cassandra ⼀一致性实现 2.1 CAS 2.2 Quorum读写 2.3 不不⼀一致产⽣生原因 2.4 Hinted handoff 2.5 Read repair 2.6 Manual repair 3.Cassandra应⽤用场景 ...
Apache Cassandra is a massively scalable, peer-to-peer database designed for 100 percent uptime, with deployments in the tens of thousands of nodes, all supporting petabytes of data. This book offers ...
编程方式设置Cassandra,主要包含以下5个包,W3C认证 slf4j-api-1.7.5.jar cassandra-driver-core-2.0.2.jar guava-16.0.1.jar metrics-core-3.0.2.jar netty-3.9.0.Final.jar
spring boot与cassandra集成,使用JPA方式。