使用Ranger的独立Spark集群授权

时间:2019-04-01 04:58:07

标签: apache-spark-sql apache-ranger

我正在研究具有独立Spark集群,Hive和Apache Ranger的EC2计算机。 Hive已集成到Ranger中。

由于Ranger不支持Spark-SQL JDBC(端口10015),因此我尝试了此开源项目https://github.com/yaooqinn/spark-authorizer进行Spark授权。但是没有用,因为它似乎依赖于纱线资源管理器。

我想知道使用Apache Ranger在Spark-sql上实现授权的任何可能方法。

我们未使用任何已实现的发行版,因此无法选择hortonworks中的SPARK-LLAP之类的功能。

我已经尝试过http://mail-archives.apache.org/mod_mbox/ranger-user/201601.mbox/%3CCAC1CY9P7iek6U6VDwLEXvLdCNRTcJzk5UWg3sei1MuUMCGrtWA@mail.gmail.com%3E中解释的内容,但是那也不起作用。

去年为此提出了火花吉拉,但似乎还没有开始。 https://issues.apache.org/jira/browse/SPARK-24503

我们正在使用Spark 2.3,Hive 2.3,Ranger 1.0。

1 个答案:

答案 0 :(得分:1)

构建一个简单的身份验证Java应用程序到spark-sql端口10015。

package hive.test;

import java.util.Hashtable;
import javax.security.sasl.AuthenticationException;
import org.apache.hive.service.auth.PasswdAuthenticationProvider;

/*
 javac -cp $HIVE_HOME/lib/hive-service-0.11-mapr.jar SampleAuthenticator.java -d .
 jar cf sampleauth.jar hive
 cp sampleauth.jar $HIVE_HOME/lib/.
*/


public class SampleAuthenticator implements PasswdAuthenticationProvider {

  Hashtable<String, String> store = null;

  public SampleAuthenticator () {
    store = new Hashtable<String, String>();
    store.put("user1", "passwd1");
    store.put("user2", "passwd2");
  }

  @Override
  public void Authenticate(String user, String  password)
      throws AuthenticationException {

    String storedPasswd = store.get(user);

    if (storedPasswd != null && storedPasswd.equals(password))
      return;

    throw new AuthenticationException("SampleAuthenticator: Error validating user");
  }

}

在安装HiveServer2的每个节点上的hive-site.xml文件中配置以下属性:

hive.server2.authentication CUSTOM hive.server2.custom.authentication.class The authentication class name.

<property>
<name>hive.server2.authentication</name>
<value>CUSTOM</value>
</property>

<property>
<name>hive.server2.custom.authentication.class</name>
<value>hive.test.SampleAuthenticator</value>
</property>

然后重新启动Hiveserver2以应用更改:

参考:https://mapr.com/docs/52/Hive/HiveServer2-CustomAuth.html

相关问题