<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Accessing Hive from spark without using kinit in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Accessing-Hive-from-spark-without-using-kinit/m-p/128948#M22998</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I need to run spark (1.5.2) job in a kerberoized environment (I am currently testing on HDP 2.3.4 sandbox).  The job needs to be able to read and write to hive (I am using HiveContext).  Also I am using master = local[*], which is similar to spark-shell.&lt;/P&gt;&lt;P&gt;I am able to do this in spark by running kinit beforehand.  However is there any other way to authenticate programatically within the spark job?&lt;/P&gt;&lt;P&gt;e.g. I am about to read / write in kerberos hdfs by running the following before the spark code, without kinit.  Is there something similar I can do for hive:&lt;/P&gt;&lt;PRE&gt;
// following works for HDFS, but not for Hive
System.setProperty("java.security.krb5.conf", krb5ConfPath);
final Configuration newConf = new Configuration();
newConf.set(SERVER_PRINCIPAL_KEY, "spark-Sandbox@KRB.HDP");
newConf.set(SERVER_KEYTAB_KEY, keyTabPath);
    LOG.info("Logging in now... ******************* THIS REPLACE kinit **************************");
    org.apache.hadoop.security.SecurityUtil.login(newConf, SERVER_KEYTAB_KEY, SERVER_PRINCIPAL_KEY, "sandbox.hortonworks.com");
    LOG.info("Logged  in !!!    ******************* THIS REPLACE kinit **************************");
&lt;/PRE&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;UPDATE:&lt;/P&gt;&lt;P&gt;I have enabled lots of logging and tracked it down to the following differences in the log:&lt;/P&gt;&lt;P&gt;with kinit I get:&lt;/P&gt;&lt;PRE&gt;DEBUG	2016-03-16 11:12:09,557	6889	org.apache.hadoop.security.Groups	[main]	Group mapping impl=org.apache.hadoop.security.JniBasedUnixGroupsMappingWithFallback; cacheTimeout=300000; warningDeltaMs=5000
&amp;gt;&amp;gt;&amp;gt; KrbCreds found the default ticket granting ticket in credential cache.
&amp;gt;&amp;gt;&amp;gt; Obtained TGT from LSA: Credentials:
      client=spark-Sandbox@KRB.HDP
      server=krbtgt/KRB.HDP@KRB.HDP
    authTime=20160316111142Z
     endTime=20160317111142Z
   renewTill=null
       flags=FORWARDABLE;INITIAL
EType (skey)=17
   (tkt key)=18
DEBUG	2016-03-16 11:12:09,560	6892	org.apache.hadoop.security.UserGroupInformation	[main]	hadoop login
DEBUG	2016-03-16 11:12:09,561	6893	org.apache.hadoop.security.UserGroupInformation	[main]	hadoop login commit
DEBUG	2016-03-16 11:12:09,562	6894	org.apache.hadoop.security.UserGroupInformation	[main]	using kerberos user:spark-Sandbox@KRB.HDP
DEBUG	2016-03-16 11:12:09,562	6894	org.apache.hadoop.security.UserGroupInformation	[main]	Using user: "spark-Sandbox@KRB.HDP" with name spark-Sandbox@KRB.HDP
DEBUG	2016-03-16 11:12:09,562	6894	org.apache.hadoop.security.UserGroupInformation	[main]	User entry: "spark-Sandbox@KRB.HDP"
DEBUG	2016-03-16 11:12:09,565	6897	org.apache.hadoop.security.UserGroupInformation	[main]	UGI loginUser:spark-Sandbox@KRB.HDP (auth:KERBEROS)
DEBUG	2016-03-16 11:12:09,567	6899	org.apache.hadoop.security.UserGroupInformation	[TGT Renewer for spark-Sandbox@KRB.HDP]	Found tgt Ticket (hex) = 
&lt;/PRE&gt;&lt;P&gt;whereas at the moment login with code (and NO kinit) got me these:&lt;/P&gt;&lt;PRE&gt;DEBUG	2016-03-16 11:09:58,902	7194	org.apache.hadoop.security.Groups	[main]	Group mapping impl=org.apache.hadoop.security.JniBasedUnixGroupsMappingWithFallback; cacheTimeout=300000; warningDeltaMs=5000
&amp;gt;&amp;gt;&amp;gt;KinitOptions cache name is C:\Users\davidtam\krb5cc_davidtam
&amp;gt;&amp;gt; Acquire default native Credentials
Using builtin default etypes for default_tkt_enctypes
default etypes for default_tkt_enctypes: 17 16 23.
&amp;gt;&amp;gt;&amp;gt; Found no TGT's in LSA
DEBUG	2016-03-16 11:09:58,910	7202	org.apache.hadoop.security.UserGroupInformation	[main]	hadoop login
DEBUG	2016-03-16 11:09:58,910	7202	org.apache.hadoop.security.UserGroupInformation	[main]	hadoop login commit
DEBUG	2016-03-16 11:09:58,911	7203	org.apache.hadoop.security.UserGroupInformation	[main]	using kerberos user:null
DEBUG	2016-03-16 11:09:58,912	7204	org.apache.hadoop.security.UserGroupInformation	[main]	using local user:NTUserPrincipal: davidtam
DEBUG	2016-03-16 11:09:58,912	7204	org.apache.hadoop.security.UserGroupInformation	[main]	Using user: "NTUserPrincipal: davidtam" with name davidtam
DEBUG	2016-03-16 11:09:58,912	7204	org.apache.hadoop.security.UserGroupInformation	[main]	User entry: "davidtam"
DEBUG	2016-03-16 11:09:58,914	7206	org.apache.hadoop.security.UserGroupInformation	[main]	UGI loginUser:davidtam (auth:KERBEROS)
INFO	2016-03-16 11:09:58,931	7223	hive.metastore	[main]	Trying to connect to metastore with URI thrift://sandbox.hortonworks.com:9083
DEBUG	2016-03-16 11:09:58,963	7255	org.apache.hadoop.security.UserGroupInformation	[main]	PrivilegedAction as:c009003 (auth:KERBEROS) from:org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport.open(TUGIAssumingTransport.java:49)
DEBUG	2016-03-16 11:09:58,963	7255	org.apache.thrift.transport.TSaslTransport	[main]	opening transport org.apache.thrift.transport.TSaslClientTransport@7c206b14
&amp;gt;&amp;gt;&amp;gt;KinitOptions cache name is C:\Users\davidtam\krb5cc_davidtam
&amp;gt;&amp;gt; Acquire default native Credentials
Using builtin default etypes for default_tkt_enctypes
default etypes for default_tkt_enctypes: 17 16 23.
&amp;gt;&amp;gt;&amp;gt; Found no TGT's in LSA

&lt;/PRE&gt;&lt;P&gt;I am running on windows connecting to the sandbox.&lt;/P&gt;</description>
    <pubDate>Wed, 16 Mar 2016 00:27:44 GMT</pubDate>
    <dc:creator>David_Tam</dc:creator>
    <dc:date>2016-03-16T00:27:44Z</dc:date>
    <item>
      <title>Accessing Hive from spark without using kinit</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Accessing-Hive-from-spark-without-using-kinit/m-p/128948#M22998</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I need to run spark (1.5.2) job in a kerberoized environment (I am currently testing on HDP 2.3.4 sandbox).  The job needs to be able to read and write to hive (I am using HiveContext).  Also I am using master = local[*], which is similar to spark-shell.&lt;/P&gt;&lt;P&gt;I am able to do this in spark by running kinit beforehand.  However is there any other way to authenticate programatically within the spark job?&lt;/P&gt;&lt;P&gt;e.g. I am about to read / write in kerberos hdfs by running the following before the spark code, without kinit.  Is there something similar I can do for hive:&lt;/P&gt;&lt;PRE&gt;
// following works for HDFS, but not for Hive
System.setProperty("java.security.krb5.conf", krb5ConfPath);
final Configuration newConf = new Configuration();
newConf.set(SERVER_PRINCIPAL_KEY, "spark-Sandbox@KRB.HDP");
newConf.set(SERVER_KEYTAB_KEY, keyTabPath);
    LOG.info("Logging in now... ******************* THIS REPLACE kinit **************************");
    org.apache.hadoop.security.SecurityUtil.login(newConf, SERVER_KEYTAB_KEY, SERVER_PRINCIPAL_KEY, "sandbox.hortonworks.com");
    LOG.info("Logged  in !!!    ******************* THIS REPLACE kinit **************************");
&lt;/PRE&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;UPDATE:&lt;/P&gt;&lt;P&gt;I have enabled lots of logging and tracked it down to the following differences in the log:&lt;/P&gt;&lt;P&gt;with kinit I get:&lt;/P&gt;&lt;PRE&gt;DEBUG	2016-03-16 11:12:09,557	6889	org.apache.hadoop.security.Groups	[main]	Group mapping impl=org.apache.hadoop.security.JniBasedUnixGroupsMappingWithFallback; cacheTimeout=300000; warningDeltaMs=5000
&amp;gt;&amp;gt;&amp;gt; KrbCreds found the default ticket granting ticket in credential cache.
&amp;gt;&amp;gt;&amp;gt; Obtained TGT from LSA: Credentials:
      client=spark-Sandbox@KRB.HDP
      server=krbtgt/KRB.HDP@KRB.HDP
    authTime=20160316111142Z
     endTime=20160317111142Z
   renewTill=null
       flags=FORWARDABLE;INITIAL
EType (skey)=17
   (tkt key)=18
DEBUG	2016-03-16 11:12:09,560	6892	org.apache.hadoop.security.UserGroupInformation	[main]	hadoop login
DEBUG	2016-03-16 11:12:09,561	6893	org.apache.hadoop.security.UserGroupInformation	[main]	hadoop login commit
DEBUG	2016-03-16 11:12:09,562	6894	org.apache.hadoop.security.UserGroupInformation	[main]	using kerberos user:spark-Sandbox@KRB.HDP
DEBUG	2016-03-16 11:12:09,562	6894	org.apache.hadoop.security.UserGroupInformation	[main]	Using user: "spark-Sandbox@KRB.HDP" with name spark-Sandbox@KRB.HDP
DEBUG	2016-03-16 11:12:09,562	6894	org.apache.hadoop.security.UserGroupInformation	[main]	User entry: "spark-Sandbox@KRB.HDP"
DEBUG	2016-03-16 11:12:09,565	6897	org.apache.hadoop.security.UserGroupInformation	[main]	UGI loginUser:spark-Sandbox@KRB.HDP (auth:KERBEROS)
DEBUG	2016-03-16 11:12:09,567	6899	org.apache.hadoop.security.UserGroupInformation	[TGT Renewer for spark-Sandbox@KRB.HDP]	Found tgt Ticket (hex) = 
&lt;/PRE&gt;&lt;P&gt;whereas at the moment login with code (and NO kinit) got me these:&lt;/P&gt;&lt;PRE&gt;DEBUG	2016-03-16 11:09:58,902	7194	org.apache.hadoop.security.Groups	[main]	Group mapping impl=org.apache.hadoop.security.JniBasedUnixGroupsMappingWithFallback; cacheTimeout=300000; warningDeltaMs=5000
&amp;gt;&amp;gt;&amp;gt;KinitOptions cache name is C:\Users\davidtam\krb5cc_davidtam
&amp;gt;&amp;gt; Acquire default native Credentials
Using builtin default etypes for default_tkt_enctypes
default etypes for default_tkt_enctypes: 17 16 23.
&amp;gt;&amp;gt;&amp;gt; Found no TGT's in LSA
DEBUG	2016-03-16 11:09:58,910	7202	org.apache.hadoop.security.UserGroupInformation	[main]	hadoop login
DEBUG	2016-03-16 11:09:58,910	7202	org.apache.hadoop.security.UserGroupInformation	[main]	hadoop login commit
DEBUG	2016-03-16 11:09:58,911	7203	org.apache.hadoop.security.UserGroupInformation	[main]	using kerberos user:null
DEBUG	2016-03-16 11:09:58,912	7204	org.apache.hadoop.security.UserGroupInformation	[main]	using local user:NTUserPrincipal: davidtam
DEBUG	2016-03-16 11:09:58,912	7204	org.apache.hadoop.security.UserGroupInformation	[main]	Using user: "NTUserPrincipal: davidtam" with name davidtam
DEBUG	2016-03-16 11:09:58,912	7204	org.apache.hadoop.security.UserGroupInformation	[main]	User entry: "davidtam"
DEBUG	2016-03-16 11:09:58,914	7206	org.apache.hadoop.security.UserGroupInformation	[main]	UGI loginUser:davidtam (auth:KERBEROS)
INFO	2016-03-16 11:09:58,931	7223	hive.metastore	[main]	Trying to connect to metastore with URI thrift://sandbox.hortonworks.com:9083
DEBUG	2016-03-16 11:09:58,963	7255	org.apache.hadoop.security.UserGroupInformation	[main]	PrivilegedAction as:c009003 (auth:KERBEROS) from:org.apache.hadoop.hive.thrift.client.TUGIAssumingTransport.open(TUGIAssumingTransport.java:49)
DEBUG	2016-03-16 11:09:58,963	7255	org.apache.thrift.transport.TSaslTransport	[main]	opening transport org.apache.thrift.transport.TSaslClientTransport@7c206b14
&amp;gt;&amp;gt;&amp;gt;KinitOptions cache name is C:\Users\davidtam\krb5cc_davidtam
&amp;gt;&amp;gt; Acquire default native Credentials
Using builtin default etypes for default_tkt_enctypes
default etypes for default_tkt_enctypes: 17 16 23.
&amp;gt;&amp;gt;&amp;gt; Found no TGT's in LSA

