文章目录
1. 环境
kafka版本:2.12-2.3.0
zookeeper版本:3.6.0
操作系统:CentOS7
2. 创建主体并生成keytab
在kerberos中,用户和服务是平等的关系,都是以principal的形式存在
$ kadmin.local
# kafka broker,zookeeper,kafka client主体
# 其中stream.dt.local表示kafka broker所在主机的FQDN,Fully Qualified Domain Name的缩写, 含义是完整的域名
$ kadmin.local: addprinc kafka/stream.dt.local@EXAMPLE.COM
$ kadmin.local: addprinc zookeeper/stream.dt.local@EXAMPLE.COM
$ kadmin.local: addprinc clients/stream.dt.local@EXAMPLE.COM
# 生成主体对应的keytab文件
$ kadmin.local: xst -k /opt/third/kafka/kerberos/kafka_server.keytab
$ kadmin.local: xst -k /opt/third/zookeeper/kerberos/kafka_zookeeper.keytab
$ kadmin.local: xst -k /opt/third/kafka/kerberos/kafka_client.keytab
# 给keytab赋予可读权限
$ chmod -R 777 /opt/third/kafka/kerberos/kafka_server.keytab
$ chmod -R 777 /opt/third/zookeeper/kerberos/kafka_zookeeper.keytab
$ chmod -R 777 /opt/third/kafka/kerberos/kafka_client.keytab
设置FQDN的方式
$ cat /etc/hostname
demo-db
$ vim /etc/hosts
192.168.90.88 stream.dt.local demo-db
# 192.168.90.88是本机ip,stream.dt.local是要设置的FQDN,demo-db是主机名
3. 配置jaas.conf
/opt/third/kafka/kerberos/kafka_server_jaas.conf