项目场景:
kerberos配置hadoop ha時,重新創建一個新的普通用戶,測試其功能`
问题描述
kerberos配置hadoop ha時,重新創建了一個用戶xwq,讓其執行hadoop jar /opt/ha/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.1.3.jar pi 1 1命令,報錯如下:
[xwq@hadoop102 hive]$ hadoop jar /opt/ha/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.1.3.jar pi 1 1
Number of Maps = 1
Samples per Map = 1
2023-06-21 10:13:36,763 INFO sasl.SaslDataTransferClient: SASL encryption trust check: localHostTrusted = false, remoteHostTrusted = false
Wrote input for Map #0
Starting Job
2023-06-21 10:13:37,121 INFO hdfs.DFSClient: Created token for xwq: HDFS_DELEGATION_TOKEN owner=xwq@EXAMPLE.COM, renewer=yarn, realUser=, issueDate=1687313617117, maxDate=1687918417117, sequenceNumber=14, masterKeyId=12 on ha-hdfs:mycluster
2023-06-21 10:13:37,122 INFO security.TokenCache: Got dt for hdfs://mycluster; Kind: HDFS_DELEGATION_TOKEN, Service: ha-hdfs:mycluster, Ident: (token for xwq: HDFS_DELEGATION_TOKEN owner=xwq@EXAMPLE.COM, renewer=yarn, realUser=, issueDate=1687313617117, maxDate=1687918417117, sequenceNumber=14, masterKeyId=12)
2023-06-21 10:13:37,214 INFO mapreduce.JobResourceUploader: Disabling Erasure Coding for path: /tmp/hadoop-yarn/staging/xwq/.staging/job_1687309231357_0007
2023-06-21 10:13:37,241 INFO sasl.SaslDataTransferClient: SASL encryption trust check: localHostTrusted = false, remoteHostTrusted = false
2023-06-21 10:13:37,306 INFO input.FileInputFormat: Total input files to process : 1
2023-06-21 10:13:37,319 INFO sasl.SaslDataTransferClient: SASL encryption trust check: localHostTrusted = false, remoteHostTrusted = false
2023-06-21 10:13:37,342 INFO sasl.SaslDataTransferClient: SASL encryption trust check: localHostTrusted = false, remoteHostTrusted = false
2023-06-21 10:13:37,353 INFO mapreduce.JobSubmitter: number of splits:1
2023-06-21 10:13:37,448 INFO sasl.SaslDataTransferClient: SASL encryption trust check: localHostTrusted = false, remoteHostTrusted = false
2023-06-21 10:13:37,462 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1687309231357_0007
2023-06-21 10:13:37,462 INFO mapreduce.JobSubmitter: Executing with tokens: [Kind: HDFS_DELEGATION_TOKEN, Service: ha-hdfs:mycluster, Ident: (token for xwq: HDFS_DELEGATION_TOKEN owner=xwq@EXAMPLE.COM, renewer=yarn, realUser=, issueDate=1687313617117, maxDate=1687918417117, sequenceNumber=14, masterKeyId=12)]
2023-06-21 10:13:37,615 INFO conf.Configuration: resource-types.xml not found
2023-06-21 10:13:37,615 INFO resource.ResourceUtils: Unable to find 'resource-types.xml'.
2023-06-21 10:13:37,867 INFO impl.YarnClientImpl: Submitted application application_1687309231357_0007
2023-06-21 10:13:37,901 INFO mapreduce.Job: The url to track the job: http://hadoop102:8088/proxy/application_1687309231357_0007/
2023-06-21 10:13:37,902 INFO mapreduce.Job: Running job: job_1687309231357_0007
2023-06-21 10:13:44,994 INFO mapreduce.Job: Job job_1687309231357_0007 running in uber mode : false
2023-06-21 10:13:44,995 INFO mapreduce.Job: map 0% reduce 0%
2023-06-21 10:13:50,042 INFO mapreduce.Job: map 100% reduce 0%
2023-06-21 10:13:53,058 INFO mapreduce.Job: Task Id : attempt_1687309231357_0007_r_000000_1000, Status : FAILED
[2023-06-21 10:13:51.502]Application application_1687309231357_0007 initialization failed (exitCode=255) with output: main : command provided 0
main : run as user is xwq
main : requested yarn user is xwq
User xwq not found
解决方案:
在每hadoop集群的每台節點上都需要創建xwq用戶,執行如下命令:
useradd xwq
echo xwq | passwd --stdin xwq
usermod -a -G hadoop xwq
kadmin -p admin/admin -wNTVfPQY9kNs6 -q"addprinc -pw xwq xwq
然後再執行hadoop jar /opt/ha/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.1.3.jar pi 1 1命令,成功:
[xwq@hadoop102 ~]$ hadoop jar /opt/ha/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.1.3.jar pi 1 1
Number of Maps = 1
Samples per Map = 1
2023-06-21 10:27:07,443 INFO sasl.SaslDataTransferClient: SASL encryption trust check: localHostTrusted = false, remoteHostTrusted = false
Wrote input for Map #0
Starting Job
2023-06-21 10:27:07,754 INFO hdfs.DFSClient: Created token for xwq: HDFS_DELEGATION_TOKEN owner=xwq@EXAMPLE.COM, renewer=yarn, realUser=, issueDate=1687314427749, maxDate=1687919227749, sequenceNumber=16, masterKeyId=12 on ha-hdfs:mycluster
2023-06-21 10:27:07,755 INFO security.TokenCache: Got dt for hdfs://mycluster; Kind: HDFS_DELEGATION_TOKEN, Service: ha-hdfs:mycluster, Ident: (token for xwq: HDFS_DELEGATION_TOKEN owner=xwq@EXAMPLE.COM, renewer=yarn, realUser=, issueDate=1687314427749, maxDate=1687919227749, sequenceNumber=16, masterKeyId=12)
2023-06-21 10:27:07,838 INFO mapreduce.JobResourceUploader: Disabling Erasure Coding for path: /tmp/hadoop-yarn/staging/xwq/.staging/job_1687309231357_0009
2023-06-21 10:27:07,859 INFO sasl.SaslDataTransferClient: SASL encryption trust check: localHostTrusted = false, remoteHostTrusted = false
2023-06-21 10:27:07,925 INFO input.FileInputFormat: Total input files to process : 1
2023-06-21 10:27:07,939 INFO sasl.SaslDataTransferClient: SASL encryption trust check: localHostTrusted = false, remoteHostTrusted = false
2023-06-21 10:27:07,962 INFO sasl.SaslDataTransferClient: SASL encryption trust check: localHostTrusted = false, remoteHostTrusted = false
2023-06-21 10:27:07,974 INFO mapreduce.JobSubmitter: number of splits:1
2023-06-21 10:27:08,064 INFO sasl.SaslDataTransferClient: SASL encryption trust check: localHostTrusted = false, remoteHostTrusted = false
2023-06-21 10:27:08,079 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1687309231357_0009
2023-06-21 10:27:08,080 INFO mapreduce.JobSubmitter: Executing with tokens: [Kind: HDFS_DELEGATION_TOKEN, Service: ha-hdfs:mycluster, Ident: (token for xwq: HDFS_DELEGATION_TOKEN owner=xwq@EXAMPLE.COM, renewer=yarn, realUser=, issueDate=1687314427749, maxDate=1687919227749, sequenceNumber=16, masterKeyId=12)]
2023-06-21 10:27:08,222 INFO conf.Configuration: resource-types.xml not found
2023-06-21 10:27:08,222 INFO resource.ResourceUtils: Unable to find 'resource-types.xml'.
2023-06-21 10:27:08,474 INFO impl.YarnClientImpl: Submitted application application_1687309231357_0009
2023-06-21 10:27:08,508 INFO mapreduce.Job: The url to track the job: http://hadoop102:8088/proxy/application_1687309231357_0009/
2023-06-21 10:27:08,508 INFO mapreduce.Job: Running job: job_1687309231357_0009
2023-06-21 10:27:14,599 INFO mapreduce.Job: Job job_1687309231357_0009 running in uber mode : false
2023-06-21 10:27:14,600 INFO mapreduce.Job: map 0% reduce 0%
2023-06-21 10:27:20,649 INFO mapreduce.Job: map 100% reduce 0%
2023-06-21 10:27:24,667 INFO mapreduce.Job: map 100% reduce 100%
2023-06-21 10:27:25,676 INFO mapreduce.Job: Job job_1687309231357_0009 completed successfully
2023-06-21 10:27:25,752 INFO mapreduce.Job: Counters: 53File System CountersFILE: Number of bytes read=28FILE: Number of bytes written=452853FILE: Number of read operations=0FILE: Number of large read operations=0FILE: Number of write operations=0HDFS: Number of bytes read=258HDFS: Number of bytes written=215HDFS: Number of read operations=9HDFS: Number of large read operations=0HDFS: Number of write operations=3Job Counters Launched map tasks=1Launched reduce tasks=1Data-local map tasks=1Total time spent by all maps in occupied slots (ms)=3415Total time spent by all reduces in occupied slots (ms)=2005Total time spent by all map tasks (ms)=3415Total time spent by all reduce tasks (ms)=2005Total vcore-milliseconds taken by all map tasks=3415Total vcore-milliseconds taken by all reduce tasks=2005Total megabyte-milliseconds taken by all map tasks=3496960Total megabyte-milliseconds taken by all reduce tasks=2053120Map-Reduce FrameworkMap input records=1Map output records=2Map output bytes=18Map output materialized bytes=28Input split bytes=140Combine input records=0Combine output records=0Reduce input groups=2Reduce shuffle bytes=28Reduce input records=2Reduce output records=0Spilled Records=4Shuffled Maps =1Failed Shuffles=0Merged Map outputs=1GC time elapsed (ms)=83CPU time spent (ms)=1110Physical memory (bytes) snapshot=641515520Virtual memory (bytes) snapshot=5220311040Total committed heap usage (bytes)=1142947840Peak Map Physical memory (bytes)=371208192Peak Map Virtual memory (bytes)=2606309376Peak Reduce Physical memory (bytes)=270307328Peak Reduce Virtual memory (bytes)=2614001664Shuffle ErrorsBAD_ID=0CONNECTION=0IO_ERROR=0WRONG_LENGTH=0WRONG_MAP=0WRONG_REDUCE=0File Input Format Counters Bytes Read=118File Output Format Counters Bytes Written=97
Job Finished in 18.208 seconds
2023-06-21 10:27:25,809 INFO sasl.SaslDataTransferClient: SASL encryption trust check: localHostTrusted = false, remoteHostTrusted = false
Estimated value of Pi is 4.00000000000000000000