查询、行-hbase Shell之简单命令说明-by小雨

文章结束给大家来个程序员笑话:[M]

    [hadoop@master hbase]$ bin/hbase shell

    进入shell

    

    hbase(main):001:0> help

    ******(Shell命令说明)

    

    hbase(main):002:0> status

    1 servers, 0 dead, 4.0000 average load (服务器,dead,负荷)

    

    hbase(main):003:0> version

    0.94.2, r1395367, Sun Oct  7 19:11:01 UTC 2012 (版本)

    

    hbase(main):001:0> create 'member','member_id','address','info'

    0 row(s) in 5.3700 seconds (建创表,功成)

    

    hbase(main):002:0> list
TABLE                                                                                          
htest                                                                                          
member                                                                                         
user                                                                                           
3 row(s) in 0.3400 seconds (查看TABLE信息)

    

    hbase(main):003:0> describe 'member'
DESCRIPTION                                                   ENABLED                          
 {NAME => 'member', FAMILIES => [{NAME => 'address', DATA_BLO true                             
 CK_ENCODING => 'NONE', BLOOMFILTER => 'NONE', REPLICATION_SC                                  
 OPE => '0', VERSIONS => '3', COMPRESSION => 'NONE', MIN_VERS                                  
 IONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'fal                                  
 se', BLOCKSIZE => '65536', IN_MEMORY => 'false', ENCODE_ON_D                                  
 ISK => 'true', BLOCKCACHE => 'true'}, {NAME => 'info', DATA_                                  
 BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'NONE', REPLICATION                                  
 _SCOPE => '0', VERSIONS => '3', COMPRESSION => 'NONE', MIN_V                                  
 ERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => '                                  
 false', BLOCKSIZE => '65536', IN_MEMORY => 'false', ENCODE_O                                  
 N_DISK => 'true', BLOCKCACHE => 'true'}, {NAME => 'member_id                                  
 ', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'NONE', REP                                  
 LICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION => 'NONE                                  
 ', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CE                                  
 LLS => 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false',                                   
 ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'}]}                                             
1 row(s) in 0.0340 seconds   (查看表)

    

    hbase(main):002:0> alter 'member',{NAME=>'member_id',METHOD=>'delete'}
ERROR: org.apache.hadoop.hbase.TableNotDisabledException: org.apache.hadoop.hbase.TableNotDisabledException: member

    (弗成直接改修,必须先把表离线,然后改修)

    

    hbase(main):003:0> disable 'member'
0 row(s) in 2.2260 seconds (disable表,先设为弗成用)

    hbase(main):004:0> alter 'member',{NAME=>'member_id',METHOD=>'delete'}

    Updating all regions with the new schema...

    1/1 regions updated.

    Done.

    0 row(s) in 2.5010 seconds  (改修功成)

    

    hbase(main):005:0> enable 'member'
0 row(s) in 2.2380 seconds   (然后动启表)

    

    hbase(main):009:0> disable 'member'
0 row(s) in 2.1470 seconds  (删除表也须要先把表设为弗成用)

    

    hbase(main):010:0> drop 'member'
0 row(s) in 1.3690 seconds  (删除功成)

    

    hbase(main):011:0> exists 'member'
Table member does not exist                                                                    
0 row(s) in 0.1170 seconds   (查看是不是存在表)

    

    hbase(main):015:0> is_enabled 'member'
true                                                                                           
0 row(s) in 0.0030 seconds   (查看表是不是可用)

    

    hbase(main):016:0> is_disabled 'member'
false                                                                                          
0 row(s) in 0.0040 seconds  (查看表是不是弗成用)

    

    (插入记载)

    hbase(main):017:0> put 'member','scutshuxue','info:age','24'

    hbase(main):018:0> put 'member','scutshuxue','info:birthday','1987-06-17'

    hbase(main):020:0> put 'member','scutshuxue','info:company','alibaba'

    hbase(main):025:0> put 'member','scutshuxue','address:province','zhejiang'

hbase(main):026:0> put 'member','scutshuxue','address:city','hangzhou'

hbase(main):027:0> put 'member','xiaofeng','info:birthday','1987-4-17'

hbase(main):028:0> put 'member','xiaofeng','info:company','alibaba'

hbase(main):029:0> put 'member','xiaofeng','address:contry','china'

hbase(main):030:0> put 'member','xiaofeng','address:province','guangdong'

hbase(main):031:0> put 'member','xiaofeng','address:city','jieyang'

hbase(main):032:0> put 'member','xiaofeng','address:town','xianqiao'

    

    (查询记载:行键查询)

    hbase(main):001:0> get 'member','scutshuxue'
COLUMN                   CELL                                                                  
 address:city            timestamp=1365791240949, value=hangzhou                               
 address:province        timestamp=1365791217245, value=zhejiang                               
 info:age                timestamp=1365790872766, value=24                                     
 info:birthday           timestamp=1365790910608, value=1987-06-17                             
 info:company            timestamp=1365790948776, value=alibaba                                
5 row(s) in 2.8340 seconds

    

    (查询记载:行键、一个列簇的有所信息)

    hbase(main):002:0> get 'member','scutshuxue','info'
COLUMN                   CELL                                                                  
 info:age                timestamp=1365790872766, value=24                                     
 info:birthday           timestamp=1365790910608, value=1987-06-17                             
 info:company            timestamp=1365790948776, value=alibaba                                
3 row(s) in 0.0220 seconds

    

    (查询记载:行键、列簇的某列信息)

    hbase(main):003:0> get 'member','scutshuxue','info:age'
COLUMN                   CELL                                                                  
 info:age                timestamp=1365790872766, value=24                                     
1 row(s) in 0.0130 seconds

    

    (新更一条记载)

    hbase(main):004:0> put 'member','scutshuxue','info:age','99'
0 row(s) in 0.0940 seconds

hbase(main):005:0> get'member','scutshuxue','info:age'
COLUMN                   CELL                                                                  
 info:age                timestamp=1365792994491, value=99                                     
1 row(s) in 0.0170 seconds

    

    (通过时间戳查询记载)

    hbase(main):008:0> get'member','scutshuxue',{COLUMN=>'info:age',TIMESTAMP=>1365792994491}
COLUMN                   CELL                                                                  
 info:age                timestamp=1365792994491, value=99                                     
1 row(s) in 0.0110 seconds

    

    (全表扫描)

    hbase(main):009:0> scan 'member'
ROW                      COLUMN+CELL                                                           
 scutshuxue              column=address:city, timestamp=1365791240949, value=hangzhou          
 scutshuxue              column=address:province, timestamp=1365791217245, value=zhejiang      
 scutshuxue              column=info:age, timestamp=1365792994491, value=99                    
 scutshuxue              column=info:birthday, timestamp=1365790910608, value=1987-06-17       
 scutshuxue              column=info:company, timestamp=1365790948776, value=alibaba           
 xiaofeng                column=address:city, timestamp=1365791360361, value=jieyang           
 xiaofeng                column=address:contry, timestamp=1365791327027, value=china           
 xiaofeng                column=address:province, timestamp=1365791339666, value=guangdong     
 xiaofeng                column=address:town, timestamp=1365791380287, value=xianqiao          
 xiaofeng                column=info:birthday, timestamp=1365791274037, value=1987-4-17        
 xiaofeng                column=info:company, timestamp=1365791292933, value=alibaba           
2 row(s) in 0.1540 seconds

    

    (删除定制行键的段字)
hbase(main):010:0> delete 'member','temp','info:age'
0 row(s) in 0.0500 seconds

hbase(main):011:0> get'member','temp'
COLUMN                   CELL                                                                  
0 row(s) in 0.0050 seconds

    

    (删除整行)

    hbase(main):013:0> deleteall'member','xiaofeng'
0 row(s) in 0.0070 seconds

    

    (查询行)

    hbase(main):014:0> count'member'
1 row(s) in 0.0670 seconds

    

    (空清表)

    hbase(main):015:0> truncate'member'
Truncating 'member' table (it may take a while):
 - Disabling table...
 - Dropping table...
 - Creating table...
0 row(s) in 3.8280 seconds

    

    Hbase API

    《Hbase威望指南》第3-5章

    http://hbase.apache.org/apidocs/index.html

文章结束给大家分享下程序员的一些笑话语录: 一个合格的程序员是不会写出 诸如 “摧毁地球” 这样的程序的,他们会写一个函数叫 “摧毁行星”而把地球当一个参数传进去。

你可能感兴趣的:(shell)