在 hbase 中,爲了加強數據的安全性,能夠經過其權限管理功能進行權限約束。shell
權限控制類型apache
注意:以上權限均是有做用域的,具體的做用域粒度控制以下。安全
權限控制粒度bash
hbase-site.xml
中配置 hbase.superuser
的值來添加超級帳號(通常狀況下保留默認的hbase便可)。注意:以上權限均是有做用實體的,具體的做用實體分類以下。ide
權限控制實體oop
在 hbase 中,能夠經過 hbase shell
command 來實現權限的控制,主要涉及三部分:ui
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>
複製代碼