IP swapping in Cassandra cluster - cassandra

We have healthy running 3 nodes cassandra cluster but we need to swap all 3 nodes IP address due to some issue.
So basically, we want to swap old cassandra server IP address from to new cassandra server IP address.
My question is :-
1) Is there any specific procedure we need to follow to avoid any issue?
2) Or Just modify rpc_address, listen_address, seeds, peers table etc. and start the cassandra nodes?
Please help, Thanks

You have already identified most of the steps to take. Also, ensure to follow the steps one node at a time:
in cassandra.yaml update rpc_address, listen_address, seeds, and any reference to the previous IP address. Also, ensure that auto_bootstrap is set to false (by default the directive is omitted and the default value is true).
Depending on your installation, also look in cassandra-topology.properties and cassandra-rackdc.properties
Stop the cassandra service
Change the IP address of the box (i.e. ifconfig, add the new route, etc.)
in cassandra-env.sh include the following directive with the previous IP address:
JVM_OPTS="$JVM_OPTS -Dcassandra.replace_address=previous_ip_address
Start the Cassandra service in the node. Wait until nodetool status reports it as UN, you should notice that the new IP address is reported
If you added the auto_bootstrap directive in cassandra.yml, remove it\
remove the cassandra.replace_address directive from cassandra-env.sh
repeat in a different node

Related

Cassandra 3.9, how to remote access [duplicate]

