1修改Kafka配置
1.1在Kafka的配置项搜索“security.inter.broker.protocol”,设置为SALS_PLAINTEXT
1.2在Kafka的配置项搜索“ssl.client.auth”,设置为none
2.创建配置文件
2.1创建jaas.conf文件
vim /var/lib/kafka/jaas.conf
KafkaClient {
com.sun.security.auth.module.Krb5LoginModule required
useTicketCache=true;
};
2.2创建cli.properties文件
vim /etc/kafka/conf/cli.properties
security.protocol=SASL_PLAINTEXT
sasl.kerberos.service.name=kafka
2.3声明jass.conf文件路径
vim /etc/profile
export KAFKA_OPTS="-Djava.security.auth.login.config=/var/lib/kafka/jaas.conf"
source /etc/profile
3.kafka生产消费
3.1生产者
kafka-console-producer --broker-list bigdb4:9092 --topic topic_test --producer.config /etc/kafka/conf/cli.properties
3.2消费者
kafka-console-consumer --bootstrap-server bigdb4:9092 --topic topic_test --from-beginning --consumer.config /etc/kafka/conf/cli.properties