Database Reference
In-Depth Information
4.
To delete some data that we can restore, let's first truncate the users
table:
truncate users;
5.
With step 4, we have truncated the data, so let's try to invoke data res-
toration. With Cassandra there are multiple ways to initiate restora-
tion. First, let's explore restoration using the sstableloader util-
ity. To begin, we need to copy all .db files in the Snapshot direct-
ory into a folder which should be in sync with the database schema,
meaning keyspace/tablename. Here in our case it should be the
users folder users under twitter ( /home/vivek/twitter/
users ).
6.
Next, let's execute the sstableloader utility for restoration:
$CASSANDRA_HOME/bin/sstableloader -d
localhost /home/vivek/twitter/users
Here /home/vivek/twitter/users is the local folder con-
taining all the backed up .db files. One point worth mentioning is
that this snapshot data can also be used for batch analytics using Ha-
doop MapReduce jobs. You can plug in a custom record reader imple-
mentation using org.apache.cassandra.db.OnDiskAtom
and
org.apache.cassandra.io.sstable.SSTableIdentityIterator .
Upon running the preceding command you see the following output
on the console:
Established connection to initial hosts
Opening sstables and calculating sections to
stream
Streaming relevant part of /home/vivek/vivek/
twitter/users/twitter-users-jb-1-Data.db to
[/127.0.0.1, /127.0.0.2, /127.0.0.3]
progress: [/127.0.0.2 1/1 (100%)] [/127.0.0.3
1/1 (100%)] [total: 100% - 0MB/s (avg: 0MB/s)]
Search WWH ::




Custom Search