參考官方文檔html
圖1
如下幾個爲組成部件web
21892 HMaster 22028 HRegionServer 21553 QuorumPeerMain 2366 NameNode 2539 DataNode
# JAVA_HOME export JAVA_HOME=/opt/softwares/jdk1.8.0_141 # 使用本身的 Zookeeper export HBASE_MANAGES_ZK=false
<configuration> <!--根目錄,在HDFS的路徑--> <property> <name>hbase.rootdir</name> <value>hdfs://cen-ubuntu.cenzhongman.com:8020/hbase</value> </property> <!--是否分佈式--> <property> <name>hbase.cluster.distributed</name> <value>true</value> </property> <!--全部節點,逗號隔開--> <property> <name>hbase.zookeeper.quorum</name> <value>cen-ubuntu.cenzhongman.com</value> </property> </configuration>
cen-ubuntu
$ bin/zkServer.sh start
$ bin/start-hbase.sh
$ hostname:60010
Connect to your running instance of HBase using the hbase shell command, located in the bin/ directory of your HBase install. In this example, some usage and version information that is printed when you start HBase Shell has been omitted. The HBase Shell prompt ends with a > character.shell
$ ./bin/hbase shell hbase(main):001:0>
Type help and press Enter, to display some basic usage information for HBase Shell, as well as several example commands. Notice that table names, rows, columns all must be enclosed in quote characters.apache
hbase(main):001:0> help hbase(main):001:0> help 'create'
Use the list command to hbase(main):002:0> list 'test' TABLE test 1 row(s) in 0.0180 seconds => ["test"]
Use the create command to create a new table. You must specify the table name and the ColumnFamily name.ubuntu
hbase(main):001:0> create 'test', 'cf' 0 row(s) in 0.4170 seconds => Hbase::Table - test
To put data into your table, use the put command.框架
# 表名 RowKey 列簇名[:列名] 值 [timeStamp]可指定,默認爲時間戳 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
One of the ways to get data from HBase is to scan. Use the scan command to scan the table for data. You can limit your scan, but for now, all data is fetched.分佈式
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
To get a single row of data at a time, use the get command.ide
# 表名 RowKey [列簇名[:列名]] [timeStamp] hbase(main):007:0> get 'test', 'row1' COLUMN CELL cf:a timestamp=1421762485768, value=value1 1 row(s) in 0.0350 seconds
給定條件按範圍進行列查詢fetch
hbase(main):007:0> scan 'test' ,{STARTROW => 'xyz'}
If you want to delete a table or change its settings, as well as in some other situations, you need to disable the table first, using the disable command. You can re-enable it using the enable command.ui
hbase(main):008:0> disable 'test' 0 row(s) in 1.1820 seconds hbase(main):009:0> enable 'test' 0 row(s) in 0.1770 seconds
Disable the table again if you tested the enable command above:
hbase(main):010:0> disable 'test' 0 row(s) in 1.1820 seconds
To drop (delete) a table, use the drop command.
hbase(main):011:0> drop 'test' 0 row(s) in 0.1370 seconds
To Delect data from table.
# 刪除一行中一列數據(不能根據列簇所屬的列的數據,可是能刪除列簇的本身數據) hbase(main):011:0> delete 't1','r1','c1',['ts1'] # 刪除整行數據 hbase(main):011:0> deleteall 't1','r1'
To exit the HBase Shell and disconnect from your cluster, use the quit command. HBase is still running in the background.
hbase(main):007:0> quit/exit
In the same way that the bin/start-hbase.sh script is provided to conveniently start all HBase daemons, the bin/stop-hbase.sh script stops them.
$ ./bin/stop-hbase.sh stopping hbase....................