Hbase-shutting-down

提供:Dev Guides
移動先:案内検索

HBase-シャットダウン

exit

*exit* コマンドを入力して、シェルを終了します。
hbase(main):021:0> exit

HBaseを停止する

HBaseを停止するには、HBaseホームフォルダーを参照し、次のコマンドを入力します。

./bin/stop-hbase.sh

Java APIを使用したHBaseの停止

*HBaseAdmin* クラスの* shutdown()*メソッドを使用して、HBaseをシャットダウンできます。 以下の手順に従って、HBaseをシャットダウンします。

ステップ1

HbaseAdminクラスをインスタンス化します。

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

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

ステップ2

*HBaseAdmin* クラスの* shutdown()*メソッドを使用してHBaseをシャットダウンします。
admin.shutdown();

以下に、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();
   }
}

以下に示すように、上記のプログラムをコンパイルして実行します。

$javac ShutDownHbase.java
$java ShutDownHbase

出力は次のようになります。

Shutting down hbase