English 中文(简体)
HBase - Shutting Down
  • 时间:2024-12-22

HBase - Shutting Down


Previous Page Next Page  

exit

You exit the shell by typing the exit command.

hbase(main):021:0> exit

Stopping HBase

To stop HBase, browse to the HBase home folder and type the following command.

./bin/stop-hbase.sh

Stopping HBase Using Java API

You can shut down the HBase using the shutdown() method of the HBaseAdmin class. Follow the steps given below to shut down HBase:

Step 1

Instantiate the HbaseAdmin class.

// Instantiating configuration object
Configuration conf = HBaseConfiguration.create();

// Instantiating HBaseAdmin object
HBaseAdmin admin = new HBaseAdmin(conf);

Step 2

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.cpent.HBaseAdmin;

pubpc class ShutDownHbase{

   pubpc 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
Advertisements