独立的 spark 集群与 Ranger 的授权
Standalone spark cluster Authorization with Ranger
我正在设置具有独立 Spark 集群、Hive、Apache Ranger 的 EC2 机器。 Hive 集成到 Ranger 中。
由于 Ranger 不支持 Spark-SQL JDBC(端口 10015),我尝试了这个开源项目 https://github.com/yaooqinn/spark-authorizer 进行 Spark 授权。但是没有用,因为它似乎依赖于 yarn 资源管理器。
我想知道使用 Apache Ranger 在 Spark-sql 上获得授权的任何可能方法。
我们没有使用任何已实现的发行版,因此不能选择 hortonworks 中的 SPARK-LLAP 等功能。
我已经尝试过 http://mail-archives.apache.org/mod_mbox/ranger-user/201601.mbox/%3CCAC1CY9P7iek6U6VDwLEXvLdCNRTcJzk5UWg3sei1MuUMCGrtWA@mail.gmail.com%3E 中解释的方法,但也没有用。
去年为此提出了一个 spark jira,但似乎还没有开始。 https://issues.apache.org/jira/browse/SPARK-24503
我们正在使用 Spark 2.3、Hive 2.3、Ranger 1.0。
构建一个简单的身份验证 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
我正在设置具有独立 Spark 集群、Hive、Apache Ranger 的 EC2 机器。 Hive 集成到 Ranger 中。
由于 Ranger 不支持 Spark-SQL JDBC(端口 10015),我尝试了这个开源项目 https://github.com/yaooqinn/spark-authorizer 进行 Spark 授权。但是没有用,因为它似乎依赖于 yarn 资源管理器。
我想知道使用 Apache Ranger 在 Spark-sql 上获得授权的任何可能方法。
我们没有使用任何已实现的发行版,因此不能选择 hortonworks 中的 SPARK-LLAP 等功能。
我已经尝试过 http://mail-archives.apache.org/mod_mbox/ranger-user/201601.mbox/%3CCAC1CY9P7iek6U6VDwLEXvLdCNRTcJzk5UWg3sei1MuUMCGrtWA@mail.gmail.com%3E 中解释的方法,但也没有用。
去年为此提出了一个 spark jira,但似乎还没有开始。 https://issues.apache.org/jira/browse/SPARK-24503
我们正在使用 Spark 2.3、Hive 2.3、Ranger 1.0。
构建一个简单的身份验证 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