You exit the shell by typing the exit command.
hbase(main):021:0> exit
To stop HBase, browse to the HBase home folder and type the following command.
./bin/stop-hbase.sh
You can shut down the HBase using the shutdown() method of the HBaseAdmin class. Follow the steps given below to shut down HBase:
Instantiate the HbaseAdmin class.
// Instantiating configuration object Configuration conf = HBaseConfiguration.create(); // Instantiating HBaseAdmin object HBaseAdmin admin = new HBaseAdmin(conf);
Shut down the HBase using the shutdown() method of the HBaseAdmin class.
admin.shutdown();
Given below is the program to stop the HBase.
import java.io.IOException; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.client.HBaseAdmin; public class ShutDownHbase{ public static void main(String args[])throws IOException { // Instantiating configuration class Configuration conf = HBaseConfiguration.create(); // Instantiating HBaseAdmin class HBaseAdmin admin = new HBaseAdmin(conf); // Shutting down HBase System.out.println("Shutting down hbase"); admin.shutdown(); } }
Compile and execute the above program as shown below.
$javac ShutDownHbase.java $java ShutDownHbase
The following should be the output:
Shutting down hbase