kafka_kdc认证版本客户端对接
kafka 通过kdc认证消费topic 配置:
一、kafka消费客户端主机要安装kerberos客户端:
yum install krber*
二、kafka消费客户端主机配置kerberos文件:/etc/krb5.conf
[root@dcdl-test-datanode1 ckm]# cat /etc/krb5.conf
includedir /var/lib/sss/pubconf/krb5.include.d/
[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log
[libdefaults]
default_realm = ESSENCE.COM
dns_lookup_realm = false
dns_lookup_kdc = true
rdns = false
ticket_lifetime = 24h
renew_lifetime = 7d
forwardable = true
udp_preference_limit = 1
#udp_preference_limit = 1 是否有开启udp端口
# default_ccache_name = KEYRING:persistent:%{uid}
[realms]
ESSENCE.COM = {
kdc = dcdl-test-datanode2.essence.com:88
master_kdc = dcdl-test-datanode2.essence.com:88
admin_server = dcdl-test-datanode2.essence.com:749
kpasswd_server = dcdl-test-datanode2.essence.com:464
default_domain = dcdl-test-datanode2.essence.com
pkinit_anchors = FILE:/etc/ipa/ca.crt
}
[domain_realm]
.essence.com = ESSENCE.COM
essence.com = ESSENCE.COM
dcdl-test-datanode1.essence.com = ESSENCE.COM
dcdl-test-namenode1.essence.com = ESSENCE.COM
server.essence.com = ESSENCE.COM
client.essence.com = ESSENCE.COM
[dbmodules]
ESSENCE.COM = {
db_library = ipadb.so
}
三、 把kafka bootstrap-server主机加入 /etc/hsots
10.2.98.128 dcdl-test-namenode1.essence.com dcdl-test-namenode1
10.2.98.129 dcdl-test-datanode1.essence.com dcdl-test-datanode1
10.2.98.130 dcdl-test-datanode2.essence.com dcdl-test-datanode2
10.2.98.131 dcdl-test-datanode3.essence.com dcdl-test-datanode3
10.2.98.128 dcdl-test-namenode1.essence.com 9092
10.2.98.129 dcdl-test-datanode1.essence.com 9092
10.2.98.130 dcdl-test-datanode2.essence.com 9092
10.2.98.131 dcdl-test-datanode3.essence.com 9092
四、向数据平台组申请kafka消费用户(示例,真实环境用户名按规范命名):kafka_test ;并生成密码文件:kafka_test.keytab
使用密码文件在kafka消费客户端主机验证登录 :
>$ kinit -kt /**/**/kafka_test.keytab kafka_test
>$ klist
正常显示如下:
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: kafka_test@ESSENCE.COM
Valid starting Expires Service principal
08/20/2020 15:39:59 08/21/2020 15:39:53 krbtgt/ESSENCE.COM@ESSENCE.COM
renew until 08/27/2020 15:39:5
五、 向数据平台组 申请创建topic , 并AR同步所需求的表数据到对应的topic里。
六、准备配置文件client.properties;jaas-keytab.conf :
>$ cat client.properties
security.protocol=SASL_PLAINTEXT
sasl.kerberos.service.name=kafka
group.id=testgroup
>$ cat jaas-keytab.conf
KafkaClient{
com.sun.security.auth.module.Krb5LoginModule required
useKeyTab=true
keyTab="/home/kafka_test/kafka_test.keytab"
principal="kafka_test@ESSENCE.COM";
};
七,加载 jaas-keytab.conf文件:
>$ export KAFKA_OPTS="-Djava.security.auth.login.config=/home/epass_app/jaas-keytab.conf"
八、kafka生产者示例
kafka-console-producer --broker-list dcdl-test-datanode2.essence.com:9092,dcdl-test-datanode1.essence.com:9092,dcdl-test-datanode3.essence.com:9092 --topic kbsstopics --producer.config client.properties
九、命令行消费测试:
kafka-console-consumer --topic kbsstopics --from-beginning --bootstrap-server dcdl-test-datanode2.essence.com:9092,dcdl-test-datanode1.essence.com:9092,dcdl-test-datanode3.essence.com:9092 --consumer.config client.properties
十、请用户申请开通网络防火墙,用户客户服务器访问kafka集服务器(需要访问kafka集群用户人员)
10.2.98.128
10.2.98.129
10.2.98.130
10.2.98.131
端口:88,749,464,2181,9092
十一、kafka集群服务器修改防火墙,加入客户端服务器IP(kafka集群运维人员)