主節點安裝
yum -y install krb5-server krb5-libs krb5-auth-dialog krb5-workstation
cat /etc/krb5.conf
Configuration snippets may be placed in this directory as well
includedir /etc/krb5.conf.d/
[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log
[libdefaults]
default_realm = HADOOP.COM
dns_lookup_realm = false
dns_lookup_kdc = false
ticket_lifetime = 24h
renew_lifetime = 7d
forwardable = true
rdns = false
# default_realm = EXAMPLE.COM
# default_ccache_name = KEYRING:persistent:%{uid}
[realms]
HADOOP.COM = {
kdc = bigdata-cdh01.kfk.com
admin_server = bigdata-cdh01.kfk.com
}
[domain_realm]
.bigdata-cdh01.kfk.com = HADOOP.COM
bigdata-cdh01.kfk.com = HADOOP.COM
cat /var/kerberos/krb5kdc/kadm5.acl
*/[email protected] *
cat /var/kerberos/krb5kdc/kdc.conf
[kdcdefaults]
kdc_ports = 88
kdc_tcp_ports = 88
[realms]
HADOOP.COM = {
#master_key_type = aes256-cts
max_renewable_life= 7d 0h 0m 0s
acl_file = /var/kerberos/krb5kdc/kadm5.acl
dict_file = /usr/share/dict/words
admin_keytab = /var/kerberos/krb5kdc/kadm5.keytab
supported_enctypes = aes256-cts:normal aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal camellia256-cts:normal camellia128-cts:normal des-hmac-sha1:normal des-cbc-md5:normal des-cbc-crc:normal
}
創建kerberos數據庫
kdb5_util create -r HADOOP.COM -s
創建kerberos管理賬號
將kerberos服務添加爲開機啓動
systemctl enable krb5kdc
systemctl enable kadmin
systemctl start krb5kdc
systemctl start kadmin
測試管理員賬號
爲節點安裝客戶端
yum -y install krb5-libs krb5-auth-dialog krb5-workstation
在主節點上安裝額外的包
yum -y install openldap-clients
將krb5.conf文件拷貝到所有kerberos客戶端(批量拷貝)
#!/bin/bash
for i in `cat node.list`
do
scp -r $2 $i:$3
done
sh scp.sh node.list /etc/krb5.conf /etc/
啓動kerberos
爲kafka開啓kerberos
krb5的一些命令
列出賬號 kadmin.local -q "listprincs"
刪除賬號 kadmin.local -q 'delete_principal hdfs/[email protected]'
創建賬號指定密碼 kadmin.local -q "addprinc hdfs/bigdata-cdh01.kfk.com@[email protected]"
隨機生成密碼 kadmin.local -q "addprinc -randkey hdfs/[email protected]"
導出票據 kadmin.local -q "xst -k hdfs.keytab hdfs/[email protected]"
登錄 kinit -k -t hdfs.keytab hdfs/[email protected]
查看過期時間 kadmin.local -q 'getprinc krbtgt/[email protected]'
修改時間 kadmin.local -q 'modprinc -maxrenewlife "7d" krbtgt/[email protected]'
查看keytab內容 klist -e -k -t zookeeper.keytab
不修改密碼導出 kadmin.local -q 'xst -k hdfs.keytab -norandkey hdfs/[email protected]'
退出登錄 kdestroy