Hbase 命令行 shell基础

发表于 2020-02-08 09:47:09 by月小升

第一部分:Hbase基础查看

1. Hbase版本查看
hbase(main):008:0> version
2.2.3, r6a830d87542b766bd3dc4cfdee28655f62de3974, 2020年 01月 10日 星期五 18:27:51 CST
Took 0.0002 seconds

2. Hbase状态查看命令shell

hbase(main):009:0> status
1 active master, 0 backup masters, 1 servers, 0 dead, 3.0000 average load
Took 0.0387 seconds

第二部分:DDL(Data Defination Language)操作,Hbase的表table的增删改查

1. 新建表test 设置两个列族为cf1,cf2
hbase(main):010:0> create 'test','cf1','cf2'
Created table test
Took 1.3418 seconds                                                             
=> Hbase::Table - test

2. 获取表的描述

hbase(main):011:0> describe 'test'
Table test is ENABLED                                                           
test                                                                            
COLUMN FAMILIES DESCRIPTION                                                     
{NAME => 'cf1', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_B
EHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false
', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICA
TION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEM
ORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'fa
lse', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'}        
 
{NAME => 'cf2', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_B
EHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false
', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICA
TION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEM
ORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'fa
lse', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'}        
 
2 row(s)
 
QUOTAS                                                                          
0 row(s)
Took 16.3063 seconds

3. 删除一个列族cf2

hbase(main):012:0> alter 'test', {NAME=>'cf2',METHOD=>'delete'}
Updating all regions with the new schema...
1/1 regions updated.
Done.
Took 2.0665 seconds

4. 列出所有Hbase里的表

hbase(main):013:0> list
TABLE                                                                           
table                                                                           
test                                                                            
2 row(s)
Took 0.0044 seconds                                                             
=> ["table", "test"]

5. 查询表是否存在

hbase(main):014:0> exists 'test'
Table test does exist                                                           
Took 0.0224 seconds                                                             
=> true

6. 查询表是否可用

hbase(main):015:0> is_enabled 'test'
true                                                                            
Took 0.0053 seconds                                                             
=> true

7. 删除一个表

hbase(main):017:0> disable 'test'
Took 0.4657 seconds                                                             
hbase(main):018:0> drop 'test'
Took 0.2485 seconds
首发地址:–

无特殊说明,文章均为月小升原创,欢迎转载,转载请注明本文地址,谢谢

我来评几句
登录后评论

已发表评论数()

相关站点

+订阅
热门文章