Friday, December 1, 2017

Login as hive user in Keberos security enabled cluster

[root@cdh-vm ~]# klist -e -k -t /var/run/cloudera-scm-agent/process/71-hive-HIVESERVER2/hive.keytab
Keytab name: FILE:/var/run/cloudera-scm-agent/process/71-hive-HIVESERVER2/hive.keytab
KVNO Timestamp           Principal
---- ------------------- ------------------------------------------------------
   2 12/01/2017 05:38:04 HTTP/cdh-vm.dbaglobe.com@DBAGLOBE.COM (aes256-cts-hmac-sha1-96)
   2 12/01/2017 05:38:04 HTTP/cdh-vm.dbaglobe.com@DBAGLOBE.COM (aes128-cts-hmac-sha1-96)
   2 12/01/2017 05:38:04 hive/cdh-vm.dbaglobe.com@DBAGLOBE.COM (aes256-cts-hmac-sha1-96)
   2 12/01/2017 05:38:04 hive/cdh-vm.dbaglobe.com@DBAGLOBE.COM (aes128-cts-hmac-sha1-96)
  
[root@cdh-vm ~]# kinit -t /var/run/cloudera-scm-agent/process/71-hive-HIVESERVER2/hive.keytab hive/cdh-vm.dbaglobe.com@DBAGLOBE.COM
keytab specified, forcing -k
[root@cdh-vm ~]# beeline
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0
Beeline version 1.1.0-cdh5.13.0 by Apache Hive
beeline> ! connect jdbc:hive2://cdh-vm.dbaglobe.com:10000/default;principal=hive/cdh-vm.dbaglobe.com@DBAGLOBE.COM
Connecting to jdbc:hive2://cdh-vm.dbaglobe.com:10000/default;principal=hive/cdh-vm.dbaglobe.com@DBAGLOBE.COM
Connected to: Apache Hive (version 1.1.0-cdh5.13.0)
Driver: Hive JDBC (version 1.1.0-cdh5.13.0)
Transaction isolation: TRANSACTION_REPEATABLE_READ
1: jdbc:hive2://cdh-vm.dbaglobe.com:10000/def> show tables;
INFO  : Compiling command(queryId=hive_20171201094646_eb78fb37-f047-4ae7-a2de-4bff5d7d1fc4): show tables
INFO  : Semantic Analysis Completed
INFO  : Returning Hive schema: Schema(fieldSchemas:[FieldSchema(name:tab_name, type:string, comment:from deserializer)], properties:null)
INFO  : Completed compiling command(queryId=hive_20171201094646_eb78fb37-f047-4ae7-a2de-4bff5d7d1fc4); Time taken: 0.058 seconds
INFO  : Executing command(queryId=hive_20171201094646_eb78fb37-f047-4ae7-a2de-4bff5d7d1fc4): show tables
INFO  : Starting task [Stage-0:DDL] in serial mode
INFO  : Completed executing command(queryId=hive_20171201094646_eb78fb37-f047-4ae7-a2de-4bff5d7d1fc4); Time taken: 0.049 seconds
INFO  : OK
+--------------+--+
|   tab_name   |
+--------------+--+
| iotdatademo  |
+--------------+--+
1 row selected (0.275 seconds)
1: jdbc:hive2://cdh-vm.dbaglobe.com:10000/def> select count(*) from iotdatademo;
INFO  : Compiling command(queryId=hive_20171201094747_db58f27f-5e08-4d3c-8b01-8c2dffcdb048): select count(*) from iotdatademo
INFO  : Semantic Analysis Completed
INFO  : Returning Hive schema: Schema(fieldSchemas:[FieldSchema(name:_c0, type:bigint, comment:null)], properties:null)
INFO  : Completed compiling command(queryId=hive_20171201094747_db58f27f-5e08-4d3c-8b01-8c2dffcdb048); Time taken: 0.24 seconds
INFO  : Executing command(queryId=hive_20171201094747_db58f27f-5e08-4d3c-8b01-8c2dffcdb048): select count(*) from iotdatademo
INFO  : Query ID = hive_20171201094747_db58f27f-5e08-4d3c-8b01-8c2dffcdb048
INFO  : Total jobs = 1
INFO  : Launching Job 1 out of 1
INFO  : Starting task [Stage-1:MAPRED] in serial mode
INFO  : Number of reduce tasks determined at compile time: 1
INFO  : In order to change the average load for a reducer (in bytes):
INFO  :   set hive.exec.reducers.bytes.per.reducer=<number>
INFO  : In order to limit the maximum number of reducers:
INFO  :   set hive.exec.reducers.max=<number>
INFO  : In order to set a constant number of reducers:
INFO  :   set mapreduce.job.reduces=<number>
INFO  : number of splits:1
INFO  : Submitting tokens for job: job_1512125736892_0001
INFO  : Kind: HDFS_DELEGATION_TOKEN, Service: 192.168.56.10:8020, Ident: (token for hive: HDFS_DELEGATION_TOKEN owner=hive, renewer=yarn, realUser=hive/cdh-vm.dbaglobe.com@DBAGLOBE.COM, issueDate=1512139631029, maxDate=1512744431029, sequenceNumber=13, masterKeyId=4)
INFO  : Kind: HIVE_DELEGATION_TOKEN, Service: HiveServer2ImpersonationToken, Ident: 00 04 68 69 76 65 04 68 69 76 65 25 68 69 76 65 2f 63 64 68 2d 76 6d 2e 64 62 61 67 6c 6f 62 65 2e 63 6f 6d 40 44 42 41 47 4c 4f 42 45 2e 43 4f 4d 8a 01 60 12 8a de 08 8a 01 60 36 97 62 08 03 01
INFO  : The url to track the job:
http://cdh-vm.dbaglobe.com:8088/proxy/application_1512125736892_0001/
INFO  : Starting Job = job_1512125736892_0001, Tracking URL = http://cdh-vm.dbaglobe.com:8088/proxy/application_1512125736892_0001/
INFO  : Kill Command = /opt/cloudera/parcels/CDH-5.13.0-1.cdh5.13.0.p0.29/lib/hadoop/bin/hadoop job  -kill job_1512125736892_0001
INFO  : Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 1
INFO  : 2017-12-01 09:47:22,750 Stage-1 map = 0%,  reduce = 0%
INFO  : 2017-12-01 09:47:29,124 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 1.98 sec
INFO  : 2017-12-01 09:47:35,467 Stage-1 map = 100%,  reduce = 100%, Cumulative CPU 4.17 sec
INFO  : MapReduce Total cumulative CPU time: 4 seconds 170 msec
INFO  : Ended Job = job_1512125736892_0001
INFO  : MapReduce Jobs Launched:
INFO  : Stage-Stage-1: Map: 1  Reduce: 1   Cumulative CPU: 4.17 sec   HDFS Read: 46846061 HDFS Write: 7 SUCCESS
INFO  : Total MapReduce CPU Time Spent: 4 seconds 170 msec
INFO  : Completed executing command(queryId=hive_20171201094747_db58f27f-5e08-4d3c-8b01-8c2dffcdb048); Time taken: 26.647 seconds
INFO  : OK
+---------+--+
|   _c0   |
+---------+--+
| 864010  |
+---------+--+
1 row selected (26.958 seconds)
1: jdbc:hive2://cdh-vm.dbaglobe.com:10000/def> !exit
Closing: 1: jdbc:hive2://cdh-vm.dbaglobe.com:10000/default;principal=hive/cdh-vm.dbaglobe.com@DBAGLOBE.COM