为kafka开启kerberos

主节点安装

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

*/admin@HADOOP.COM  *

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管理账号
为kafka开启kerberos
将kerberos服务添加为开机启动

systemctl enable krb5kdc
systemctl enable kadmin
systemctl start krb5kdc
systemctl start kadmin

测试管理员账号
为kafka开启kerberos
为节点安装客户端

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
为kafka开启kerberos
为kafka开启kerberos
为kafka开启kerberos
krb5的一些命令

列出账号          kadmin.local -q "listprincs"
删除账号          kadmin.local -q 'delete_principal hdfs/bigdata-cdh01.kfk.com@HADOOP.COM'
创建账号指定密码  kadmin.local -q "addprinc  hdfs/bigdata-cdh01.kfk.com@bd00@HADOOP.COM" 
随机生成密码      kadmin.local -q "addprinc  -randkey  hdfs/bigdata-cdh01.kfk.com@HADOOP.COM"  
导出票据          kadmin.local -q "xst -k hdfs.keytab hdfs/bigdata-cdh01.kfk.com@HADOOP.COM"
登录              kinit -k -t hdfs.keytab hdfs/bigdata-cdh01.kfk.com@HADOOP.COM
查看过期时间      kadmin.local -q 'getprinc  krbtgt/HADOOP.COM@HADOOP.COM'
修改时间          kadmin.local -q 'modprinc -maxrenewlife "7d" krbtgt/HADOOP.COM@HADOOP.COM'
查看keytab内容    klist -e -k -t  zookeeper.keytab
不修改密码导出    kadmin.local -q 'xst -k hdfs.keytab -norandkey hdfs/bigdata-cdh01.kfk.com@HADOOP.COM'
退出登录          kdestroy

原创文章,作者:3628473679,如若转载,请注明出处:https://blog.ytso.com/tech/opensource/190504.html

(0)
上一篇 2021年11月14日 06:33
下一篇 2021年11月14日 06:33

相关推荐

发表回复

登录后才能评论