在启用kerberos的hadoop集群中运行livy作业

h4cxqtbf  于 2021-05-29  发布在  Hadoop
关注(0)|答案(0)|浏览(342)

我使用 com.cloudera.livy.Job 用于计算pi近似值的类(来源:https://github.com/cloudera/livy#using-编程api),作为jar文件导出到。 C:/path/to/the/pijob.jar .
实际上我是从另一个地方来做这个工作的 Main 类(也从上面的链接复制并改编):

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Properties;
import java.util.concurrent.ExecutionException;

import com.cloudera.livy.LivyClient;
import com.cloudera.livy.LivyClientBuilder;

public class Main {

    public static void main(String[] args) throws IOException, URISyntaxException, InterruptedException, ExecutionException {
        String livyUrl = "http://myserverIp:8998";
        String piJar = "C:/path/to/the/pijob.jar";
        int samples = 10000;

        LivyClient client = new LivyClientBuilder().setURI(new URI(livyUrl)).build();

        try {
            System.err.printf("Uploading %s to the Spark context...\n", piJar);
            client.uploadJar(new File(piJar)).get();

            System.err.printf("Running PiJob with %d samples...\n", samples);
            double pi = client.submit(new PiJob(samples)).get();

            System.out.println("Pi is roughly: " + pi);
        } finally {
            client.stop(true);
        }
    }
}

这个应用程序在外部(从我的客户机开始)的不安全hadoop集群中工作得非常好。但当我尝试在启用kerberos的集群上运行它时,它失败了。
我尝试在中设置相应的kerberos属性 LivyClientBuilder 班级:

Properties props = new Properties();
props.put("livy.environment", "production");
props.put("livy.impersonation.enabled", "true");
props.put("livy.server.auth.kerberos.keytab", "/etc/security/keytabs/spnego.service.keytab");
props.put("livy.server.auth.kerberos.principal", "HTTP/_HOST@MYCLUSTER.DE");
props.put("livy.server.auth.type", "kerberos");
props.put("livy.server.csrf_protection.enabled", "true");
props.put("livy.server.kerberos.keytab", "/etc/security/keytabs/livy.service.keytab");
props.put("livy.server.kerberos.principal", "livy/_HOST@MYCLUSTER.DE");
props.put("livy.server.port", "8998");
props.put("livy.server.session.timeout", "3600000");
props.put("livy.superusers", "zeppelin-MyCluster");

LivyClient client = new LivyClientBuilder().setAll(props).setURI(new URI(livyUrl)).build();

但我还是得到一个例外,说认证是必需的:

Exception in thread "main" java.lang.RuntimeException: java.io.IOException: Authentication required: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 401 </title>
</head>
<body>
<h2>HTTP ERROR: 401</h2>
<p>Problem accessing /sessions/. Reason:
<pre>    Authentication required</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
</body>
</html>

    at com.cloudera.livy.client.http.HttpClient.propagate(HttpClient.java:185)
    at com.cloudera.livy.client.http.HttpClient.<init>(HttpClient.java:85)
    at com.cloudera.livy.client.http.HttpClientFactory.createClient(HttpClientFactory.java:38)
    at com.cloudera.livy.LivyClientBuilder.build(LivyClientBuilder.java:124)
    at livy.Main.main(Main.java:34)
Caused by: java.io.IOException: Authentication required: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 401 </title>
</head>
<body>
<h2>HTTP ERROR: 401</h2>
<p>Problem accessing /sessions/. Reason:
<pre>    Authentication required</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
</body>
</html>

    at com.cloudera.livy.client.http.LivyConnection.sendRequest(LivyConnection.java:230)
    at com.cloudera.livy.client.http.LivyConnection.sendJSONRequest(LivyConnection.java:204)
    at com.cloudera.livy.client.http.LivyConnection.post(LivyConnection.java:180)
    at com.cloudera.livy.client.http.HttpClient.<init>(HttpClient.java:82)
    ... 3 more

现在的问题是:
这些都是我需要的kerberos设置吗?
或者我需要添加更多内容才能登录?
我必须在我的客户机上提供配置文件/键表吗?
或者我仍然可以使用服务器路径(就像我到目前为止所做的那样)?
有没有一些关于kerberos的有用文档?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题