HBase shell權限管理

概述

在 hbase 中,爲了加強數據的安全性,能夠經過其權限管理功能進行權限約束。shell

權限控制類型apache

  • Read (R):讀取數據權限
  • Write (W):寫數據權限
  • Execute (X):執行協處理器的權限
  • Create (C):建立/刪除表等操做
  • Admin (A):管理員權限

注意:以上權限均是有做用域的,具體的做用域粒度控制以下。安全

權限控制粒度bash

  • Superuser:超級管理員用戶!!!擁有全部的權限! 能夠經過在 hbase-site.xml 中配置 hbase.superuser 的值來添加超級帳號(通常狀況下保留默認的hbase便可)。
  • Global:擁有全部 table 的 admin 權限。
  • Namespace :控制命名空間級別相關權限。
  • Table:控制 table 級別相關權限。
  • ColumnFamily:控制 ColumnFamily 級別相關權限。
  • Cell:控制 Cell 級別相關權限。

注意:以上權限均是有做用實體的,具體的做用實體分類以下。ide

權限控制實體oop

  • User:對某用戶受權
  • Group:對某用戶組受權

權限控制

在 hbase 中,能夠經過 hbase shell command 來實現權限的控制,主要涉及三部分:ui

  • grant:爲 user / group 賦權
  • revoke:移除 user / group 的權限
  • user_permission:查看 user / group 的權限

grant / 賦權spa

grant 的使用方法參考:code

Grant users specific rights.
Syntax : grant <user>, <permissions> [, <@namespace> [, <table> [, <column family> [, <column qualifier>]]]

permissions is either zero or more letters from the set "RWXCA".
READ('R'), WRITE('W'), EXEC('X'), CREATE('C'), ADMIN('A')

Note: Groups and users are granted access in the same way, but groups are prefixed with an '@' 
      character. In the same way, tables and namespaces are specified, but namespaces are 
      prefixed with an '@' character.

For example:

    hbase> grant 'bobsmith', 'RWXCA' // 爲用戶賦權
    hbase> grant '@admins', 'RWXCA' // 爲用戶組賦權
    hbase> grant 'bobsmith', 'RWXCA', '@ns1'
    hbase> grant 'bobsmith', 'RW', 't1', 'f1', 'col1'
    hbase> grant 'bobsmith', 'RW', 'ns1:t1', 'f1', 'col1' // 粒度能夠控制到 ColumnFamily 和 Cell 級別
複製代碼

revoke / 移除權限server

revoke 的使用方法參考:

Revoke a user's access rights. Syntax : revoke <user> [, <@namespace> [, <table> [, <column family> [, <column qualifier>]]]] Note: Groups and users access are revoked in the same way, but groups are prefixed with an '@' character. In the same way, tables and namespaces are specified, but namespaces are prefixed with an '@' character. For example: hbase> revoke 'bobsmith' // 移除用戶權限 hbase> revoke '@admins' // 移除用戶組權限 hbase> revoke 'bobsmith', '@ns1' hbase> revoke 'bobsmith', 't1', 'f1', 'col1' hbase> revoke 'bobsmith', 'ns1:t1', 'f1', 'col1' 複製代碼

user_permission / 查看權限

Show all permissions for the particular user.
Syntax : user_permission <table>

Note: A namespace must always precede with '@' character.

For example:

    hbase> user_permission
    hbase> user_permission '@ns1' // 查看 namespace 權限
    hbase> user_permission '@.*' // 查看全部 namespace 權限
    hbase> user_permission '@^[a-c].*'
    hbase> user_permission 'table1' // 查看 table 權限
    hbase> user_permission 'namespace1:table1' // 查看 table 權限
    hbase> user_permission '.*'
    hbase> user_permission '^[A-C].*'

複製代碼

補充說明

爲了使用 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>
<property>
  <name>hbase.coprocessor.regionserver.classes</name>
  <value>org.apache.hadoop.hbase.security.access.AccessController,org.apache.hadoop.hbase.security.token.TokenProvider</value>
</property>
複製代碼
相關文章
相關標籤/搜索