nodetool import
Imports SSTables from an external directory into a table.
Synopsis
Section titled “Synopsis”nodetool [connection_options] import [options] <keyspace> <table> <directory>...See connection options for connection options.
Description
Section titled “Description”nodetool import loads SSTables from an external directory into a Cassandra table. Unlike refresh, which requires files to be in the data directory, import can load from any location and optionally moves or copies files.
Available in Cassandra 4.0+.
Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
keyspace | Target keyspace |
table | Target table |
directory | One or more directories containing SSTables to import |
Options
Section titled “Options”| Option | Description |
|---|---|
-c, --no-invalidate-caches | Skip row cache invalidation |
-cd, --copy-data | Copy files instead of moving |
-e, --extended-verify | Extended verification of SSTables |
-k, --keep-level | Keep original SSTable level (for LCS) |
-l, --keep-repaired | Keep repaired status |
-niv, --no-index-validation | Skip index component validation |
-q, --quick | Quick import (less verification) |
-ri, --require-index-components | Require index components to be present |
-t, --no-tokens | Skip token verification |
-v, --no-verify | Skip SSTable verification |
Examples
Section titled “Examples”Basic Import
Section titled “Basic Import”nodetool import my_keyspace my_table /path/to/sstables/Import with Copy (Keep Original)
Section titled “Import with Copy (Keep Original)”nodetool import -cd my_keyspace my_table /backup/sstables/Quick Import (Less Verification)
Section titled “Quick Import (Less Verification)”nodetool import -q my_keyspace my_table /path/to/sstables/Import Keeping LCS Levels
Section titled “Import Keeping LCS Levels”nodetool import -k my_keyspace my_table /path/to/sstables/Extended Verification Import
Section titled “Extended Verification Import”nodetool import -e my_keyspace my_table /path/to/sstables/Import vs Refresh vs SSTableLoader
Section titled “Import vs Refresh vs SSTableLoader”| Feature | import | refresh | sstableloader |
|---|---|---|---|
| External directory | Yes | No | Yes |
| Move/copy files | Yes | No | Streams |
| Token verification | Optional | No | Yes |
| Different topology | No | No | Yes |
| Speed | Fast | Fast | Slower |
Workflow: Restore from Backup
Section titled “Workflow: Restore from Backup”# 1. Extract backup to a directorytar -xzf backup.tar.gz -C /tmp/restore/
# 2. Import SSTablesnodetool import my_keyspace my_table /tmp/restore/my_keyspace/my_table/
# 3. Verifynodetool tablestats my_keyspace.my_tableWorkflow: Bulk Load
Section titled “Workflow: Bulk Load”# 1. Generate SSTables externally (e.g., from Spark)# Files are in /data/generated/my_keyspace/my_table/
# 2. Import to each nodenodetool import my_keyspace my_table /data/generated/my_keyspace/my_table/
# 3. Repair for consistencynodetool repair my_keyspace my_tableDirectory Requirements
Section titled “Directory Requirements”The source directory should contain SSTable files:
/path/to/sstables/├── nb-1-big-Data.db├── nb-1-big-Index.db├── nb-1-big-Filter.db├── nb-1-big-Statistics.db├── nb-1-big-Summary.db├── nb-1-big-TOC.txt└── nb-1-big-CompressionInfo.dbToken Verification
Section titled “Token Verification”By default, import verifies tokens belong to this node:
# Normal import (verifies tokens)nodetool import my_keyspace my_table /path/
# Skip token verification (use carefully)nodetool import -t my_keyspace my_table /path/Token Verification
Skipping token verification (-t) may import data that doesn't belong to this node. Only use when certain about data placement.
File Handling
Section titled “File Handling”Default (Move)
Section titled “Default (Move)”By default, files are moved from source to data directory:
nodetool import my_keyspace my_table /tmp/sstables/# Files moved from /tmp/sstables/ to data directory# Source directory will be empty after importCopy Mode
Section titled “Copy Mode”Use -cd to copy instead of move:
nodetool import -cd my_keyspace my_table /backup/sstables/# Files copied, originals remain in /backup/sstables/Common Issues
Section titled “Common Issues”Permission Denied
Section titled “Permission Denied”# Ensure Cassandra can read source directorychmod -R 755 /path/to/sstables/chown -R cassandra:cassandra /path/to/sstables/Invalid SSTable
Section titled “Invalid SSTable”ERROR: SSTable is not validTry with verification options:
# Extended verification to see detailsnodetool import -e my_keyspace my_table /path/
# Or skip verification (risky)nodetool import -c my_keyspace my_table /path/Token Range Mismatch
Section titled “Token Range Mismatch”ERROR: Token ... is not owned by this nodeEither:
- Import to the correct node
- Use
-vto skip verification (if certain data is correct) - Use
sstableloaderfor different topologies
Post-Import Steps
Section titled “Post-Import Steps”# 1. Verify importnodetool tablestats my_keyspace.my_table
# 2. Check data is queryablecqlsh -e "SELECT COUNT(*) FROM my_keyspace.my_table;"
# 3. Run repair for consistency (recommended for bulk loads)nodetool repair -pr my_keyspace my_tableBest Practices
Section titled “Best Practices”Import Guidelines
- Use copy mode for backups - Keep original files with
-cd - Verify first - Use extended verification for critical data
- Check token ownership - Ensure SSTables belong to this node
- Run repair after - Ensure consistency across replicas
- Monitor space - Ensure sufficient disk for imported data
Related Commands
Section titled “Related Commands”| Command | Relationship |
|---|---|
| refresh | Load SSTables from data directory |
| snapshot | Create backups |
| tablestats | Verify after import |
| repair | Run after bulk imports |