Quantcast
Channel: CodeSection,代码区,数据库(综合) - CodeSec
Viewing all articles
Browse latest Browse all 6262

[Cassandra教程] (二)Cassandra 安装、配置与升级方法

$
0
0
原创声明: 本文为原创文章,转载需要注明来自http://www.flyml.net 为了更好的阅读体验,请回 源站 查看文章。有任何修改、订正只会在源站体现 最后更新时间:2016年09月03日

本文接上一篇文章: 《为什么我们选择了Cassandra》

windows安装 来自http://www.flyml.net

可能各位读者主要的工作机器还是Windows。因此先说说其他NoSQL DB 可能没法实现的在Windows安装方法。

当前最新的版本是3.7, 下载地址:http://downloads.datastax.com/datastax-ddc/datastax-ddc-64bit-3.7.0.msi

强烈推荐x64的环境上面安装, 如果是32位系统,还需要自行安装 Microsoft Visual C++ 2008 Redistributable Package (x86) 。 下载下来,直接双击解压即可运行。 官网有很详细的截图: http://www.datastax.com/2012/01/getting-started-with-apache-cassandra-on-windows-the-easy-way 。 但是其中有一些信息需要更新:

适应的平台已经包括了Windows 10 (笔者自己就是Win10 x64) 文中提到的OpsCenter, 在普通版本已经不再支持。只在企业版之中才有 推荐直接安装到C盘! 因为老版本上,如果不是安装到C盘的话,会有一些奇奇怪怪的问题 不太清楚新版本是否还有这种问题。 来自http://www.flyml.net linux 安装

Linux下的安装,本质上跟Windows安装一样。 下载Tar安装包之后,解压并运行命令:

# 后台线程启动 bin/cassandra.sh # 前台线程启动 bin/cassandra.sh -f

如果是以后台线程的方式启动,停止方式相对有一些粗暴:

$ psauwx | grepcassandra $ sudokillpid

来自http://www.flyml.net

常用配置:

所有的配置都在cassandra.yaml 之中进行修改, 大多数场景之下修改下面几个配置项即可

(1)cluster_name

设置集群的名称。 同一个集群需要设置成相同的名字才可以

(2)data_file_directories

数据文件存放的文件夹。 实际上可以写多个文件夹。默认是$CASSANDRA_HOME/data/data。 实际上,笔者并不太清楚为什么可以配置多个目录,难道是一个写满了就会往第二个目录写吗?

(3)commitlog_directory

如果你的机器有两块硬盘, 强烈建议将commitlog_directory设置成与data_file_directories不同的目录 , 并且各自放在不同的硬盘之上,充分理论多个硬盘的IO能力。

(4)seed_provider.seeds

这是一个很重要的配置项。 所谓Cassandra的Seed(种子)是当外面的比如Java API需要调用集群的时候,需要首先让Seed server 告诉当前调用者,集群一共有哪些个机器。除此之外,所有节点都是平等的。 不能把所有机器都设置成seeds,否则会有一些奇奇怪怪的问题。。。

(5)listen_address &rpc_address

需要设置成当前机器的IP。 最好机器能有一个固定的IP并将这个IP写死到配置文件之中。

如果你嫌配置麻烦,可以设置一个配置模板,然后写一个python脚步,通过paramiko 远程执行python文件并把相应的参数写到配置文件之中

(6)各种timeout

如果你需要将Cassandra集群打造成一个用于数据分析的数据仓库,那么你就需要将各种timeout的值设置成比较大的数值。比如:

# How long the coordinator should wait for read operations to complete read_request_timeout_in_ms: 100000 # How long the coordinator should wait for seq or index scans to complete range_request_timeout_in_ms: 100000 # How long the coordinator should wait for writes to complete write_request_timeout_in_ms: 100000 # How long the coordinator should wait for counter writes to complete counter_write_request_timeout_in_ms: 100000 # How long a coordinator should continue to retry a CAS operation # that contends with other proposals for the same row cas_contention_timeout_in_ms: 100000 # How long the coordinator should wait for truncates to complete # (This can be much longer, because unless auto_snapshot is disabled # we need to flush first so we can snapshot before removing the data.) truncate_request_timeout_in_ms: 100000 # The default timeout for other, miscellaneous operations request_timeout_in_ms: 100000 来自http://www.flyml.net Ubuntu Tar安装方式升级

注: 笔者只有Ubuntu底下 + Tar 安装方式的升级经验。 其他的升级方式在官网有非常详细的记载

保存老版本上的配置文件。 理论上,各个机器的配置基本上完全一样,只有IP相关配置项不太一样 在各个节点之上安装新的Cassandra 将老版本的配置文件合并到新版本的配置文件之中 注意:只是把之前的修改项逐个的迁移到新版本的配置文件之中

另外需要特别注意的是: 不能从非常老的版本直接迁移到最新的版本之中 。 举个例子:Cassandra无法直接从2.0.X 直接迁移到3.7 之中。 因为其中的数据格式可能已经改变,只有重新将数据刷入新系统才行

具体兼容版本,一定要到官网上看清楚呢!

来自http://www.flyml.net 本文为原创文章,转载请注明 出处:http://www.flyml.net

Viewing all articles
Browse latest Browse all 6262

Latest Images

Trending Articles