How to generate a new hostid for a Cassandra node.

If you clone a Cassandra VM with the goal of creating a cassandra cluster – you may find that every Cassandra node has the same hostID.

Steps to generate a new hostid:

  • stop cassandra
  • remove files from /var/lib/cassandra/data/system ; rm -rf /var/lib/cassandra/*
  • restart cassandra

Example

$ nodetool status
 Datacenter: datacenter1
 Status=Up/Down
 |/ State=Normal/Leaving/Joining/Moving
 --  Address    Load        Tokens  Owns (effective)  Host ID                               Rack
 UN  127.0.0.1  224.75 KiB  16      100.0%            e83be842-a05e-4acb-9c92-0f18fb3690be  rack1

$ sudo service cassandra stop; sudo rm -rf /var/lib/cassandra/data/system ; sudo  rm -rf /var/lib/cassandra/*; sudo service cassandra start


$ nodetool status
 Datacenter: datacenter1
 Status=Up/Down
 |/ State=Normal/Leaving/Joining/Moving
 --  Address    Load        Tokens  Owns (effective)  Host ID                               Rack
 UN  127.0.0.1  164.49 KiB  16      100.0%            b93fd004-0679-46b6-be75-81da2850f07b  rack1

Leave a Comment