How-to: enable hbase ACL and verify

通过配置HBase安全授权,实现管理员为特定用户(如chenfangfang)授予读写权限,允许其访问并操作指定表(如employee)。案例展示了如何验证权限分配,并通过授权操作使用户能够扫描和修改表数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. Add following configuration in 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>
  2. restart hbase cluster
Verify:
  • take htable named employee as example
  • hadoop admin user: hadoop, testing user: chenfangfang
  • Original: not grant to user chenfangfang
    -  The permission is as following(run as hadoop admin user):
    hbase(main):009:0> user_permission 'employee2'
    User                                       Namespace,Table,Family,Qualifier:Permission                                                                                
    hadoop                                    default,employee2,,: [Permission: actions=READ,WRITE,EXEC,CREATE,ADMIN] 
    -  User chenfangfang could not scan this htable:
    hbase(main):002:0> scan 'employee2'
    ROW                                        COLUMN+CELL                                                                                                                
    ERROR: org.apache.hadoop.hbase.security.AccessDeniedException: Insufficient permissions (table=employee2, action=READ)
  • Grant RW(read+write) to chenfangfang:
    - Run as admin user:
    hbase(main):010:0> grant 'chenfangfang', 'RW', 'employee2'
    0 row(s) in 0.4670 seconds
    hbase(main):012:0> user_permission 'employee2'
    User                                       Namespace,Table,Family,Qualifier:Permission                                                                                
    hadoop                                    default,employee2,,: [Permission: actions=READ,WRITE,EXEC,CREATE,ADMIN]                                                    
    chenfangfang                              default,employee2,,: [Permission: actions=READ,WRITE]                                                                      
    2 row(s) in 0.3000 seconds
    - Run as user chenfangfang: could scan and put
    hbase(main):003:0> scan 'employee2'
    ROW                                        COLUMN+CELL                                                                                                                 
    BeiJing                                   column=address:country, timestamp=1436947463771, value=China                                                                
    Hong                                      column=address:country, timestamp=1436947135888, value=China                                                                
    2 row(s) in 0.0440 seconds
    hbase(main):004:0> put 'employee2', 'BJ', 'address:country', 'China'
    0 row(s) in 0.0690 seconds
    hbase(main):005:0> put 'employee2', 'BJ', 'address:country', 'China'scan 'employee2'
    ROW                                        COLUMN+CELL                                                                                                                 
    BJ                                        column=address:country, timestamp=1436956463818, value=China                                                                
    BeiJing                                   column=address:country, timestamp=1436947463771, value=China                                                                
    Hong                                      column=address:country, timestamp=1436947135888, value=China                                                                
    3 row(s) in 0.0140 seconds
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值