In this post we will switch our attention from authorization to authentication, and show how we can authenticate Apache Hive users via kerberos.
1) Set up a KDC using Apache Kerby
A github project that uses Apache Kerby to start up a KDC is available here:
- 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.
- hdfs/localhost@hadoop.apache.org
- HTTP/localhost@hadoop.apache.org
- mapred/localhost@hadoop.apache.org
- hiveserver2/localhost@hadoop.apache.org
- alice@hadoop.apache.org
2) Configure Apache Hadoop to use Kerberos
The next step is to configure Apache Hadoop to use Kerberos. As a pre-requisite, follow the first tutorial on Apache Hive so that the Hadoop data and Hive table are set up before we apply Kerberos to the mix. Next, follow the steps in section (2) of an earlier tutorial on configuring Hadoop with Kerberos that I wrote. Some additional steps are also required when configuring Hadoop for use with Hive.
Edit 'etc/hadoop/core-site.xml' and add:
- hadoop.proxyuser.hiveserver2.groups: *
- hadoop.proxyuser.hiveserver2.hosts: localhost
- mapreduce.framework.name: classic
- mapreduce.jobtracker.kerberos.principal: mapred/localhost@hadoop.apache.org
- mapreduce.jobtracker.keytab.file: Path to Kerby mapred.keytab (see above).
- mapreduce.tasktracker.keytab.file: mapred/localhost@hadoop.apache.org
- mapreduce.tasktracker.keytab.file: Path to Kerby mapred.keytab (see above).
- mapreduce.jobhistory.kerberos.principal: mapred/localhost@hadoop.apache.org
- mapreduce.jobhistory.keytab.file: Path to Kerby mapred.keytab (see above).
- sbin/start-dfs.sh
- sudo sbin/start-secure-dns.sh
Next we will configure Apache Hive to use Kerberos. Edit 'conf/hiveserver2-site.xml' and add the following properties:
- hive.server2.authentication: kerberos
- hive.server2.authentication.kerberos.principal: hiveserver2/localhost@hadoop.apache.org
- hive.server2.authentication.kerberos.keytab: Path to Kerby hiveserver2.keytab (see above).
- export KRB5_CONFIG=/pathtokerby/target/krb5.conf
- kinit -k -t /pathtokerby/target/alice.keytab alice
- bin/beeline -u "jdbc:hive2://localhost:10000/default;principal=hiveserver2/localhost@hadoop.apache.org"
No comments:
Post a Comment