hbase單機安裝和簡單使用

電腦太卡了,使用不了hadoop和hdfs了,因此今天安裝了一個僞分佈式,數據存儲在本地磁盤,也沒有向HDFS中存,也沒有使用本身的zookeeper,安裝過程當中還出了點小問題,總結一下,省得忘了。linux

1.hbase的安裝shell

  ·將壓縮包上傳到linux中,解壓,上傳我使用的是secureCRT,直接ALT+P,而後從windows中下好的,拖進去就能夠了。windows

  ·解壓命令:tar -zxvf hbase.tar.gz分佈式

  ·修改配置文件,將目錄切換到hbase/conf,修改第一個配置文件hbse-env.sh:這個文件修改兩個位置,第一個是加入jdk,第二個是將zookeeper設置true【使用自帶的,固然是能夠使用本身的】oop

export JAVA_HOME=/home/kwhadoop/hadoop/jdk

export HBASE_MANAGES_ZK=true

  ·修改hbse-site.xml文件,將目錄改到本地this

<configuration>
        <property>
                <name>hbase.rootdir</name>
                <value>file:///home/kwhadoop/te</value>
        </property>
</configuration>

  ·啓動命令spa

[root@hadoop bin]#./start-hbase.sh

  `啓動shellcode

[root@hadoop bin]# ./hbase shell

  2018-03-30 18:40:12,322 INFO [main] Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.ava  ilable
  HBase Shell; enter 'help<RETURN>' for list of supported commands.
  Type "exit<RETURN>" to leave the HBase Shell
  Version 0.96.2-hadoop2, r1581096, Mon Mar 24 16:03:18 PDT 2014xml

  hbase(main):001:0>blog

(1)建立表

hbase(main):001:0> create 'user1','info1'
0 row(s) in 47.2280 seconds

=> Hbase::Table - user1

(2)顯示錶

hbase(main):004:0> list
TABLE                                                                                                                                                               
user1                                                                                                                                                               
1 row(s) in 0.0960 seconds

=> ["user1"]

(3)顯示錶結構

hbase(main):007:0> describe 'user1'
DESCRIPTION                                                                                               ENABLED                                                   
 'user1', {NAME => 'info1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0' true                                                      
 , VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS =                                                           
 > 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}                                                                                       
1 row(s) in 0.2010 seconds

(4)刪除表的時候先要將表設置爲disable,不然沒法刪除

hbase(main):008:0> drop 'user1'

ERROR: Table user1 is enabled. Disable it first.'

Here is some help for this command:
Drop the named table. Table must first be disabled:
  hbase> drop 't1'
  hbase> drop 'ns1:t1'

(5)將表設置爲disable

hbase(main):008:0> disable 'user1'

(6)添加字段

hbase(main):002:0> put 'user1','1232456','info1:name','kw'
0 row(s) in 0.2550 seconds

(7)全表掃描

hbase(main):003:0> scan 'user1'
ROW                                        COLUMN+CELL                                                                                                              
 1232456                                   column=info1:name, timestamp=1522450895874, value=kw                                                                     
1 row(s) in 0.1910 seconds

(8)列族中增長字段

hbase(main):004:0> put 'user1','1232456','info1:age','23'
0 row(s) in 0.0270 seconds

hbase(main):005:0> scan 'user1'
ROW COLUMN+CELL
1232456 column=info1:age, timestamp=1522450938635, value=23
1232456 column=info1:name, timestamp=1522450895874, value=kw
1 row(s) in 0.0730 seconds

(9)統計行數

hbase(main):011:0> count 'user1'
1 row(s) in 0.1290 seconds

=> 1

(10)獲取一個列族的數據

hbase(main):013:0> get 'user1','1232456','info1'
COLUMN                                     CELL                                                                                                                     
 info1:age                                 timestamp=1522450938635, value=23                                                                                        
 info1:name                                timestamp=1522450895874, value=kw                                                                                        
2 row(s) in 0.0400 seconds

(11)若是插入鍵值、列族、屬性相同的屬性,這個時候起到了更新的做用

hbase(main):018:0> put 'user1','1232456','info1:age','20'
0 row(s) in 0.0130 seconds

hbase(main):019:0> scan 'user1'
ROW                                        COLUMN+CELL                                                                                                              
 1232456                                   column=info1:age, timestamp=1522453126526, value=20                                                                      
 1232456                                   column=info1:name, timestamp=1522450895874, value=kw                                                                     
1 row(s) in 0.1330 seconds

(12)獲取指定的屬性,選取時間戳最新的數據顯示

hbase(main):022:0> get 'user1','1232456','info1:age'
COLUMN                                     CELL                                                                                                                     
 info1:age                                 timestamp=1522453126526, value=20                                                                                        
1 row(s) in 0.0450 seconds

(13)刪除數據

hbase(main):023:0> delete 'user1','1232456','info1:age'
0 row(s) in 0.2380 seconds

hbase(main):024:0> describe 'user1'
DESCRIPTION                                                                                               ENABLED                                                   
 'user1', {NAME => 'info1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0' true                                                      
 , VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS =                                                           
 > 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}                                                                                       
1 row(s) in 0.2180 seconds

hbase(main):025:0> scan 'user1'
ROW                                        COLUMN+CELL                                                                                                              
 1232456                                   column=info1:name, timestamp=1522450895874, value=kw                                                                     
1 row(s) in 0.0370 seconds

(14)刪除全部

hbase(main):030:0> deleteall 'user1','1232456'
0 row(s) in 0.0210 seconds

hbase(main):031:0> list
TABLE
user1
1 row(s) in 0.1370 seconds

=> ["user1"]
hbase(main):032:0>

 

他只是將表中的列族刪除了嗎,表的刪除須要使用disable,而後drop就能夠了。

表都刪了,那就不練了

相關文章
相關標籤/搜索