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的表都創建在此
創建namespace
hbase>create_namespace 'ai_ns'
刪除namespace
hbase>drop_namespace 'ai_ns'
查看namespace
hbase>describe_namespace 'ai_ns'
列出全部namespace
hbase>list_namespace
在namespace下創建表
hbase>create 'ai_ns:testtable', 'fm1'
查看namespace下的表
hbase>list_namespace_tables 'ai_ns'
3、授權
具備Create權限的namespace Admin能夠對表創建和刪除、生成和恢復快照
具備Admin權限的namespace Admin能夠對表splits或major compactions
hbase>grant 'tenant-A' 'W' '@ai_ns'
回收tenant-A用戶對ai_ns的全部權限
hbase>revoke 'tenant-A''@ai_ns'當前用戶:hbase
hbase>namespace_create 'hbase_perf' hbase>grant 'mike', 'W', '@hbase_perf'
當前用戶:mike
hbase>create 'hbase_perf.table20', 'family1' hbase>create 'hbase_perf.table50', 'family1'
mike創建了兩張表table20和table50,同一時候成為這兩張表的owner。意味着有'RWXCA'權限
此時,mike團隊的還有一名成員alice也須要獲得hbase_perf下的權限,hbase管理員操作例如以下
當前用戶:hbase
hbase>grant 'alice', 'W', '@hbase_perf'此時alice能夠在hbase_perf下創建表,可是無法讀、寫、改動和刪除hbase_perf下已存在的表
當前用戶:alice
hbase>scan 'hbase_perf:table20'報錯AccessDeniedException
假設希望alice能夠訪問已經存在的表,則hbase管理員操作例如以下
當前用戶:hbase
hbase>grant 'alice', 'RW', 'hbase_perf.table20' hbase>grant 'alice', 'RW', 'hbase_perf.table50'
在HBase中啟用授權機制
hbase-site.xml
<property> <name>hbase.security.authorization</name> <value>true</value> </property> <property> <name>hbase.coprocessor.master.classes</name> <value>org.apache.hadoop.hbase.security.access.AccessController</value> </property> <property> <name>hbase.coprocessor.region.classes</name> <value>org.apache.hadoop.hbase.security.token.TokenProvider,org.apache.hadoop.hbase.security.access.AccessController</value> </property>配置完畢后須要重新啟動HBase集群
授權相關JIRA