&lt;/PRE&gt;&lt;P&gt;I am running on windows connecting to the sandbox.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 00:27:44 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Accessing-Hive-from-spark-without-using-kinit/m-p/128948#M22998</guid>
      <dc:creator>David_Tam</dc:creator>
      <dc:date>2016-03-16T00:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing Hive from spark without using kinit</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Accessing-Hive-from-spark-without-using-kinit/m-p/128949#M22999</link>
      <description>&lt;P&gt;Did you tired to use below properties as command line parameter while running spark-submit? Also there were few issues related to spark kerberos in spark 1.4 and 1.5 so its better to try this on spark 1.6 release.&lt;/P&gt;&lt;P&gt; --principal &amp;lt;principle name&amp;gt; --keytab /etc/security/keytabs/spark.keytab&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 12:30:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Accessing-Hive-from-spark-without-using-kinit/m-p/128949#M22999</guid>
      <dc:creator>jyadav</dc:creator>
      <dc:date>2016-03-16T12:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing Hive from spark without using kinit</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Accessing-Hive-from-spark-without-using-kinit/m-p/128950#M23000</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/2528/jyadav.html" nodeid="2528"&gt;@Jitendra Yadav&lt;/A&gt; thanks for your reply.  I believe these are for yarn while I am trying to run master = local[*], similar to spark-shell on sandbox.&lt;/P&gt;&lt;P&gt;I am using spark 1.5.2 on HDP 2.3.4&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 20:00:06 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Accessing-Hive-from-spark-without-using-kinit/m-p/128950#M23000</guid>
      <dc:creator>David_Tam</dc:creator>
      <dc:date>2016-03-16T20:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing Hive from spark without using kinit</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Accessing-Hive-from-spark-without-using-kinit/m-p/128951#M23001</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/2311/davidtam.html" nodeid="2311"&gt;@David Tam&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The same conf's should work for local mode also, initially it made for YARN only then later it applicable for local mode also. As I said earlier that it's better to try it on spark 1.6 version. &lt;/P&gt;&lt;P&gt;Please refer this Jira and it's Pull requests :- &lt;A href="https://issues.apache.org/jira/browse/SPARK-11821" target="_blank"&gt;https://issues.apache.org/jira/browse/SPARK-11821&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 20:30:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Accessing-Hive-from-spark-without-using-kinit/m-p/128951#M23001</guid>
      <dc:creator>jyadav</dc:creator>
      <dc:date>2016-03-16T20:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing Hive from spark without using kinit</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Accessing-Hive-from-spark-without-using-kinit/m-p/128952#M23002</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/2528/jyadav.html" nodeid="2528"&gt;@Jitendra Yadav&lt;/A&gt; thanks just had a look at the jira.  I think in this case I will need to wait until we upgrade to spark 1.6 then.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 21:14:13 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Accessing-Hive-from-spark-without-using-kinit/m-p/128952#M23002</guid>
      <dc:creator>David_Tam</dc:creator>
      <dc:date>2016-03-16T21:14:13Z</dc:date>
    </item>
  </channel>
</rss>

