In this blog, i will assume you already have Cassandra installed - intact, i will assume you have installed it on 3 difference servers already that you plan to make part of the Cassandra cluster.
So lets say you have three servers:
Server Name IP OS Java
cassandra-1 192.168.2.1 Ubuntu 14.04 java-8-oracle
cassandra-2 192.168.2.2 Ubuntu 14.04 java-8-oracle
cassandra-3 192.168.2.3 Ubuntu 14.04 java-8-oracle
On each Server, first thing to do is stop Cassandra:
sudo /etc/init.d/cassandra stop
Edit the script /etc/cassandra/cassandra-env.sh and search for the following line:
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname
Uncomment the line and add your local address as the value after the =:
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=127.0.0.1"
Also, edit the script /etc/init.d/cassandra and search for this line:
CMD_PATT="Dcassandra-pidfile=.*cassandra\.pid"
and edit it to look like this:
CMD_PATT="cassandra"
Now, lets edit the yaml (/etc/cassandra/cassandra.yaml) file make sure that the following parameters are set as below. Leave other parameters with their default settings:
cluster_name: 'test_cluster'
listen_address: 192.168.2.1
rpc_address: 192.168.2.1
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
- seeds: "192.168.2.1, 192.168.2.2, 192.168.2.3"
endpoint_snitch: GossipingPropertyFileSnitch
auto_bootstrap: false
So the yaml file on server cassandra-1 will look like above. Then the one for cassandra-2 and 3, make sure to change the 'listen_address' and 'rpc_address' to their respective IPs.
Restart cassandra on all three servers one by one.
sudo /etc/init.d/cassandra restart
Check if Cassandra is running
sudo nodetool status
When all nodes are up and running and assuming everything went well with the configuration part, it should display something like this:
george.chilumbu@dynomite-1-1:~$ sudo nodetool status
Datacenter: dc1
===============
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 192.168.2.1 158.91 KiB 256 70.1% 2b56a64c-cb8c-4f5b-9e20-b61ec0ed8498 rack1
UN 192.168.2.2 141.8 KiB 256 65.4% 074b5f6c-96c2-4562-a530-1de03586368f rack1
UN 192.168.2.3 250.65 KiB 256 64.5% 6c74e4f3-e0d3-466f-b4d1-40ec9f141bdb rack1
And when you try to log in using cqlsh, you should see something like this:
george.chilumbu@dynomite-1-1:~$ cqlsh 192.168.2.1
Connected to kkcass at 192.168.2.1:9042.
[cqlsh 5.0.1 | Cassandra 3.9 | CQL spec 3.4.2 | Native protocol v4]
Use HELP for help.
cqlsh>
No comments:
Post a Comment