hbase 快速啓動

介紹

介紹hbase 單機實例啓動方式(Master, RegionSever, zookeeper). hbase 是Java現實的,所以需要JVM環境

下載

https://www.apache.org/dyn/closer.lua/hbase/2.0.2/hbase-2.0.2-bin.tar.gz

安裝

  1. 解壓
tar xzvf hbase-2.0.2-bin.tar.gz
cd hbase-2.0.2
  1. 設置JAVA_HOME路徑 vi conf/hbase-env.sh
# 內容
    export JAVA_HOME=/usr/java/jdk1.8.0_121

  1. 配置文件路徑

3.1 hbase.rootdir

3.2 hbase.zookeeper.property.dataDir

<configuration>
<property>
    <name>hbase.rootdir</name>
    <value>/data/jiazhiqiang/dataDir/hbase</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/data/jiazhiqiang/dataDir/zookeeper</value>
  </property>
  <property>
    <name>hbase.unsafe.stream.capability.enforce</name>
    <value>false</value>
    <description>
      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.
    </description>
  </property>
</configuration>

啓動

 ./bin/start-hbase.sh

測試

http://ip:16010

使用

連接hbase

使用hbase shell指令本地連接

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

查詢所有表

hbase(main):005:0> list
TABLE                                           
0 row(s)
Took 0.0076 seconds                 
=> []
hbase(main):006:0> 

創建表

語法: create [table], [column family]

創建表,並指定它的列族; 在hbase中,列不屬於表的,而是直接屬於列族
, 列族創建消耗很大的性能,所以在增加列族的時候,需要先disable table

hbase(main):006:0> create 'user', 'baseinfo'
Created table user
Took 0.9881 seconds                      
=> Hbase::Table - user

增加列族

alter [table], [column family]

disable 'test'
Took 0.4992 seconds                                                                                                                                                                                             
hbase(main):037:0> alter 'test', 'cf2'
Updating all regions with the new schema...
All regions updated.
Done.
Took 1.2430 seconds                                                                                                                                                                                             
hbase(main):038:0> enable 'test'
Took 0.7625 seconds   

插入數據

4:0* put 'test', 'row1', 'cf:name', 'jack'
Took 0.3727 seconds                                                                                                                                                                                             
hbase(main):045:0> scan 'test'
ROW                                                   COLUMN+CELL                                                                              
row1                                                 column=cf:name, timestamp=1537953179108, value=jack                                                                                                       
1 row(s)
Took 0.0560 seconds

查詢單行數據

hbase(main):031:0> get 'user' ,'row2'
COLUMN                                                CELL 
 id:                                                  timestamp=1537253166068, value=002                                
 name:                                                timestamp=1537253177855, value=lisi                                   
 phone:                                               timestamp=1537253188730, value=3253953                                 
1 row(s)

掃描全表

hbase(main):036:0> scan 'user'
ROW                                                   COLUMN+CELL                        
 row1                                                 column=id:, timestamp=1537253015327, value=001 
 row1                                                 column=name:, timestamp=1537253027288, value=zhangsan                      
 row1                                                 column=phone:, timestamp=1537253058786, value=1234545                     
 row2                                                 column=id:, timestamp=1537253166068, value=002 
 row2                                                 column=name:, timestamp=1537253177855, value=lisi                            
 row2                                                 column=phone:, timestamp=1537253188730, value=3253953

啓用和禁用表

distable  'user'
enable  'user'

刪除表

drop 'user'
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章