LoginSignup
3
4

More than 5 years have passed since last update.

Apache HBaseを、StandAloneモードで動かしてみた

Last updated at Posted at 2016-03-01

Apache HBase Reference GuideのQuickStartを試してみた
ちなみに、StandAloneモードだと、
In standalone mode, HBase does not use HDFS -- it uses the local filesystem instead -- and it runs all HBase daemons and a local ZooKeeper all up in the same JVM. Zookeeper binds to a well known port so clients may talk to HBase.
とのことです。

⬛︎ HBase環境構築

  • JDK環境をインストールし、JAVA_HOME環境変数にセットする
$ sudo apt-get install default-jdk
$ sudo update-alternatives --list java
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java

$ cd $HOME
$ vi .profile
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
  • ZooKeeperをインストールして、起動する
$ wget http://apache.arvixe.com/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
$ sudo tar -C /opt -xzf zookeeper-3.4.6.tar.gz
$ cd /opt/zookeeper-3.4.6/conf
$ cp zoo_sample.cfg zoo.cfg

$ cd $HOME
$ vi .profile
export PATH=/opt/zookeeper-3.4.6/bin:$PATH

$ source .profile 
$ zkServer.sh start
  • HBaseをインストールする
$ wget http://www.apache.org/dist/hbase/hbase-0.94.27/hbase-0.94.27.tar.gz
$ tar xfz hbase-0.94.27.tar.gz
$ cd hbase-0.94.27/
$ vi conf/hbase-site.xml 
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>file:///tmp/hbase-${user.name}/hbase</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/tmp/zookeeper</value>
  </property>
  <property>
    <name>hbase.zookeeper.quorum</name>
    <value>localhost</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.clientPort</name>
    <value>2182</value>
  </property>
</configuration>
  • HBaseを起動する
$ ./bin/start-hbase.sh 
starting master, logging to /home/tsubo/hbase-0.94.27/bin/../logs/hbase-tsubo-master-HBase.out
  • HBaseのマスタ状態を確認する

Webブラウザから、http://localhost:60010/ にアクセスして、HBaseのマスタ状態を確認する
HBase-ui.png

⬛︎ HBaseを使ってみる

  • HBase Shellを起動する
$ ./bin/hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 0.94.27, rfb434617716493eac82b55180b0bbd653beb90bf, Thu Mar 19 06:17:55 UTC 2015

hbase(main):001:0> 
  • “cf”というカラムファミリーで、“test”テーブルを作成する
hbase(main):002:0* create 'test', 'cf'
0 row(s) in 0.9600 seconds

hbase(main):003:0> list
TABLE                                                                                                                                                 
test                                                                                                                                                  
1 row(s) in 0.0160 seconds
  • “test”テーブルに、行を挿入する
hbase(main):006:0* put 'test', 'row1', 'cf:a', 'value1'
0 row(s) in 0.0820 seconds

hbase(main):007:0> put 'test', 'row2', 'cf:b', 'value2'
0 row(s) in 0.0070 seconds

hbase(main):008:0> put 'test', 'row3', 'cf:c', 'value3'
0 row(s) in 0.0050 seconds

hbase(main):009:0> scan 'test'
ROW                                    COLUMN+CELL                                                                                                    
 row1                                  column=cf:a, timestamp=1456846418547, value=value1                                                             
 row2                                  column=cf:b, timestamp=1456846430155, value=value2                                                             
 row3                                  column=cf:c, timestamp=1456846438103, value=value3                                                             
3 row(s) in 0.0510 seconds
  • “test”テーブルを削除する
hbase(main):011:0> disable 'test'
0 row(s) in 1.1120 seconds

hbase(main):012:0> drop 'test'
0 row(s) in 1.0600 seconds

hbase(main):013:0> exit
  • HBaseを停止する
$ ./bin/stop-hbase.sh
stopping hbase...............

以上

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4