hbase(main):002:0> version 2.1.0-cdh6.2.0, rUnknown, Wed Mar 13 23:39:58 PDT 2019 Took 0.0003 seconds
1、介绍
在HBase中,namespace命名空间指对一组表的逻辑分组,类似RDBMS中的database,方便对表在业务上划分。Apache HBase从0.98.0, 0.95.2两个版本开始支持namespace级别的授权操作,HBase全局管理员可以创建、修改和回收namespace的授权。
2、namespace
HBase系统默认定义了两个缺省的namespace
hbase:系统内建表,包括namespace和meta表
default:用户建表时未指定namespace的表都创建在此
hbase(main):001:0> list_namespace NAMESPACE default hbase 2 row(s) Took 0.5695 seconds
hbase(main):005:0> create_namespace 'grady' Took 0.5849 seconds hbase(main):006:0> list_namespace NAMESPACE default grady hbase 3 row(s) Took 0.0123 seconds
create 'table_name', 'family1', 'family2', 'familyN'
hbase(main):008:0> create 'grady:student' ERROR: Table must have at least one column family For usage try 'help "create"' Took 0.0117 seconds
hbase(main):010:0> create 'grady:student', 'colfam01' Created table grady:student Took 2.5297 seconds => Hbase::Table - grady:student
hbase(main):011:0> list_namespace_tables 'grady' TABLE student 1 row(s) Took 0.0289 seconds => ["student"]
hbase(main):012:0> list TABLE grady:student 1 row(s) Took 0.0291 seconds => ["grady:student"]
drop_namespace 'grady'
disable 'grady:student'
enable ‘grady:student’
is_enabled 'table1' is_disabled 'table1'
disable 'grady:student' drop 'grady:student'
hbase(main):015:0> describe 'grady:student' Table grady:student is ENABLED grady:student COLUMN FAMILIES DESCRIPTION {NAME => 'colfam01', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE ', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BL OOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'} 1 row(s) Took 0.2017 seconds
put 'grady:student' , 'jiang' , 'colfam01:age' , '24' put 'grady:student' , 'jiang' , 'colfam01:city' , 'wuhan'
hbase(main):020:0> scan 'grady:student' ROW COLUMN+CELL jiang column=colfam01:age, timestamp=1643384572444, value=24 jiang column=colfam01:city, timestamp=1643384598828, value=wuhan 1 row(s) Took 0.0072 seconds
hbase(main):023:0> get 'grady:student', 'jiang' COLUMN CELL colfam01:age timestamp=1643384572444, value=24 colfam01:city timestamp=1643384598828, value=wuhan 1 row(s) Took 0.0684 seconds
hbase(main):025:0> get 'grady:student', 'jiang', 'colfam01' COLUMN CELL colfam01:age timestamp=1643384572444, value=24 colfam01:city timestamp=1643384598828, value=wuhan 1 row(s) Took 0.0064 seconds
hbase(main):024:0> get 'grady:student', 'jiang', 'colfam01:city' COLUMN CELL colfam01:city timestamp=1643384598828, value=wuhan 1 row(s) Took 0.0197 seconds
hbase(main):026:0> put 'grady:student' , 'jiang' , 'colfam01:city' , 'wuhan-hongshan' Took 0.0102 seconds hbase(main):027:0> scan 'grady:student' ROW COLUMN+CELL jiang column=colfam01:age, timestamp=1643384572444, value=24 jiang column=colfam01:city, timestamp=1643385119877, value=wuhan-hongshan 1 row(s) Took 0.0073 seconds
hbase(main):028:0> count 'grady:student' 1 row(s) Took 0.0434 seconds => 1
truncate 'member'
先插入chen的数据 hbase(main):029:0> put 'grady:student' , 'chen' , 'colfam01:city' , 'wuhan-hongshan' Took 0.0097 seconds hbase(main):030:0> put 'grady:student' , 'chen' , 'colfam01:age' , '25' Took 0.0116 seconds hbase(main):031:0> scan 'grady:student' ROW COLUMN+CELL chen column=colfam01:age, timestamp=1643385532711, value=25 chen column=colfam01:city, timestamp=1643385510256, value=wuhan-hongshan jiang column=colfam01:age, timestamp=1643384572444, value=24 jiang column=colfam01:city, timestamp=1643385119877, value=wuhan-hongshan hbase(main):032:0> delete 'grady:student', 'chen', 'colfam01:age' Took 0.0094 seconds
hbase(main):006:0> deleteall 'grady:student', 'chen' Took 0.0642 seconds
alter 'grady:student', 'cf2'
alter 'grady:student', 'delete' => 'cf2'
参考:
https://blog.csdn.net/kangkangwanwan/article/details/60960731