Skip to content

AxonOps — AI-Native Control Plane for Open Source Data Platforms

nodetool rebuild

Rebuilds data on a node by streaming from other datacenters, used when adding nodes to a new datacenter.


Terminal window
nodetool [connection_options] rebuild [options] [source_datacenter]

See connection options for connection options.

nodetool rebuild streams all data that belongs to this node from another datacenter. This is used when:

  • Adding nodes to a new datacenter
  • Recovering a node without using bootstrap
  • Repopulating a datacenter after total loss

Unlike bootstrap, rebuild does not require the node to be in JOINING state and can be run on a node that's already part of the ring.

Rebuild Streams from One Replica Only

The rebuild command streams data from a single replica for each token range, not from all replicas. This means:

  • Data may be inconsistent if the source replica was not fully up-to-date
  • Deleted data (tombstones) that only existed on other replicas will not be streamed
  • The rebuilt node may have stale or missing data

Always run nodetool repair after rebuild completes to ensure full consistency with all replicas. The recommended workflow is:

  1. Run rebuild to quickly populate the node with data
  2. Run repair to synchronize with all replicas and resolve inconsistencies

This two-step approach is faster than repair alone for large datasets, as rebuild streams entire SSTables while repair performs merkle tree comparisons.


ArgumentDescription
source_datacenterDatacenter to stream data from. If omitted, streams from all DCs

OptionDescription
-ks, --keyspaceSpecific keyspace to rebuild
-ts, --tokensSpecific token ranges to rebuild
-s, --sourcesSpecific source nodes to stream from
--exclude-local-dcExclude sources from the local datacenter

When expanding to a new datacenter:

Terminal window
# Step 1: Configure nodes in new DC
# Step 2: Update keyspace RF to include new DC
ALTER KEYSPACE my_keyspace WITH replication = {
'class': 'NetworkTopologyStrategy',
'dc1': 3,
'dc2': 3 -- New DC
};
# Step 3: On each node in new DC, rebuild from existing DC
nodetool rebuild dc1

If a node lost data but is still in the ring:

Terminal window
nodetool rebuild

Not a Substitute for Repair

Rebuild streams data from other DCs. For single-DC clusters or to sync from same-DC replicas, use nodetool repair instead.

After recovering all nodes in a datacenter that was completely down:

Terminal window
# On each recovered node
nodetool rebuild <source_dc>

Single-DC Considerations

By default, rebuild can stream from any datacenter including the local one. However, for single-DC clusters where rebuild would stream from the same replicas as repair, using nodetool repair is typically more appropriate:

Terminal window
# Use repair for single-DC consistency
nodetool repair -pr

Use --exclude-local-dc if sources from the local datacenter should not be used.

When adding nodes to an existing DC, use bootstrap (normal node startup) instead:

Terminal window
# Just start the node - bootstrap happens automatically
sudo systemctl start cassandra

Don't run rebuild on a node that's currently bootstrapping.


  1. New DC node calculates token ranges to receive
  2. New DC node requests data from Source DC nodes
  3. Source DC nodes stream SSTables to new DC node
  4. Once all data is received, new DC node resumes normal operations

Rebuild Behavior

The node streams data for ALL token ranges it owns from the source datacenter.


Terminal window
nodetool rebuild dc1

Streams all data this node should own from dc1.

Terminal window
nodetool rebuild -ks my_keyspace dc1
Terminal window
nodetool rebuild

Streams from all available datacenters.

Terminal window
# Watch streaming progress
nodetool netstats

Terminal window
# 1. Add nodes to new DC (don't start Cassandra yet)
# 2. Configure cassandra.yaml on new nodes:
# - Same cluster_name
# - Different dc/rack in GossipingPropertyFileSnitch
# 3. Start first node in new DC
sudo systemctl start cassandra
# 4. Update keyspace replication
ALTER KEYSPACE my_keyspace WITH replication = {
'class': 'NetworkTopologyStrategy',
'dc1': 3,
'dc2': 3
};
# 5. Rebuild on first node
nodetool rebuild dc1
# 6. Start remaining nodes in new DC one at a time
# 7. Run rebuild on each after it joins
Terminal window
# Check node status
nodetool status
# Verify data
nodetool tablestats my_keyspace | grep "Space used"
# Run repair to ensure consistency
nodetool repair -pr

Terminal window
# Streaming progress
nodetool netstats
# Thread pool activity
nodetool tpstats | grep -i stream
Data SizeNetworkApproximate Time
100 GB1 Gbps15-30 minutes
500 GB1 Gbps1-2 hours
1 TB1 Gbps3-5 hours
1 TB10 Gbps30-60 minutes
Terminal window
tail -f /var/log/cassandra/system.log | grep -i rebuild

ERROR: No such datacenter: dc2

The specified datacenter doesn't exist:

Terminal window
# Check available DCs
nodetool status

If rebuild doesn't progress:

  1. Check streaming:

    Terminal window
    nodetool netstats
  2. Check source nodes are healthy:

    Terminal window
    ssh <source_node> "nodetool status"
  3. Check network connectivity between DCs

  4. Check throughput settings:

    Terminal window
    nodetool getstreamthroughput
    nodetool getinterdcstreamthroughput

Rebuild requires space for incoming data:

Terminal window
# Check disk space
df -h /var/lib/cassandra
# May need to clear old data or add storage

If rebuild fails partway through:

  1. Check logs for error cause
  2. Fix the issue
  3. Restart rebuild (it will re-stream needed data)

OperationUse Case
rebuildStream from other DCs to populate data
repairSync data between replicas
bootstrapNew node joining cluster for first time
removenodeRemove dead node from cluster
AspectBootstrapRebuild
WhenNew node joiningExisting node needs data
Auto-triggerOn first startManual command
StateJOININGNORMAL
SourceSame DC (primary)Other DCs

Control rebuild speed:

Terminal window
# Check current settings
nodetool getstreamthroughput
nodetool getinterdcstreamthroughput
# Increase for faster rebuild
nodetool setstreamthroughput 400
nodetool setinterdcstreamthroughput 100

Source DC Load

Rebuild reads from source DC nodes, impacting their performance:

  • Run during off-peak hours
  • Consider throttling
  • Monitor source DC latencies

Rebuild Guidelines

  1. Plan for duration - Large datasets take hours
  2. Off-peak timing - Reduce impact on production
  3. One node at a time - Minimize cluster impact
  4. Monitor progress - Watch netstats continuously
  5. Verify afterward - Check tablestats and run repair
  6. Consider throttling - Balance speed vs. impact

CommandRelationship
repairSync replicas within/across DCs
netstatsMonitor streaming progress
statusCheck node/DC status
setstreamthroughputControl streaming speed