Cassandra bulk loader

The Cassandra bulk loader, also called the sstableloader tool, provides the ability to bulk load external data into a cluster, load existing SSTables into another cluster with a different number nodes or replication strategy, and restore snapshots.

The Cassandra bulk loader, also called the sstableloader tool, provides the ability to bulk load external data into a cluster, load existing SSTables into another cluster with a different number nodes or replication strategy, and restore snapshots.

The sstableloader tool streams a set of SSTable data files to a live cluster. It does not simply copy the set of SSTables to every node, but transfers the relevant part of the data to each node, conforming to the replication strategy of the cluster. The table into which the data is loaded does not need to be empty.

Because sstableloader uses Cassandra gossip, make sure of the following:

  • The cassandra.yaml configuration file is in the classpath and set to communicate with the cluster.
  • At least one node in the cluster is configured as seed.
  • In the cassandra.yaml file, the following properties are properly configured for the cluster that you are importing into:

If you use sstableloader to load external data, you must first generate SSTables. If you use DataStax Enterprise, you can use Sqoop to migrate your data or if you use Cassandra, follow the procedure described in Using the Cassandra Bulk Loader blog.

Before loading the data, you must define the schema of the column families with CQL, CLI, or Thrift.

To get the best throughput from SSTable loading, you can use multiple instances of sstableloader to stream across multiple machines. No hard limit exists on the number of SSTables that sstablerloader can run at the same time, so you can add additional loaders until you see no further improvement.

If you use sstableloader on the same machine as the Cassandra node, you can't use the same network interface as the Cassandra node. However, you can use the JMX StorageService > bulkload() call from that node. This method takes the absolute path to the directory where the SSTables are located, and loads them just as sstableloader does. However, because the node is both source and destination for the streaming, it increases the load on that node. This means that you should load data from machines that are not Cassandra nodes when loading into a live cluster.

The sstableloader bulk loads the SSTables found in the keyspace directory to the configured target cluster.

Packaged installs:

$ sstableloader [options] path_to_keyspace

Tarball installs:

$ cd install_location/bin
$ sstableloader [options] path_to_keyspace
For example:
  1. Go to the location of the SSTables:
    $ cd /var/lib/cassandra/data/Keyspace1/Standard1/
  2. To view the contents of the keyspace:
    $ ls 
    
    Keyspace1-Standard1-jb-60-CRC.db
    Keyspace1-Standard1-jb-60-Data.db
    ...
    Keyspace1-Standard1-jb-60-TOC.txt
  3. To bulk load the files, specify the path to Keyspace1/Standard1/ in the target cluster:
    $ sstableloader -d 110.82.155.1 /var/lib/cassandra/data/Keyspace1/Standard1/ ##  package installation
    
    $ install_location/bin/sstableloader -d 110.82.155.1 /var/lib/cassandra/data/Keyspace1/Standard1/ ## tarball installation

    This bulk loads all the files.

sstableloader
Short option Long option Description
-d <initial hosts> --nodes <initial hosts> Connect to comma separated list of hosts for initial ring information.
  -debug Display stack traces.
-h --help Display help.
-i <NODES> --ignore <NODES> Do not stream to this comma separated list of nodes.
  --no-progress Do not display progress.
-p <rpc port> --port <rpc port> RPC port (default 9160).
-t <throttle> --throttle <throttle> Throttle speed in Mbits (default unlimited).
-v --verbose Verbose output.

Related topics

The cassandra.yaml configuration file