1) Set up a KDC using Apache Kerby
As for other kerberos-related tutorials that I have written on this blog, we will use a github project I wrote that uses Apache Kerby to start up a KDC:
- bigdata-kerberos-deployment: This project contains some tests which can be used to test kerberos with various big data deployments, such as Apache Hadoop etc.
- zookeeper/localhost@storm.apache.org
- zookeeper-client@storm.apache.org
- storm/localhost@storm.apache.org
- storm-client@storm.apache.org
- alice@storm.apache.org
2) Download and configure Apache Zookeeper
Apache Storm uses Apache Zookeeper to help coordinate the cluster. Download Apache Zookeeper (this tutorial used 3.4.10) and extract it to a local directory. Configure Zookeeper to use Kerberos by adding a new file 'conf/zoo.cfg' with the following properties:
- dataDir=/tmp/zookeeper
- clientPort=2181
- authProvider.1 = org.apache.zookeeper.server.auth.SASLAuthenticationProvider
- requireClientAuthScheme=sasl
- jaasLoginRenew=3600000
Server {
com.sun.security.auth.module.Krb5LoginModule required refreshKrb5Config=true useKeyTab=true keyTab="/path.to.kerby.project/target/zookeeper.keytab" storeKey=true principal="zookeeper/localhost";
};
Before launching Zookeeper, we need to point to the JAAS configuration file above and also to the krb5.conf file generated in the Kerby test-case above. Add a new file 'conf/java.env' adding the SERVER_JVMFLAGS property to the classpath with:
- -Djava.security.auth.login.config=/path.to.zookeeper/conf/zookeeper.jaas
- -Djava.security.krb5.conf=/path.to.kerby.project/target/krb5.conf".
- bin/zkServer.sh start
Now download and extract the Apache Storm distribution (1.1.0 was used in this tutorial). Edit 'conf/storm.yaml' and edit the following properties:
- For "storm.zookeeper.servers" add "- localhost"
- nimbus.seeds: ["localhost"]
- storm.thrift.transport: "org.apache.storm.security.auth.kerberos.KerberosSaslTransportPlugin"
- java.security.auth.login.config: "/path.to.storm/conf/storm.jaas"
- storm.zookeeper.superACL: "sasl:storm"
- nimbus.childopts: "-Djava.security.auth.login.config=/path.to.storm/conf/storm.jaas -Djava.security.krb5.conf=/path.to.kerby.project/target/krb5.conf"
- ui.childopts: "-Djava.security.auth.login.config=/path.to.storm/conf/storm.jaas -Djava.security.krb5.conf=/path.to.kerby.project/target/krb5.conf"
- supervisor.childopts: "-Djava.security.auth.login.config=/path.to.storm/conf/storm.jaas -Djava.security.krb5.conf=/path.to.kerby.project/target/krb5.conf"
Client {
com.sun.security.auth.module.Krb5LoginModule required refreshKrb5Config=true useKeyTab=true keyTab="/path.to.kerby.project/target/zookeeper_client.keytab" storeKey=true principal="zookeeper-client";
};
StormClient {
com.sun.security.auth.module.Krb5LoginModule required refreshKrb5Config=true useKeyTab=true keyTab="path.to.kerby.project/target/storm_client.keytab" storeKey=true principal="storm-client" serviceName="storm";
};
StormServer {
com.sun.security.auth.module.Krb5LoginModule required refreshKrb5Config=true useKeyTab=true keyTab="path.to.kerby.project/target/storm.keytab" storeKey=true principal="storm/localhost@storm.apache.org";
};
'Client' is used to communicate with Zookeeper, 'StormClient' is used by the supervisor nodes and 'StormServer' is used by nimbus. Now start Nimbus and a supervisor node via:
- bin/storm nimbus
- bin/storm supervisor
As we have the Storm cluster up and running, the next task is to deploy a Topology to it. For this we will need to use another Storm distribution, so extract Storm again to another directory. Edit 'conf/storm.yaml' and edit the following properties:
- For "storm.zookeeper.servers" add "- localhost"
- nimbus.seeds: ["localhost"]
- storm.thrift.transport: "org.apache.storm.security.auth.kerberos.KerberosSaslTransportPlugin"
- java.security.auth.login.config: "/path.to.storm.client/conf/storm.jaas"
StormClient {
com.sun.security.auth.module.Krb5LoginModule required refreshKrb5Config=true useTicketCache=true serviceName="storm";
};
Note that we are not using keytabs here, but instead a ticket cache. Now edit 'conf/storm_env.ini' and add:
- STORM_JAR_JVM_OPTS:-Djava.security.krb5.conf=/path.to.kerby.project/target/krb5.conf
- export KRB5_CONFIG=/path.to.kerby.project/target/krb5.conf
- kinit -k -t /path.to.kerby.project/target/alice.keytab alice
- bin/storm jar /path.to.storm.project/target/bigdata-storm-demo-1.0-jar-with-dependencies.jar org.apache.coheigea.bigdata.storm.StormMain /path.to.storm.project/target/test-classes/words.txt
Hi,I am implementing Kerberos with Apache Storm and hence I came across your blog. I have followed similar steps but when starting the UI, I get the following error. I was hoping you could help.
ReplyDeletejavax.servlet.ServletException: org.apache.hadoop.security.authentication.client.AuthenticationException: javax.security.auth.login.LoginException: No key to store
This comment has been removed by a blog administrator.
ReplyDeleteHi,
ReplyDeleteSee the next blog entry for how to get the UI working with Kerberos:
http://coheigea.blogspot.ie/2017/05/securing-apache-storm-part-ii.html
I didn't see the error you noted. What is the full stacktrace? Are you configuring SSL?