Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shell script for executing hbase commands - Deleting all hbase tables

Tags:

shell

hbase

I want to delete all tables in HBase. I am using HBase shell commands for doing this operation:

$ hbase shell
 > disable_all .*
 > drop_all .*

How can i write a shell script for doing this operations ?

Note: While executing above commands, it asks for the user confirmation i.e y/n before disabling and dropping all tables.

like image 334
Vrushank Doshi Avatar asked Jun 29 '15 21:06

Vrushank Doshi


People also ask

Which command can be used to delete data from HBase table?

Deleting All Cells in a Table. Using the “deleteall” command, you can delete all the cells in a row. Given below is the syntax of deleteall command.

How do I run a HBase command from the shell?

To access the HBase shell, you have to navigate to the HBase home folder. You can start the HBase interactive shell using “hbase shell” command as shown below. If you have successfully installed HBase in your system, then it gives you the HBase shell prompt as shown below.

How do I get out of HBase shell?

A column qualifier identifies a single column within a column family. There can be multiple time-stamped cells at the intersection of a row and column. Type exit and press Enter to exit the HBase shell.


1 Answers

I use the following:

#!/bin/sh
echo -e "disable_all '.*'\ny" | hbase shell -n
echo -e "drop_all '.*'\ny" | hbase shell -n

The -e flag to echo causes it to process escape sequences so you can build the confirmation into it. The -n tells hbase shell this is a non-interactive session.

like image 115
Martin Serrano Avatar answered Nov 08 '22 19:11

Martin Serrano