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
Cassandra Database(6)Multinode Cluster
最新推荐文章于 2024-08-20 10:04:23 发布
本文详细介绍了如何使用ccm工具在本地机器上创建和配置Cassandra多节点集群,包括节点初始化、配置文件修改、节点连接与管理等关键步骤。通过实例演示了如何设置多个IP地址、解决端口冲突问题,并展示了如何通过ccm添加额外节点及使用Java库进行集群连接。
5396

被折叠的 条评论
为什么被折叠?



