了解系统
#查看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
最佳实践篇
-
通过commitlog_directory配置commit log路径,请线上应用请不要与数据放到一块磁盘
-
通过data_file_directories配置多个磁盘存放数据
-
Java Heap Size在6GB到8GB是不错的配置,绝对不要超过16GB
-
batch mutations:1000个mutations可以启动10个并发线程,每个100个mutations来实现,太大mutations会导致回滚成本很高
-
不使用OPP、BOP分区器
-
Always specify your initial token.
-
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;