Backing up cassandra using nodetool

I am using Cassandra on Ubuntu 14.04. From the documentation, I could see the command being executed:

nodetool snapshot <keyspace name> 

creates a snapshot of my keyspace.

Command output:

 nodetool snapshot my_keyspace Requested creating snapshot(s) for [my_keyspace] with snapshot name [1455455429118] Snapshot directory: 1455455429118 

In accordance with the documents, snapshots must be present in the directories:

 /var/lib/cassandra/data/my_keyspace/<table names>/snapshots/1455455429118 

However, there is some hash value at the end of the table name.

I'm not sure where it came from, and also not sure if this value will always be the same or not. For example, the table name is user_agents, the snapshot directory:

 /var/lib/cassandra/data/my_keyspace/user_agents-147c8cc0d31c11e5aacb3b02dd594b59/snapshots/1455455429118 

I'm not sure what represents <<24>.

I am trying to automate this process, and if I do not know about this random hash value, I won’t be able to find out which directory to select. Is there a way to disable this or decrypt it from the output of the nodetool command?

+5
source share
1 answer

From the documentation.

Take snapshot

Snapshots are taken as node using the nodetool snapshot command. To take a global snapshot, run the nodetool snapshot command using a parallel ssh utility, such as pssh.

The snapshot first flushes all the records in the memory to disk, and then makes a hard link of the SSTable files for each key space. You should have enough free disk space for the node to host snapshots of your date files. One snapshot requires a small amount of disk space. However, snapshots can cause your disk to grow rapidly over time because the snapshot prevents older obsolete data files from being deleted. After the snapshot is completed, you can move the backup files to another location if necessary, or you can leave them in place.

Run the nodetool snapshot command with the host name, JMX port, and key space.

 $ nodetool -h localhost -p 7199 snapshot mykeyspace 

A snapshot is created in the data_directory_location/keyspace_name/table_name/snapshots/snapshot_name directory. Each snapshot directory contains many .db files that contain data during the snapshot.

Cassandra takes a node before taking a snapshot, takes snapshots and saves the data in the snapshot directory of each keypace in the data directory. If you do not specify a snapshot directory name using the -t option, Cassandra names the directory using a snapshot timestamp, for example 1391460334889. Follow the procedure for a snapshot before updating Cassandra. when updated, back up all key areas. For more information on snapshots, see the Apache Documentation .

If you did not provide a snapshot name, Cassandra writes snapshot directories using the snapshot timestamp . If there is no data in the key space, empty directories are not created.

Example: snapshot of one table

Take a snapshot of only the playlist tables in the music key space. On Linux, in the Cassandra bin directory, for example:

 $ ./nodetool snapshot -cf playlists music Requested creating snapshot(s) for [music] with snapshot name [1391461910600] Snapshot directory: 1391461910600 

Cassandra creates a snapshot directory named 1391461910600 that contains the backup data of the playlist table in

 /var/lib/cassandra/data/music/playlists-bf8118508cfd11e3972273ded3cb6170/snapshots nodetool <options> snapshot ( ( -cf <table> | --column-family <table> ) ( -t <tag> | --tag <tag> ) -- ( <keyspace> ) | ( <keyspace> ... ) ) 
  • :

  • ( -h | --host ) |

  • ( -p | --port )
  • ( -pw | --password )
  • ( -u | --username )

  • -cf or --column-family followed by the name of the table to back up.

  • -t or --tag followed by the name of the snapshot.

  • - Separates a parameter and an argument that may be mistaken for a parameter.

  • keyspace is the one key name that is required when using the -cf option or one or more additional key names separated by a space.

UPDATE ::

 /var/lib/cassandra/data/music/playlists-bf8118508cfd11e3972273ded3cb6170/snapshots 

Here in playlists-bf8118508cfd11e3972273ded3cb6170 , - bf8118508cfd11e3972273ded3cb6170 UUID


Thus, it is generated in this way. Ad There are some options for monitoring recorded sstables and phased backup of these files.

Check out tablesnap and cassandra snapshotter .

+1
source

Source: https://habr.com/ru/post/1242980/


All Articles