1、启动zookeeper
./zookeeper-server-start.sh ../config/zookeeper.properties &
2、config文件夹新建文件 kafka_server_jaas.conf
KafkaServer {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin"
user_admin="admin"
user_read="read";
};
3、修改kafka-server-start.sh在最前面添加
export KAFKA_OPTS=" -Djava.security.auth.login.config=/kafka/config/kafka_server_jaas.conf"
4、修改server.properties添加,修改对应IP和端口
3.0版本以前:
listeners=SASL_PLAINTEXT://192.168.X.X:9092
security.inter.broker.protocol=SASL_PLAINTEXT
sasl.mechanism.inter.broker.protocol=PLAIN
sasl.enabled.mechanisms=PLAIN
allow.everyone.if.no.acl.found=false
authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer
allow.everyone.if.no.acl.found=true
auto.create.topics.enable=true
delete.topic.enable=true
super.users=User:admin
3.0版本以后:
listeners=SASL_PLAINTEXT://192.168.X.X:9092
security.inter.broker.protocol=SASL_PLAINTEXT
sasl.mechanism.inter.broker.protocol=PLAIN
sasl.enabled.mechanisms=PLAIN
allow.everyone.if.no.acl.found=false
authorizer.class.name=kafka.security.authorizer.AclAuthorizer
allow.everyone.if.no.acl.found=true
auto.create.topics.enable=true
delete.topic.enable=true
super.users=User:admin
5、启动kafka
./kafka-server-start.sh ../config/server.properties &