當前位置:
首頁 > 最新 > HBase快速入門之單一節點安裝

HBase快速入門之單一節點安裝

來來來,先參與一下世界盃,我選埃及勝,好像我選錯了:

不知不覺,《hadoop權威指南》精要分析,已經寫了233頁了,等待與《hadoop快速入門與實踐》第二版共同發布:


單節點安裝hbase

HBase DataModel

JDK與Hbase版本支持

1:ssh免密碼登錄。

2:安裝JDK並正確配置環境變數。


注意,以下下載的是hbase1.x版本。

http://mirrors.hust.edu.cn/apache/hbase/stable/hbase-1.2.6.1-bin.tar.gz


我將hbase解壓到了/app/hbase-1.2.6目錄下:

[wangjian@hadoop91 app]$ tar -zxvf ~/hbase-1.2.6.1-bin.tar.gz -C .

解壓後,查看hbase-1.2.6.1目錄結構如下:

通過上面的目錄結構,就可以知道以下幾點問題:

1:bin目錄下,包含啟動和停止hbase的腳本程序。

2:conf目錄下,包含配置Hadoop的配置文件。

3:hbase-webapps目錄下,包含hbase的web服務及rest和thrift客戶端程序。

4:lib目錄下,包含hbase的jar包及依賴的其他jar包。重點是,通過上面的可以看出hbase1.2.6.1依賴還依然是hadoop-2.5.x版本。到了hbase2.0以後,依賴hadoop版本為2.7.4。所以,如果是用hadoop2.7.x的朋友,完全可以使用hbase2.0版本。


1:hbase-env.sh

export JAVA_HOME=/usr/jdk1.8.0_171

2:hbase-site.xml

hbase.rootdir

file:///app/hbase/data

/app/hbase/zookeeperdata

false

3:為了操作上的方便,建議將hbase_home/bin配置到PATH環境變數

export HBASE_HOME=/app/hbase-1.2.6.1

export PATH=$PATH:$HBASE_HOME/bin

配置完成以後查看hbase的版本:

[wangjian@hadoop91 profile.d]$ hbase version

HBase 1.2.6.1

Source code repository file:///home/busbey/projects/hbase/hbase-release-staging/hbase-1.2.6.1

revision=Unknown

Compiled by busbey on Sun Jun 3 23:19:26 CDT 2018

From source with checksum 8bbad3724e1501dbe32107e20b780499

查看hbase的shell幫助:

[wangjian@hadoop91 profile.d]$ hbase

Usage: hbase [] []

Options:

--config DIR Configuration direction to use. Default: ./conf

--hosts HOSTS Override the list in "regionservers" file

--auth-as-server Authenticate to ZooKeeper using servers configuration

Commands:

Some commands take arguments. Pass no args or -h for usage.

shell Run the HBase shell

hbck Run the hbase "fsck" tool

snapshot Create a new snapshot of a table

snapshotinfo Tool for dumping snapshot information

wal Write-ahead-log analyzer

hfile Store file analyzer

zkcli Run the ZooKeeper shell

upgrade Upgrade hbase

master Run an HBase HMaster node

regionserver Run an HBase HRegionServer node

zookeeper Run a Zookeeper server

rest Run an HBase REST server

thrift Run the HBase Thrift server

thrift2 Run the HBase Thrift2 server

clean Run the HBase clean up script

classpath Dump hbase CLASSPATH

mapredcp Dump CLASSPATH entries required by mapreduce

pe Run PerformanceEvaluation

ltt Run LoadTestTool

version Print the version

CLASSNAME Run the class named CLASSNAME

使用bin目錄下的start-hbase.sh腳本,就可以啟動hbase:

[wangjian@hadoop91 app]$ /app/hbase-1.2.6.1/bin/start-hbase.sh

starting master, logging to /app/hbase-1.2.6.1/bin/../logs/hbase-wangjian-master-hadoop91.out

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0

使用jps檢查hbase的守護進程,也只有一個名稱為HMaster的進程:

[wangjian@hadoop91 app]$ jps

1443 Jps

1406 HMaster

注意:在standalone模式下,即在單一節點模式下,HMaster這一個進程裡面即包含:HRegionServer也包含Zookeeper進程。以下是英文官方說明:

In standalone mode HBase runs all daemons within this single JVM, i.e. the HMaster, a single HRegionServer, and the ZooKeeper daemon.



使用hbase shell就可以登錄hbase shell的客戶端:

[wangjian@hadoop91 app]$ hbase shell

2018-06-14 23:11:38,637 WARN [main] util.NativeCodeLoader: Unable to load native-hadoop library for

your platform... using builtin-java classes where applicable

HBase Shell; enter "help" for list of supported commands.

Type "exit" to leave the HBase Shell

Version 1.2.6.1, rUnknown, Sun Jun 3 23:19:26 CDT 2018

hbase(main):001:0>

在hbase shell的命令行裡面,輸入help就可以顯示所有可以執行的命令,類似於DML,DDL的語句都是hbase特有的(前面講過,HBase不是關係型資料庫,不支持SQL語句,這兒所說的DML,DDL是針對HBase而言的,不是指的SQL中的DDL,DML等)。


以下是通過最簡單的示例,展示基本hbase的操作

創建一個表,表名為stud,列族為info:

hbase(main):013:0> create "stud","info"

0 row(s) in 1.3370 seconds

=> Hbase::Table - stud

hbase(main):014:0> list

TABLE

stud1 row(s) in 0.0390 seconds

=> ["stud"]

寫入數據:

hbase(main):016:0> put "stud","S001","info:name","Jack"

0 row(s) in 0.3890 seconds

hbase(main):017:0> put "stud","S001","info:age",30

0 row(s) in 0.0280 seconds

查看數據:

hbase(main):019:0> get "stud","S001"

COLUMN CELL

info:age timestamp=1528990009272, value=30

info:name timestamp=1528989990294, value=Jack

2 row(s) in 0.0530 seconds

再保存一些數據,不同的row key:

hbase(main):022:0> put "stud","S002","info:name","Mike"

0 row(s) in 0.0560 seconds

再查詢這個數據:

hbase(main):025:0> get "stud","S002"

COLUMN CELL

info:name timestamp=1528990139124, value=Mike

1 row(s) in 0.0200 seconds

遍曆數據:

hbase(main):027:0> scan "stud"

ROW COLUMN+CELL

S001 column=info:age, timestamp=1528990009272, value=30

S001 column=info:name, timestamp=1528989990294, value=Jack

S002 column=info:name, timestamp=1528990139124, value=Mike

2 row(s) in 0.0790 seconds

刪除表,先禁用表,再刪除表:

hbase(main):029:0> disable "stud"

0 row(s) in 2.3100 seconds

hbase(main):030:0> list

TABLE

stud

1 row(s) in 0.0310 seconds

=> ["stud"]

hbase(main):031:0> drop "stud"

0 row(s) in 1.2720 seconds

hbase(main):032:0> list

TABLE

0 row(s) in 0.0230 seconds


腳本stop-hbase.sh用於停止hbase:

[wangjian@hadoop91 app]$ /app/hbase-1.2.6.1/bin/stop-hbase.sh


喜歡這篇文章嗎?立刻分享出去讓更多人知道吧!

本站內容充實豐富,博大精深,小編精選每日熱門資訊,隨時更新,點擊「搶先收到最新資訊」瀏覽吧!


請您繼續閱讀更多來自 健哥說編程 的精彩文章:

TAG:健哥說編程 |