Home

Awesome

Cassandra Data Copy Tool

This simple java based tool copies data from a live cassandra table to another. The source and destination tables do not need to be on the same cluster or keyspace. All you need to ensure is that the destination table is compatible with the source table.

How to use it

Build

The project requires:

Once you've got your environment setup run from the project directory.

mvn package

This builds a jar in ./target/cassandra-data-copy-tool-<VERSION>-SNAPSHOT.jar"

Configuration

To configure the tool you'll need to create a properties file. Here's an example:

copy.tables=table1,table2,table3=>other_table4,...,tableN
copy.ignoreColumns=tab1e1.columnX,table2.columnY
copy.batchSize=20000
copy.queryPageSize=1000
copy.batchesPerSecond=1

source.cassandra.contactPoints=127.0.0.1
source.cassandra.port=9142
source.cassandra.keyspace=test_keyspace
source.cassandra.username=cassandra
source.cassandra.password=cassandra

destination.cassandra.contactPoints=127.0.0.1
destination.cassandra.port=9142
destination.cassandra.keyspace=test_keyspace
destination.cassandra.username=cassandra
destination.cassandra.password=cassandra

Properties

There are three configuration groups:

Copy
Property NameDescriptionDefault Value
copy.tablesA column delimited list of table names to copy. If the table names don't match between source and destination use source_table=>dest_table""
copy.ignoreColumnsA comma delimited list of columns from the source to ignore. Format is TABLE_NAME.COLUMN_NAME""
copy.batchSizeSize of batches to insert into destination database.20000
copy.queryPageSizeSize of pages as read from source1000
copy.batchesPerSecondMaximum rate of batches copied per second1
Source
Property NameDescriptionDefault Value
source.cassandra.contactPointsComma delimited list of source cluster's contact points127.0.0.1
source.cassandra.portSource cluster's port9142
source.cassandra.keyspaceSource keyspace name""
source.cassandra.usernameSource usernamecassandra
source.cassandra.passwordSource plaintext passwordcassandra
Destination
Property NameDescriptionDefault Value
destination.cassandra.contactPointsComma delimited list of destination cluster's contact points127.0.0.1
destination.cassandra.portDestination cluster's port9142
destination.cassandra.keyspaceDestination keyspace name""
destination.cassandra.usernameDestination usernamecassandra
destination.cassandra.passwordDestination plaintext passwordcassandra

Run

Once you have your property file ready, simply run:

java -jar cassandra-data-copy-tool-<VERSION>-SNAPSHOT.jar --spring.config.location=/path/to/config.properties