java认证Kerberos主动登录

一、hive主动登录

 

// 设置jvm启动时krb5的读取路径参数

System.setProperty("java.security.krb5.conf", propertie.getProperty("kerberos.krb5.path"));

 

if(configuration == null){

              configuration = new Configuration();

          }

          configuration.set("hadoop.security.authentication", "Kerberos");

          String principal = properties.getProperty("hive.kerberos.principal");

          String keytabPath = properties.getProperty("hive.kerberos.keytab.path");

          UserGroupInformation.setConfiguration(configuration);

          try {

               UserGroupInformation.loginUserFromKeytab(principal, keytabPath);

          } catch (IOException e) {

              e.printStackTrace();

              System.exit(1);

              

          }

          LOG.info("********** Hive Succeeded in authenticating through Kerberos! **********");

     }

 

二、hbase

//hbase启动kerberos认证

          if("1".equals(enableKerberosAuth)){

              String principal = properties.getProperty("hbase.kerberos.principal");

              String keytabPath = properties.getProperty("hbase.kerberos.keytab.path");

              String dynamicPrincipalMaster = properties.getProperty("hbase.master.kerberos.principal");

              String dynamicPrincipalReg = properties.getProperty("hbase.regionserver.kerberos.principal");

              

              //hbase的配置信息

               configuration.set("hadoop.security.authentication", "Kerberos");

               configuration.set("hbase.security.authentication","Kerberos");

               configuration.set("hbase.master.kerberos.principal", dynamicPrincipalMaster);

               configuration.set("hbase.regionserver.kerberos.principal", dynamicPrincipalReg);

              /*configuration.set("hbase.rpc.engine", "org.apache.hadoop.hbase.ipc.SecureRpcEngine");

              configuration.set("kerberos.principal", dynamicPrincipal);

               configuration.set("hbase.regionserver.keytab.file", keytabPath);*/

              

             

               UserGroupInformation.setConfiguration(configuration);

              try {

                   UserGroupInformation.loginUserFromKeytab(principal, keytabPath);

              } catch (IOException e) {

                   e.printStackTrace();

                   System.exit(1);

              }

              LOG.info("********** HBase Succeeded in authenticating through Kerberos! **********");

          }else{ //hbase不启动kerberos认证

          }

 

 

三、yarn

 //yarn的配置

              String dynamicPrincipalYarn = properties.getProperty("yarn.kerberos.resourcemanager.principal");

               configuration.set("yarn.resourcemanager.principal", dynamicPrincipalYarn);

              //conf.set("yarn.resourcemanager.keytab", param.getKeytabPosition());

              //conf.set("yarn.nodemanager.keytab", param.getKeytabPosition());

              //conf.set("yarn.nodemanager.principal", param.getKerberousPrincipal());

               //conf.set("yarn.nodemanager.container-executor.class", "org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor");

               //conf.set("yarn.nodemanager.linux-container-executor.group", "yarn");

        

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值