• hbase »
  • 快速体验HBase

快速体验HBase

standalone运行hbase

下载,并解压

# wget http://mirror.reverse.net/pub/apache/hbase/2.0.0/hbase-2.0.0-bin.tar.gz
# tar xzvf hbase-2.0.0-bin.tar.gz -C /opt
# cd /opt/hbase-2.0.0/

配置

# vi conf/hbase-site.xml

  
    hbase.rootdir
    file:///Users/wingyiu/data/hbase
  
  
    hbase.zookeeper.property.dataDir
    /Users/wingyiu/data/zookeeper
  
  
    hbase.unsafe.stream.capability.enforce
    false
    
      Controls whether HBase will check for stream capabilities (hflush/hsync).

      Disable this if you intend to run on LocalFileSystem, denoted by a rootdir
      with the 'file://' scheme, but be mindful of the NOTE below.

      WARNING: Setting this to false blinds you to potential data loss and
      inconsistent system state in the event of process and/or node failures. If
      HBase is complaining of an inability to use hsync or hflush it's most
      likely not a false positive.
    
  

启动

# bin/start-hbase.sh
# jps
22660 HMaster
22681 Jps

访问Hbase Web UI,在浏览器打开http://localhost:16010
huaban (9)

命令客户端Shell体验

连接

$ ./bin/hbase shell
hbase(main):001:0>

创建table和列族

hbase(main):001:0> create 'test', 'cf'
0 row(s) in 0.4170 seconds

=> Hbase::Table - test

hbase(main):002:0> list 'test'
TABLE
test
1 row(s) in 0.0180 seconds

=> ["test"]

插入Row

hbase(main):003:0> put 'test', 'row1', 'cf:a', 'value1'
0 row(s) in 0.0850 seconds

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

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

遍历表

hbase(main):006:0> scan 'test'
ROW                                      COLUMN+CELL
 row1                                    column=cf:a, timestamp=1421762485768, value=value1
 row2                                    column=cf:b, timestamp=1421762491785, value=value2
 row3                                    column=cf:c, timestamp=1421762496210, value=value3
3 row(s) in 0.0230 seconds

This entry was posted in hbase