I have built Cassandra server 2.0.3, then run it. It is starting and then stopped with messages:
X:\MyProjects\cassandra\apache-cassandra-2.0.3-src\bin>cassandra.bat >log.txt
java.lang.RuntimeException: Unable to gossip with any seeds
at org.apache.cassandra.gms.Gossiper.doShadowRound(Gossiper.java:1160)
at org.apache.cassandra.service.StorageService.checkForEndpointCollision
(StorageService.java:416)
at org.apache.cassandra.service.StorageService.joinTokenRing(StorageServ
ice.java:608)
at org.apache.cassandra.service.StorageService.initServer(StorageService
.java:576)
at org.apache.cassandra.service.StorageService.initServer(StorageService
.java:475)
at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.ja
va:346)
at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon
.java:461)
at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.jav
a:504)
What I can change to run it?
I had a similar problem with my cassandra v2.0.4 cluster running a single node.
Check your cassandra.yaml and make sure that your "listen_address" and "seeds" values match, with the exception that the seeds value requires quotes around it.
You might get this problem if your private IP address is different than the public one (like on AWS). For example, the host thinks it's "172.31.0.2" when it's visible as "55.70.33.10".
The solution to this problem is:
listen_address: 172.31.0.2
broadcast_address: 55.70.33.10
in cassandra.yaml
Make sure your cluster_name entry match on all the nodes in the cluster
(you may need to delete your storage if you changed the cluster name)
Verify that all nodes can ping to each other
broadcast_rpc_address and listen_address should be set to local IP
(not localhost or 127.0.0.1)
seeds should point to the IP address of the seed(s)
If you are on AWS and use the Ec2MultiRegionSnitch you will need to set the seeds to the public IP addresses rather than the private IPs.
I had the same problem on Ubuntu 16.04. I'm not sure which of these changes made it work, where XXX.XXX.XXX.XXX is your public facing IP address, below are selections from cassandra.yaml
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: "<ip1>,<ip2>,<ip3>"
- seeds: "XXX.XXX.XXX.XXX"
listen_address: XXX.XXX.XXX.XXX
broadcast_address: XXX.XXX.XXX.XXX
broadcast_rpc_address: XXX.XXX.XXX.XXX
listen_on_broadcast_address: true
start_rpc: true
rpc_address: XXX.XXX.XXX.XXX
I also needed to restart my Virtual Machine for some reason. ¯_(ツ)_/¯
For a quick single node setup on RHEL, I did the following:
Get info about your network interface setup:
# /sbin/ifconfig -a
It will list the interfaces and the ip addresses they are attached to.
Usually it will show an "Ethernet" interface and a "Local Loopback".
Get the associated ip addresses.
Then edit conf/cassandra.yaml:
rpc_address: [Local Loopback address]
broadcast_rpc_address: [Ethernet address]
listen_address: [Local Loopback address]
broadcast_address: [Ethernet address]
listen_on_broadcast_address: true
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
- seeds: "[Ethernet address]"
Then also, open the correct ports on Linux firewall, being 9042, 7000 and 7001. More info about opening ports on Linux here:
http://ask.xmodulo.com/open-port-firewall-centos-rhel.html
in cassandra.yaml, I update the seed from domain name to IP address. and it works.
Happened to me because in my configuration the "intial_token" settings was specified (I think because I just copied to configuration file over from another cluster member). After clearing the data directory, commenting out the setting and restarting the node, it worked fine for me.
I experienced this error today...
I could not find any reason for the error other than timing issues.
I restarted many times and after a while it sticked. It looks like they expect a bi-directional communication on the gossip channel and if it does not happen quickly enough (which looks like a very small amount of time to me) then they drop the line and generate that error.
In my case I just upgraded my software and restarted the computer. So it was clearly not a connection issue between the computers (I have firewalls and SSL, to complicate matters) and the node was connected before... So the one entry I found in that regard from datastax did not apply...
https://support.datastax.com/hc/en-us/articles/209691483-Bootstap-fails-with-Unable-to-gossip-with-any-seeds-yet-new-node-can-connect-to-seed-nodes
I got the same error. There can be more than one solution. Hope my mistake is what you have done.
I had my localhost IP pointing to some domain name (and I did that in order that my Spring boot application's server context is some domain name like www.example.com:8080 instead of localhost:8080, and I had the following entry in my hosts file on Windows system).
127.0.0.1 www.example.com
While my cassandra batch file was looking for localhost which it didn't find. So, I made another entry for localhost too in my hosts file as:
127.0.0.1 localhost
127.0.0.1 www.example.com
After adding it, I opened new command prompt, ran cassandra batch from the cassandra bin directory and it then worked.
Disable the firewall and SELINUX and try again
In our case ssl was enabled, and cassandra.yaml configuration looks fine as per above comments. Then we enabled ssl debugging by by adding below jvm paramter in cassandra-env.sh -Djavax.net.debug=ssl:handshake
After starting the node again we noticed below in cassandra log file
MessagingService-Outgoing-geo2_host/xx.xx.xx.xx, Exception while
waiting for close javax.net.ssl.SSLHandshakeException: Received fatal
alert: certificate_unknown
After further investigating the ssl debug logs we got to know that the certificate was not valid. After fixing this ssl issue node was able to join the cluster.
Thanks to elvingt
His answer just remind me , I need to verify that all node needs to be able to talk to each other.
https://support.datastax.com/hc/en-us/articles/209691483-Bootstap-fails-with-Unable-to-gossip-with-any-seeds-yet-new-node-can-connect-to-seed-nodes
Gossip communications must be bi-directional.
To verify use this commnd, and you need test from BOTH SIDE
nc -vz {your_node_ip} 7000
Then I recollect that I turned on my ubuntu firewall last night. I open it by
sudo ufw allow 7000/tcp
And it is working now
Getting error during startup/bootstrap
Unable to gossip with any seeds
indicates there is some issue with broadcast_address. broadcast_address is responsible for communication with other nodes not with clients.
This address must be set in seed node(mandatory for seed node), If you are using cloud VMs you might have different IPs(public and private) hence its recommended to use your private IPs for broadcast_address this will save your n/w cost as well.
# Address to broadcast to other Cassandra nodes
# Leaving this blank will set it to the same value as listen_address
broadcast_address: 10.11.xx.xxx
In my scenario I was using IBM and once I set broadcast_address in seed nodes issue got resolved.
Please make sure you are starting your seed node first then other node, this order is mandatory.
in cassandra.yaml
changing listen_address value from localhost to domainName solved my issue
I had same issue, I checked port, used tcpdump, netcat to test connections and finally it comes to expired SSL certificates on internode_encryption. I modified internode_encryption to make it 'none', restarted all nodes and it worked.
Before all neighbor nodes were down. And node repair command was failing with:
"Did not get positive replies from all endpoints"
P.S Dont leave internode_encryption as none for a long time, just regenerate certs and enable it back.

Cassandra - What's the relation between 'start_rpc' and 'rpc_address' in cassandra.yaml

I'm using cassandra 3.6.
The names seem to implying me that I need to enable start_rpc before set rpc_address.
I try disable start_rpc and set rpc_address to my local network address 192.168.201.144 ,my cluster is still working but I need to use CQLSH_HOST=192.168.201.144 apache-cassandra-3.6/bin/cqlsh in order to connect to cassandra.
What's the relation between them?
If you want to start rpc service, you need modify them together:
start_rpc: true
rpc_address: 192.168.XXX.XXX
Rpc_address is the listen address for client connections (Thrift RPC service and native transport).Valid values are:
unset:
Resolves the address using the hostname configuration of the node. If left unset, the hostname must resolve to the IP address of this node using /etc/hostname, /etc/hosts, or DNS.
0.0.0.0:
Listens on all configured interfaces, but you must set the broadcast_rpc_address to a value other than
0.0.0.0.
IP address
hostname

Will the DataStax Cluster class ever refresh IP address from the hostname given to builder.addContactPoint() if DNS changes?

I've a problem, once set host name, cluster wouldn't update it's IP, even in DNS changes.
Or what is the recommended way of making the application resilient to the fact that more nodes can be added to DNS round robin and old nodes decomissioned ?
I had same thing with Astyanax driver. For me it looks like it works this way:
DNS name is used only when initial connection to cluster is created. At this point driver collects data about cluster nodes. This information is kept in terms of IP addresses already and DNS names are not used any more. Sub-sequential changes in the cluster topology are propagated into the client also using IP addresses.
So, when you add more nodes to the cluster, you actually do not have to assign domain names to them. Just adding a node to the cluster propagates its IP address to the cluster topology table and this info is distributed among all cluster members and smart clients like Java Driver (some third party clients might not have this info and will use only seed nodes to pass queries to).
When you decommission node it works same way. Just all cluster nodes and smart clients receive information that node with a particular IP is not in the cluster any more. It can be even initial seed node.
->Domain name makes sense only for clients which hadn't established cluster connection.
In case you really need to switch IP you have to:
Join node with new IP
Decommission node with old IP
Assign DNS name to new IP

How to create a Cassandra node Cluster in Windows7 pcs?

Problem while Creating cluster using cassandra:-
I follow the below steps for creating a Cassandra cluster:-
1.Installed cassandra in 3 Windows-7 PCs.
PC IPAddress-127.0.0.1,127.0.0.2,127.0.0.3
2.Modified the cassandra.yaml file as below.
cluster_name: 'MyCluster'
num_tokens: 256
seed_provider: - seeds: "127.0.0.1"
listen_address: 127.0.0.1,127.0.0.2,127.0.0.3
rpc_address: 0.0.0.0
3.start the Cassandra in all the above 3 PCs.
but I am not getting more than 1 Node in Node tool. I can see only one node.
I have installed datastax-community-64bit_2.0.3
So, Please help me to solve this problem. I need to create Cassandra cluster.
Thanks in Adavance,
Satya
You have follow all the steps for creating cluster,but you have to define firewall inbound rule for allowing the port.(by default these ports are not allowed by firewall).So after modifying the "cassandra.yaml" file,you have to set the port used in cassandra and datastax in your firewall,then start the cassandra service.
For adding port in firewall:
go to control panel->windows firewall->advanced setting->Inbound Rules->new Rule->select port and add all the ports require for the cassandra/datastax. google the require ports for cassandra/datastax.
The 127.x.x.x IP addresses you are using are all loopback device addresses. Traffic sent to those addresses never leaves your localhost. If you want the three hosts to discover each other you need to use IPs from some private IP address range. See this Wikipedia article for an overview. As your Windows workstations are networked, the IP number to use should be obvious from running ipconfig on the command line on each of the three workstations. Look for the output entry IPv4-Adress.

Cassandra unable to contact seeds if using AWS Elastic IP address... only works with private IP address

I created 3 instances with 3 Elastic IP addresses pointing to these instances.
I did a yum install of dsc:
dsc12.noarch 1.2.13-1 #datastax
And the /etc/cassandra/default.conf/cassandra.yaml has the:
- seeds: [Elastic IP list]
But when I start cassandra via "service cassandra start" I see in /var/log/cassandra/cassandra.log:
...
Exception encountered during startup: Unable to contact any seeds!
...
And sure enough "nodetool status" shows:
Failed to connect to '127.0.0.1:7199': Connection refused
BUT:
If I change the value of the seeds to use the "private IP" of the instance, cassandra starts just fine. I would expect it work just fine with the Elastic IP's, but it doesn't.
Do you know why that is?
The reason I want the Elastic IP's to work is that I know the IP address ahead of time, so that when I provision a machine with Puppet, I can pre-populate the seeds in cassandra.yaml file. I don't know the private IP address until after the machine has booted :(
This is almost a duplicate of: Cassandra on Amazon EC2 with Elastic IP addresses
I believe your problem comes from the seed IP's not being the same as the node's Broadcast IP's . To change this modify the following line in each of your Cassandra.yamls
# Address to broadcast to other Cassandra nodes
# Leaving this blank will set it to the same value as listen_address
broadcast_address: <node's elastic ip> #uncomment this line

Resources