Sitemap

Member-only story

Migrate a Cassandra Keyspace to a New Cluster

2 min readApr 16, 2025

--

Press enter or click to view image in full size
Created by Meta AI

I need to migrate a Cassandra keyspace’s data from a existing cluster to a new cluster. Both cluster are part of a commercial off-the-shell which have the same Cassandra version and schema.

The nodetool from Cassandra will help us to migrate the data from one cluster to the cluster.

1. Take snapshots

On the source Cassandra cluster, take a snapshot of each node.

nodetool snapshot -t {{.snapshotName }} {{.keyspace }} 

You may stop the client to send data into the DB before that. I have the following magefile tasks to take the snapshot concurrently on the 3 nodes of the cassandra cluster.

func (Backup) T01_take_snapshot() {
g := errgroup.Group{}
for i := range 3 {
cmd := quote.CmdTemplate(`
oc exec -i {{ .name }}-topology-cassandra-{{ .i }} -- nodetool snapshot -t {{.snapshotName }} {{.keyspace }}
`, map[string]string{
"snapshotName": get_snapshot_name(),
"keyspace": "janusgraph",
"i": fmt.Sprintf("%d", i),
"name": "aiops",
})
g.Go(func() error {
return bastion().Execute(cmd)
})
}
g.Wait()
}

The snapshot will then be created into the cassandra data filesystem, in the format of below

{{ .dataDir }}/{{ .keyspace }}/{{ .table…

--

--