Apache Cassandra Cluster Setup
This tutorial is to build a 3-node cassandra cluster.
Step1: Download apache-cassandra and install it on your operating system.[more details in the previous tutorial]
Step2: Modify configuration fils, cassandra.yaml.
You can find it is under ../conf/cassandra.yaml
There are only three things you need to focus on if you just want to build a simple cassandra cluster:
1. listen_address
2. rpc_address
3. seeds
we'll take a glance at those one by one.
1. listen_address, Here is the description about it:
# Address to bind to and tell other Cassandra nodes to connect to. You
# _must_ change this if you want multiple nodes to be able to
# communicate!
#
# Leaving it blank leaves it up to InetAddress.getLocalHost(). This
# will always do the Right Thing *if* the node is properly configured
# (hostname, name resolution, etc), and the Right Thing is to use the
# address associated with the hostname (it might not be).
#
# Setting this to 0.0.0.0 is always wrong.
listen_address:
So, leave listen_address blank is a good choice.
2. rpc_address, here is the description:
# Address to broadcast to other Cassandra nodes
# Leaving this blank will set it to the same value as listen_address
# broadcast_address: 1.2.3.4
# The address to bind the Thrift RPC service to -- clients connect
# here. Unlike ListenAddress above, you *can* specify 0.0.0.0 here if
# you want Thrift to listen on all interfaces.
#
# Leaving this blank has the same effect it does for ListenAddress,
# (i.e. it will be based on the configured hostname of the node).
rpc_address:
After reading the description, leave it blank it good.
3. seeds, this part you have to edit it, the description of it:
# any class that implements the SeedProvider interface and has a
# constructor that takes a Map of parameters will do.
seed_provider:
# Addresses of hosts that are deemed contact points.
# Cassandra nodes use this list of hosts to find each other and learn
# the topology of the ring. You must change this if you are running
# multiple nodes!
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
# seeds is actually a comma-delimited list of addresses.
# Ex: ",,"
- seeds: "127.0.0.1"
You only need to change the last line "- seeds: "127.0.0.1", if your 3 IP address are 192.168.0.1, 192.168.0.2, and 192.168.0.3, your last line should be
- seeds:"192.168.0.1, 192.168.0.2, 192.168.0.3"
Step3: restart cassandra, and be sure that the port can access to other servers.
you can turn iptables off using the command in terminal:
# sudo service iptables stop
you can turn iptables off using the command in terminal:
# sudo service iptables stop
Step4: Now to check whether it works, using Cassandra-CLI(command line interface):
# ../bin/nodetool -h 192.168.1.0.1 -p 7199 ring
Address DC Rack Status State Load Owns Token 127605887595351923798765477786913079296 192.168.0.1 DC1 r1 Up Normal 17.3 MB 33.33% 0 192.168.0.2 DC1 r1 Up Normal 17.4 MB 33.33% 42535295865117307932921825928971026432 192.168.0.3 DC1 r1 Up Normal 37.2 MB 33.33% 85070591730234615865843651857942052864
Step5: Write new info to your cassandra database, and check all servers get the same date.
there is no need to have all 3 nodes (the IPs that you stated) to act as seeds.
ReplyDelete