Start Livy running on a Kerberos-enabled Hadoop cluster

I created a sample Livy app (Spark) using a class com.cloudera.livy.Job

to calculate a rough value for the Pi (Source: https://github.com/cloudera/livy#using-the-programmatic-api ), exported as a jar file for example C:/path/to/the/pijob.jar

.

Actually I am running this work from another class Main

like this (also copied from the link above and adapted):

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);
        }
    }
}

      

This application works fine on an unsecured Hadoop cluster externally (started by my client). But when I try to run it against a Kerberos enabled cluster, it fails.

I tried to set the appropriate Kerberos properties on the class 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();

      

But I still get an exception saying authentication is required:

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

      

Questions at this point for me:

  • Are all required Kerberos settings required?
    • Or do I need to add something else for the login?
  • Should I provide config files / keytabs on my client machine?
    • or can I use the server paths (for example, I've done this so far)?
  • Is there any helpful documentation on Kerberos stuff for Livy?
+3


source to share





All Articles