首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

Cassandra Database(六)Multinode Cluster

2014-04-27 
Cassandra Database(6)Multinode ClusterCassandra Database(6)Multinode ClusterOn MAC system, we can d

Cassandra Database(6)Multinode Cluster

Cassandra Database(6)Multinode Cluster

On MAC system, we can do like this.

>sudo ifconfig lo0 alias 127.0.0.2 up
>sudo ifconfig lo0 alias 127.0.0.3 up

Then we have the IP 127.0.0.1, 127.0.0.2, 127.0.0.3

If I change the configuration file cassandra.yaml and want to start 3 nodes on my local machine. I got errors.
Error Message:
Port already in use: 7199

Solution:
Right now, I do not know the solution. Just go on and try CCM

>git clone?https://github.com/pcmanus/ccm.git

That is cool, my local machine python version is 2.7.5.?
sparkworker1:ccm carl$ python --version Python 2.7.5

>sudo easy_install pyYaml
>sudo ./setup.py install

>ccm help

>sudo ln -s /Users/carl/tool/ccm /opt/ccm

Create the Instance and Nodes
Tell ccm which version are we plan to use
>ccm create Test -v 2.0.4

Create a cluster named Test with version 2.0.4

Then create 3 nodes
>ccm populate -n 3

Start all the nodes
>ccm start

Then we have 3 nodes. We can connect as follow:
>cqlsh 127.0.0.3 9160

>ccm node1 ring Datacenter: datacenter1 ========== Address??? Rack??????? Status State ? Load??????????? Owns??????????????? Token ????????????????????????????????????? ????????????????????????????????????????????????????????????????????????? 3074457345618258602 ??????????????????????? 127.0.0.1? rack1 ????? Up ??? Normal? 68.41 KB??????? 66.67%????????????? -9223372036854775808??????????????????????? 127.0.0.2? rack1 ????? Up ??? Normal? 35.92 KB??????? 66.67%????????????? -3074457345618258603??????????????????????? 127.0.0.3? rack1 ????? Up ??? Normal? 52.14 KB??????? 66.67%????????????? 3074457345618258602 ?

This is the method to add one more node
>ccm add node4 -i 127.0.0.4 -j 7400 -b

That is cool, we can use java library to connect to the cluster
? val hosts = "127.0.0.1,127.0.0.2,127.0.0.3"
? val nativePort = 9042? //9042, 9160

? val keyspaceName = "books"
? val columnFamilyName = "books"
? val replicationStrategy = "SimpleStrategy"
? val replicationFactor = 2

But from the document, ccm is only support local machine right now. So looking forward to see the future version.

>nodetool -host 127.0.0.1 -p 7100 status Datacenter: datacenter1 ======================= Status=Up/Down |/ State=Normal/Leaving/Joining/Moving --? Address??? Load ????? Owns (effective)? Host ID ????????????????????????????? Token??????????????????????????????????? Rack UN? 127.0.0.1? 40.74 KB ? 66.7% ??????????? 03e83bcf-d409-4ea8-ac0c-3be00451cc1c? -9223372036854775808 ??????????????????? rack1 UN? 127.0.0.2? 51.02 KB ? 66.7% ??????????? 133165df-a23a-4768-a339-62e453bb862d? -3074457345618258603 ??????????????????? rack1 UN? 127.0.0.3? 67.24 KB ? 66.7% ??????????? b1f7c514-a0b6-4266-8d1b-e89f4d13f43e? 3074457345618258602????????????????????? rack1

References:
http://wiki.apache.org/cassandra/GettingStarted

热点排行