Facebook Cassandra集群配置图解2

上一篇“Facebook Cassandra 介绍及Mac配置”主要介绍了Cassandra单节点的配置和基本使用,正所谓distribut数据库没有集群是发挥不出它的优势的,同样的作为现在的主流分布式数据库,没有集群是体现不出Cassandra的优势的。下面简单的介绍在mac下面集群的配置,方法同样左右用类unix的机子。

开启SSH

所谓的集群就是多台机子组合在一起工作,这边使用了两台mac来进行配置。首先要做的是开启SSH功能,默认情况下mac的ssh功能是被防火墙阻止的,即端口22号被屏蔽了,按照下面两步开启ssh。点击mac的system preferences->sharing,选择remot login。

opneSSH

这样就可以通过ssh user@192.168.1.218来远程这个机子,方便下面的操作。

配置节点

首先按照单节点的配置方式安装Cassandra,接下来再配置节点通信信息。Cassandra 使用Gossip协议P2P的方式进行节点间的通信,需要在配置的节点中修改conf/storage-conf.xml中增加<Seed>,类似DNS的作用,显式的配置它所连接的节点。原文如下:

Cassandra nodes exchange information about one another using a mechanism called Gossip, but to get the ball rolling a newly started node needs to know of at least one other, this is called a Seed. It’s customary to pick a small number of relatively stable nodes to serve as your seeds, but there is no hard-and-fast rule here. Do make sure that each seed also knows of at least one other, remember, the goal is to avoid a chicken-and-egg scenario and provide an avenue for all nodes in the cluster to discover one another.

按照这个思想,我们找到conf/storage-conf.xml

1..修改seed

将原先配置文件中的

<Seeds>
    <Seed>127.0.0.1</Seed>
</Seeds>

修改为

<Seeds>
    <Seed>192.168.1.218</Seed>
    <Seed>192.168.1.216</Seed>
</Seeds>

其中seed列表中包括其他的节点IP,有多个节点就整个多少个Seed。

2.修改ListenAddress

将<ListenAddress>localhost</ListenAddress>

修改为

<ListenAddress>192.168.1.218</ListenAddress>

listenaddress中填的是本节点的IP,这个端口控制端口,Cluster的节点通过该端口进行通信

3.修改ThriftAddress

将<ThriftAddress>localhost</ThriftAddress>

修改为:

<ThriftAddress>0.0.0.0</ThriftAddress>或<ThriftAddress>192.168.1.218</ThriftAddress>

0.0.0.0表示侦听所有接口,192.168.1.218表示该节点ip,这个端口监听来自客户端的消息,使用Thrift编程就用这个端口。

这样就完成了cassandra的集群配置,测试在本节点登陆另外一个节点,如果成功表示配置成功。或者使用nodetool工具来检测。

基本使用

数据同步

启动两个节点的cassandra。

使用./bin/cassandra-cli登陆本节点,查看上一次插入的测试数据,发现两边都可以查到相同的数据,说明完成了数据库的同步。途中黑色背景的Terminal为节点1,蓝色背景的Terminal为节点2。

synth-data

检查简单情况

nodetool-ring

插入数据

从一个节点插入数据,在另外一个节点查看刚插入的数据,测试成功。

query-data

更新数据

cassandra中直接使用set命令来完成数据的更新,制定列明,从新赋值就完成了数据的更新,看bittable的论文说会保存历史记录,也就说保存了不同时间段的数据,而且在storage-conf.xml中也有相应版本的被分数的配置,但是要怎么查看历史版本的呢?希望有知道的朋友告知。

custer-upate

删除数据

删除数据可以指定删除特定的列,特定的keyspace。

custer-delete

系统资源占用情况

以下为1个节点的情况,初步看内存使用比较高,线程创建了很多。

custer-cpu-memory-usage

未完待续…

以上简单的使用了下cassandra的集群功能,当然目前使用的数据量很小,完全没有体现出大数据量时的优势,这其中的cassandra中的节点通信时怎么完成的,数据同步时怎么完成的,怎么能够快速的查找出指定的数据,等等,这些都是下一步需要分析研究的。下一步将主要放在怎么使用其提供的API,敬请期待。

无觅相关文章插件,快速提升流量

Leave a comment

5 Comments.


  1. mac上的命令行这么漂亮呀

  2. 我来看博主文章了,感谢分享哦!!!


发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*


您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackbacks and Pingbacks:

Bad Behavior has blocked 1475 access attempts in the last 7 days.

site tracking with Asynchronous Google Analytics plugin for Multisite by WordPress Expert at Web Design Jakarta.

serial corel draw 11

serial corel draw 11 serials

free corel photoshop download

free corel photoshop download keygen

adobe free

adobe free

key office 2010

office 2010 key

download photo shop free

photo shop serial

free winrar download for xp

download winrar for xp for free

windows 7 free

windows 7 crack

cs5 serialz

cs5 serialz free

free corel downloads

free corel downloads cracked

office 2010 free

office 2010 key

winrar password cracker serial

wirar password cracker

serial winzip 11

serial winzip 11 key

photoshop key

photoshop key

windows key

windows key

corel dvd moviefactory 6

corel dvd moviefactory 6 downloads

office 2010 professional key

office 2010 key

photo shop key

photo shop key

winrar 3 download

winrar 3 download freedownload

windows 7 key

windows 7 key