hbase simple权限二

简介: 一:HBASE权限userHBASE的user底层使用的还是hadoop的user;构造connection类:public static Connection createConnection(Configuration conf, User u...

一:HBASE权限user

HBASE的user底层使用的还是hadoop的user;
构造connection类:

public static Connection createConnection(Configuration conf, User user) throws IOException {
    return createConnection(conf, null, user);
}

其中可以user参数
进入HBASE的user类:有一个构造方法:

public static User create(UserGroupInformation ugi) {
    if (ugi == null) {
        return null;
    }
    return new SecureHadoopUser(ugi);
}

可以看到使用子类SecureHadoopUser
SecureHadoopUser的构造方法参数UserGroupInformation中看到:

public static UserGroupInformation createRemoteUser(String user, AuthMethod authMethod) {
if (user == null || user.isEmpty()) {
  throw new IllegalArgumentException("Null user");
}
Subject subject = new Subject();
subject.getPrincipals().add(new User(user));
UserGroupInformation result = new UserGroupInformation(subject);
result.setAuthenticationMethod(authMethod);
return result;

其中封装user的则是hadoop.security的user类。

二:acl数据更新zookeeper及cache

(初始化的时候会执将所有表的权限信息写到对应table的node节点上)
在HBASE执行put以及delete操作触发updateAcl更新操作:

    /**
    * Writes all table ACLs for the tables in the given Map up into ZooKeeper
    * znodes.  This is called to synchronize ACL changes following {@code _acl_}
    * table updates.
    */
    void updateACL(RegionCoprocessorEnvironment e,final Map<byte[], List<Cell>> familyMap) 

获取权限监控的znode

this.authManager.getZKPermissionWatcher();

读取acl表的所有权限:

AccessControlLists.getPermissions(conf, entry, t);

并且会解析数据成指定格式,写入zookeeper,并且转成字节;
解析核心代码:

    int idx = username.indexOf(ACL_KEY_DELIMITER);
    byte[] permFamily = null;
    byte[] permQualifier = null;
    
    //因为在acl表中,列名columname的组成是user+权限table的不为空family+不为空的列名,且以逗号分隔的形式。
    if (idx > 0 && idx < username.length() - 1) {
        String remainder = username.substring(idx + 1);
        username = username.substring(0, idx);
        idx = remainder.indexOf(ACL_KEY_DELIMITER);
        if (idx > 0 && idx < remainder.length() - 1) {
            permFamily = Bytes.toBytes(remainder.substring(0, idx));
            permQualifier = Bytes.toBytes(remainder.substring(idx + 1));
        } else {
            permFamily = Bytes.toBytes(remainder);
        }
    }

    return new Pair<String, TablePermission>(username, new TablePermission(TableName.valueOf(entryName), permFamily, permQualifier, value));

则是最终写入zookeeper的格式数据
序列化写入数据:

    byte[] serialized = AccessControlLists.writePermissionsAsBytes(perms, conf);
      zkw.writeToZookeeper(entry, serialized);

zookeeper上node子znode数据变更,会执行更新cache操作;
相应的执行refreshAuthManager操作,包括

authManager.refreshNamespaceCacheFromWritable(AccessControlLists.fromNamespaceEntry(entry), nodeData);
authManager.refreshTableCacheFromWritable(TableName.valueOf(entry), nodeData);

然后重新将新权限信息放进cache中,提供HBASE权限的检查check操作。
当然,再删除的时候,数据信息也会执行相应的delete操作。

三:cache

在TableAuthManager权限检查类中,三种cache,

    1.PermissionCache<Permission> globalCache
    2.ConcurrentSkipListMap<TableName, PermissionCache<TablePermission>> tableCache 
    3.private ConcurrentSkipListMap<String, PermissionCache<TablePermission>> nsCache

分别在处理超级用户superuser,namespace及table的用户权限信息

目录
相关文章
|
分布式数据库 Hbase 网络架构
hbase simple权限一
一:shell执行: grant授权: 查看commands目录下grant.rb文件: security_admin.grant(user, permissions, table_name, family, qualifier) 进入security.
1814 0
|
Java Shell 分布式数据库
【大数据技术Hadoop+Spark】HBase数据模型、Shell操作、Java API示例程序讲解(附源码 超详细)
【大数据技术Hadoop+Spark】HBase数据模型、Shell操作、Java API示例程序讲解(附源码 超详细)
475 0
|
11月前
|
分布式计算 Ubuntu Hadoop
Ubuntu22.04下搭建Hadoop3.3.6+Hbase2.5.6+Phoenix5.1.3开发环境的指南
呈上,这些步骤如诗如画,但有效且动人。仿佛一个画家在画布上描绘出一幅完美的画面,这就是你的开发环境。接下来,尽情去创造吧,祝编程愉快!
785 19
|
分布式计算 Java Hadoop
java使用hbase、hadoop报错举例
java使用hbase、hadoop报错举例
396 4
|
分布式计算 Hadoop 关系型数据库
Hadoop任务scan Hbase 导出数据量变小分析
Hadoop任务scan Hbase 导出数据量变小分析
230 0
|
分布式计算 Hadoop Shell
Hadoop-35 HBase 集群配置和启动 3节点云服务器 集群效果测试 Shell测试
Hadoop-35 HBase 集群配置和启动 3节点云服务器 集群效果测试 Shell测试
376 4
|
SQL 分布式计算 Hadoop
Hadoop-37 HBase集群 JavaAPI 操作3台云服务器 POM 实现增删改查调用操作 列族信息 扫描全表
Hadoop-37 HBase集群 JavaAPI 操作3台云服务器 POM 实现增删改查调用操作 列族信息 扫描全表
241 3
|
分布式计算 Hadoop Shell
Hadoop-36 HBase 3节点云服务器集群 HBase Shell 增删改查 全程多图详细 列族 row key value filter
Hadoop-36 HBase 3节点云服务器集群 HBase Shell 增删改查 全程多图详细 列族 row key value filter
282 3
|
存储 分布式计算 Hadoop
Hadoop-33 HBase 初识简介 项目简介 整体架构 HMaster HRegionServer Region
Hadoop-33 HBase 初识简介 项目简介 整体架构 HMaster HRegionServer Region
244 2
|
SQL 分布式计算 Hadoop
Hadoop-34 HBase 安装部署 单节点配置 hbase-env hbase-site 超详细图文 附带配置文件
Hadoop-34 HBase 安装部署 单节点配置 hbase-env hbase-site 超详细图文 附带配置文件
663 2

热门文章

最新文章