如何續約我用於 Amazon EMR 驗證的過期 Kerberos 票證?

2 分的閱讀內容
0

我在 Amazon EMR 叢集上使用 Kerberos 進行驗證。我的 Kerberos 票證已過期。當我嘗試在叢集上執行命令時,收到類似以下的錯誤訊息: 19/11/04 22:12:16 WARN ipc.Client: Exception encountered while connecting to the server : javax.security.sasl.SaslException: GSS initiate failed [Caused by GSSException: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)] ls: Failed on local exception: java.io.IOException: javax.security.sasl.SaslException: GSS initiate failed [Caused by GSSException: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)]; Host Details : local host is: "ip-xxx-x-x-x.ec2.internal/192.x.x.x";destination host is: "ip-xxx-x-x-x.ec2.internal":8020;

簡短說明

請執行下列動作以續約過期的 Kerberos 票證:

1、    執行 klist 命令以顯示金鑰分發中心 (KDC) 所發出的憑證。

2、    若要取得新票證,請執行 kinit 命令,然後指定包含憑證的 keytab 檔案,或輸入主體的密碼。

解決方法

1、    使用 SSH 連線至主節點

2、    若要確認票證已過期,請執行 klist 命令。此命令會檢查憑證快取。如果沒有快取任何憑證,則表示票證已過期。

[hadoop@ip-xxx-x-x-xxx ~]$ klist
klist: No credentials cache found (filename: /tmp/krb5cc_498)

3、    若要確認 Kerberos 主體名稱,請列出 keytab 檔案的內容:

[hadoop@ip-xxx-x-x-xxx ~]$ klist -kt /etc/hadoop.keytab
Keytab name: FILE:/etc/hadoop.keytab
KVNO Timestamp           Principal
---- ------------------- ------------------------------------------------------
   2 07/04/2019 21:48:46 hadoop/ip-xxx-x-x-xxx.ec2.internal@EC2.INTERNAL
   2 07/04/2019 21:48:46 hadoop/ip-xxx-x-x-xxx.ec2.internal@EC2.INTERNAL
   2 07/04/2019 21:48:46 hadoop/ip-xxx-x-x-xxx.ec2.internal@EC2.INTERNAL

4、    若要續約 Kerberos 票證,請執行 kinit 並同時指定 keytab 檔案和主體:

[hadoop@ip-xxx-x-x-xxx ~]$ kinit -kt /etc/hadoop.keytab hadoop/ip-xxx-x-x-xxx.ec2.internal@EC2.INTERNAL

5、    確認已快取憑證:

[hadoop@ip-xxx-x-x-xxx ~]$ klist
Ticket cache: FILE:/tmp/krb5cc_498
Default principal: hadoop/ip-xxx-x-x-xxx.ec2.internal@EC2.INTERNAL
Valid starting       Expires              Service principal
11/04/2019 22:13:47  11/05/2019 08:13:47  krbtgt/EC2.INTERNAL@EC2.INTERNAL
renew until 11/06/2019 22:13:47

6、    執行 HDFS 命令,以確認 Kerberos 票證正常工作:

[hadoop@ip-XXX-XX-XX-XXX ~]$ hdfs dfs -ls /
Found 4 items
drwxr-xr-x   - hdfs hadoop          0 2019-11-05 22:45 /apps
drwxrwxrwt   - hdfs hadoop          0 2019-11-05 22:46 /tmp
drwxr-xr-x   - hdfs hadoop          0 2019-11-05 22:45 /user
drwxr-xr-x   - hdfs hadoop          0 2019-11-05 22:45 /var

相關資訊

使用 Kerberos 驗證

AWS 官方
AWS 官方已更新 3 年前