Troubleshooting cassandra: Saved cluster name XXXX != configured name YYYY

If at anytime you can’t start cassandra, and the logfile show this error:

INFO [SSTableBatchOpen:3] 2012-10-31 16:51:35,669 (line 153) Opening /cassandra/data/system/LocationInfo-hd-56 (696 bytes)
ERROR [main] 2012-10-31 16:51:35,717 (line 173) Fatal exception during initialization
org.apache.cassandra.config.ConfigurationException: Saved cluster name XXXX != configured name YYYY
at org.apache.cassandra.db.SystemTable.checkHealth(
at org.apache.cassandra.service.AbstractCassandraDaemon.setup(
at org.apache.cassandra.service.AbstractCassandraDaemon.activate(
at org.apache.cassandra.thrift.CassandraDaemon.main(

The problem is a mismatch between the cluster name in the config file ($CASSANDRA_HOME/conf/cassandra.yaml) and the value LocationInfo[utf8(‘L’)][utf8(‘ClusterName’)] inside the database. To fix this we must either change one or the other.

Changing the config file is obvious, but if we want to change the other one, you need cassandra-cli:

$CASSANDRA_HOME/bin/cassandra-cli -h localhost
use system;
set LocationInfo[utf8('L')][utf8('ClusterName')]=utf8('');

This can happen when we are trying to move data from a cluster to another (moving from a production environment to a non-production, for instance), or simply if we want to change cassandra cluster name, for whatever reason.



I'll make something up