在hbase 激活kerberos 下opentsdb的使用


最近公司大數據集群統一升級了 kerberos,那原先 的opentsdb就不能使用了,需要使用keytab方式登陸驗證。

在百度找了好久沒找到解決方案,還是組里勇哥看opentsdb源碼才發現opentsdb怎么驗證keytab.

下面是具體代碼片斷:

未使用kerberos 時候,直接使用下面的舊代碼:

HBaseClient hbaseClient = new HBaseClient(zookeeper);

激活了kerberos需要:
 System.setProperty("java.security.auth.login.config", "D:/kbs/ksm_jaas.conf");
System.setProperty("zookeeper.sasl.client", "false");
//下面行只在本地打開
System.setProperty("java.security.krb5.conf", "D:/kbs/krb5.conf");

org.hbase.async.Config asyncConfig = new org.hbase.async.Config();
asyncConfig.overrideConfig("hbase.zookeeper.quorum", zookeeper);
asyncConfig.overrideConfig("hbase.security.auth.enable", "true");
asyncConfig.overrideConfig("hbase.security.authentication", "kerberos");
asyncConfig.overrideConfig("hbase.sasl.clientconfig", "Client");
asyncConfig.overrideConfig("hbase.kerberos.regionserver.principal", "hbase/_HOST@HTSEC.COM");
HBaseClient hbaseClient = new HBaseClient(asyncConfig);
//認證
KerberosClientAuthProvider authProvider = new KerberosClientAuthProvider(hbaseClient);

需要注意的是maven jar包,低版本的opentsdb的確不支持kerberos

<dependency>
<groupId>net.opentsdb</groupId>
<artifactId>opentsdb</artifactId>
<version>2.3.0-RC1</version>
</dependency>
<dependency>
<groupId>org.hbase</groupId>
<artifactId>asynchbase</artifactId>
<version>1.7.2</version>
</dependency>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM