Kerberos ticket lifetime及其它


前言

之前的博文中涉及到了Kerberos的內容,這里對Kerberos ticket lifetime相關的內容做一個補充。

ticket lifetime

Kerberos ticket具有lifetime,超過此時間則ticket就會過期,需要重新申請或renew。ticket lifetime取決於以下5項設置中的最小值:

  • Kerberos server上/var/kerberos/krb5kdc/kdc.conf中max_life
  • 內置principal krbtgt的maximum ticket life,可在kadmin命令行下用getprinc命令查看
  • 你的principal的maximum ticket life,可在kadmin命令行下用getprinc命令查看
  • Kerberos client上/etc/krb5.conf的ticket_lifetime
  • kinit -l 參數后面指定的時間

ticket renew lifetime

ticket過期后,如果想延長,一種方法是重新申請(需要輸入密碼),另一種是renew(不需要輸入密碼),每renew一次,就延長一個lifetime。不過renew操作本身也有lifetime,即在ticket renew lifetime,在此lifetime之內,才能進行renew操作。與上面的很相似,ticket renew lifetime取決於以下5項設置中的最小值:

  • Kerberos server上/var/kerberos/krb5kdc/kdc.conf中max_renewable_life
  • 內置principal krbtgt的maximum renewable life,可在kadmin命令行下用getprinc命令查看
  • 你的principal的maximum renewable life,可在kadmin命令行下用getprinc命令查看
  • Kerberos client上/etc/krb5.conf的renew_lifetime
  • kinit -r 參數后面指定的時間

HBase與ticket lifetime

HBase需要長時間運行,它對ticket過期問題的處理見org.apache.hadoop.hbase.ipc.RpcClient,方法handleSaslConnectionFailure(),方法注釋中提到HBase是嘗試自動relogin,從代碼上看應該是直接獲取一個新的ticket,而不是進行renew。

The other problem is to do with ticket expiry. To handle that, a relogin is attempted.
The retry logic is governed by the shouldAuthenticateOverKrb method. In case when the user doesn't have valid credentials, we don't need to retry (from cache or ticket). In such cases, it is prudent to throw a runtime exception when we receive a SaslException from the underlying authentication implementation, so there is no retry from other high level (for eg, HCM or HBaseAdmin).

 

另外:

[org.apache.hadoop.security.UserGroupInformation] Not attempting to re-login since the last re-login was attempted less than 600 seconds before.

這個錯誤實際是由於UserGroupInformation中的一個hard code值引起的,MIN_TIME_BEFORE_RELOGIN=10*60*1000L,是hadoop自己做出的限制,即不允許過於頻繁地relogin,需要將ticket_lifetime設置為大於10分鍾即可。

keytab與ticket lifetime

keytab文件實際只是一個密碼文件,顯然,修改lifetime相關設置跟密碼是沒有關系的,不需要去重新生成現有的keytab文件。

一些命令

  • kadmin: modprinc -maxrenewlife 11days +allow_renewable {principal}
  • kadmin: modprinc -maxlife 6minutes {principal}
  • kadmin: getprinc {principal} //retrieve the detail info of principal
  • kinit -R //renew current ticket
  • kinit {principal} -kt {keytab file} //init a principal via keytab file


送書了,送書了,關注公眾號“程序員雜書館”,就送出O'Reilly《Spark快速大數據分析》紙質書(亦有一批PDF分享)! —— 2018年12月


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM