nodetool refresh
Deprecated in Cassandra 4.0+
nodetool refresh is deprecated since Cassandra 4.0. Use nodetool import instead, which provides more options including the ability to import from external directories.
Loads newly placed SSTables into a running node without restart.
Synopsis
Section titled “Synopsis”nodetool [connection_options] refresh <keyspace> <table>See connection options for connection options.
Description
Section titled “Description”nodetool refresh scans a table's data directory for new SSTable files and loads them into the running Cassandra process. This is useful for bulk loading data or restoring from backups without restarting the node.
Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
keyspace | The keyspace containing the table |
table | The table to refresh |
When to Use
Section titled “When to Use”Bulk Loading Data
Section titled “Bulk Loading Data”After copying SSTables from another source:
# 1. Copy SSTables to data directorycp /backup/nb-*.db /var/lib/cassandra/data/my_keyspace/my_table-uuid/
# 2. Load them into Cassandranodetool refresh my_keyspace my_tableRestore from Backup
Section titled “Restore from Backup”# 1. Copy snapshot filescp /snapshots/backup_name/*.db /var/lib/cassandra/data/my_keyspace/my_table-uuid/
# 2. Refresh to loadnodetool refresh my_keyspace my_tableSSTableLoader Alternative
Section titled “SSTableLoader Alternative”For loading SSTables generated on the same cluster topology:
# Simpler than sstableloader when topology matchesnodetool refresh my_keyspace my_tableExamples
Section titled “Examples”Refresh Single Table
Section titled “Refresh Single Table”nodetool refresh my_keyspace my_tableBulk Load Workflow
Section titled “Bulk Load Workflow”#!/bin/bashKEYSPACE="my_keyspace"TABLE="my_table"DATA_DIR="/var/lib/cassandra/data/$KEYSPACE"TABLE_DIR=$(ls -d $DATA_DIR/${TABLE}-* 2>/dev/null | head -1)
# Copy SSTablescp /source/sstables/*.db "$TABLE_DIR/"cp /source/sstables/*.txt "$TABLE_DIR/"
# Load into Cassandranodetool refresh $KEYSPACE $TABLE
echo "Loaded SSTables into $KEYSPACE.$TABLE"Prerequisites
Section titled “Prerequisites”SSTable Compatibility
Section titled “SSTable Compatibility”Version Match Required
SSTables must be compatible with the running Cassandra version:
- Same or older SSTable format version
- If older, consider running
upgradesstablesafter refresh
File Location
Section titled “File Location”SSTables must be placed in the correct data directory:
/var/lib/cassandra/data/<keyspace>/<table>-<uuid>/Required Files
Section titled “Required Files”A complete SSTable includes multiple files:
nb-1-big-Data.dbnb-1-big-Index.dbnb-1-big-Filter.dbnb-1-big-Statistics.dbnb-1-big-Summary.dbnb-1-big-TOC.txtnb-1-big-CompressionInfo.db # If compressedAll files for an SSTable must be present.
Process Flow
Section titled “Process Flow”- Cassandra scans the table directory for new SSTables
- Validates SSTable format and compatibility
- Loads SSTable metadata into memory
- Makes data available for queries
- SSTables become part of normal compaction cycle
Refresh vs Import
Section titled “Refresh vs Import”| Aspect | refresh | import |
|---|---|---|
| Location | Must be in data directory | Can be from external directory |
| File handling | Files stay in place | Files can be moved or copied |
| Use case | Quick load | External bulk import |
Common Issues
Section titled “Common Issues”"Unknown SSTable"
Section titled “"Unknown SSTable"”If SSTables are from a different cluster or schema version:
# May need to use sstableloader insteadsstableloader -d localhost /path/to/sstables/Missing Files
Section titled “Missing Files”ERROR: Missing component Data.dbEnsure all SSTable component files are present.
Permission Errors
Section titled “Permission Errors”# Fix ownershipchown -R cassandra:cassandra /var/lib/cassandra/data/my_keyspace/my_table-*/
# Then refreshnodetool refresh my_keyspace my_tableWrong Directory
Section titled “Wrong Directory”Verify the table UUID directory:
# Find correct directoryls -la /var/lib/cassandra/data/my_keyspace/ | grep my_tableVerification
Section titled “Verification”After Refresh
Section titled “After Refresh”# Verify data is visiblenodetool tablestats my_keyspace.my_table
# Query the datacqlsh -e "SELECT COUNT(*) FROM my_keyspace.my_table;"Check Logs
Section titled “Check Logs”tail -f /var/log/cassandra/system.log | grep -i refreshBest Practices
Section titled “Best Practices”Refresh Guidelines
- Validate SSTables first - Check compatibility before copying
- Use correct permissions - cassandra:cassandra ownership
- Copy all files - Include all SSTable components
- Monitor after refresh - Check for errors in logs
- Consider repair - Run repair after bulk load for consistency
Alternative: sstableloader
Section titled “Alternative: sstableloader”For loading SSTables to a different cluster or when topology differs:
sstableloader -d node1,node2,node3 /path/to/sstables/sstableloader is more flexible but slower than refresh.
Related Commands
Section titled “Related Commands”| Command | Relationship |
|---|---|
| import | Import SSTables from external location |
| tablestats | Verify table after refresh |
| upgradesstables | Upgrade SSTable format if needed |
| snapshot | Create backups to restore later |