1、在 consumer.properties 、producer.properties 底部添加配置、
security.protocol=SASL_PLAINTEXT
sasl.mechanism=PLAIN
2、在 server.properties 文件中添加
security.inter.broker.protocol=SASL_PLAINTEXT
sasl.mechanism.inter.broker.protocol=PLAIN
sasl.enabled.mechanisms=PLAIN
authorizer.class.name = kafka.security.auth.SimpleAclAuthorizer
super.users=User:admin
3、启动配置修改 kafka-server-start.sh
export KAFKA_OPTS="-Djava.security.auth.login.config=/opt/kafka_2.12-2.1.1/config/kafka_server_jaas.conf"
4、zookper启动文件修改 zookeeper-server-start.sh
export KAFKA_OPTS=" -Djava.security.auth.login.config=/opt/kafka_2.12-2.1.1/config/kafka_zoo_jaas.conf”
5、添加新文件 kafka_server_jaas.conf
KafkaServer {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="ao123456c"
user_admin="ao123456c"
user_alice="Q3123456P";
};
KafkaClient {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="ao123456c";
};
6、添加新文件 kafka_zoo_jaas.conf
zookeeper {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="alice"
password="Q3123456P";
};
网友评论