cassandra 学习笔记

了解系统

  #查看CPU core数量:

  more /proc/cpuinfo | grep 'processor' | wc -l

  #查看CPU位数

  getconf LONG_BIT

  #查看操作系统位数

  uname -a

  #查看内存大小

  free -m



资料篇:

  #cassandra文档

http://www.datastax.com/docs/1.2/index

  #官方运维文档

http://wiki.apache.org/cassandra/Operations


井上天花篇:

OpsCenter(cassandra运维工具)

  #下载与安装

http://www.datastax.com/docs/opscenter/install/install_tar

  #介绍

http://www.datastax.com/what-we-offer/products-services/datastax-opscenter


救命稻草篇篇:

  #去社区找答案

  ①https://groups.google.com/forum/#!forum/hector-users

  ② 官方mail list


最佳实践篇

  1. 通过commitlog_directory配置commit log路径,请线上应用请不要与数据放到一块磁盘

  2. 通过data_file_directories配置多个磁盘存放数据

  3. Java Heap Size在6GB到8GB是不错的配置,绝对不要超过16GB

  4. batch mutations:1000个mutations可以启动10个并发线程,每个100个mutations来实现,太大mutations会导致回滚成本很高

  5. 不使用OPP、BOP分区器

  6. Always specify your initial token.

  7. have at more than one seed node per data center.


书中过时部分内容

副本存放策略SimpleStrategy、NetworkTopologyStrategy


cassandra学习路线图

客户端使用、CQL、监控、调优、Datastatx的管理工具(http://planetcassandra.org/)


windows下运行:

  • 解压tar包

  • apache-cassandra-1.2.2\bin\cassandra.bat:启动服务,不出问题9160端口就启动了。

  • apache-cassandra-1.2.2\bin\cassandra-cli.bat:客户端程序

      # 启动客户端同时连接到远程(本地)服务器,cassandra-cli.bat connect localhost/9160


客户端命令:

  • ? #帮助

  • exit; #退出

  • connect localhost/9160 #连接到本地(远程)服务器

  • 创建keyspace

create keyspace MyKeyspace;

  • 1

    2

    3

    create keyspace my_keyspace

    with placement_strategy ='org.apache.cassandra.locator.SimpleStrategy'

    and strategy_options = {replication_factor:2};

    drop keyspace my_keyspace ;

  • show keyspaces;

  • use MyKeyspace;

  • create column family Users

       with key_validation_class = 'UTF8Type'

       and comparator = 'UTF8Type'

       and default_validation_class = 'UTF8Type';

  • set Users['yue.zhang']['email']='yue.zhang@126.com';

  • set Users['yue.zhang']['gender']='F';

  • get Users['yue.zhang']['email'];

  • list Users;

  • count Users['yue.zhang'];

  • set Users['yue.zhang']['email']='yue.zhang@126.com';

  • list Users;

  • --------------华丽分割线-------

  • create column family fc

    with default_validation_class=CounterColumnType

      and key_validation_class=UTF8Type

      and comparator=UTF8Type;

  • incr fc ['20120203_img.autohome.com.cn']['trffice'] by 111;

  • incr fc ['20120203_img.autohome.com.cn']['trffice'] by 111;

  • list fc;


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值