1 软件版本
kafka_2.12-2.4.0.tgz(带zookeeper)
2 kafka服务端部署
2.1 将安装包上传到服务器,并解压
tar zxvf kafka_2.12-2.4.0.tgz -C /data
mv kafka_2.12-2.4.0 kafka
2.2 修改kafka配置文件 server.properties
vim /data/kafka/config/server.properties:
############################# Server Basics #############################
# The id of the broker. This must be set to a unique integer for each broker.
broker.id=0
host.name=10.7.2.201
listeners=SASL_PLAINTEXT://10.7.2.201:9092
advertised.listeners=SASL_PLAINTEXT://10.7.2.201:9092
security.inter.broker.protocol=SASL_PLAINTEXT
sasl.enabled.mechanisms=PLAIN
sasl.mechanism.inter.broker.protocol=PLAIN
authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer
allow.everyone.if.no.acl.found=true
2.3 添加SASL配置文件
在kafka安装目录下创建一个 kafka_server_jaas.conf 文件
vim /data/kafka/kafka_server_jaas.conf:
KafkaServer {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="adminpasswd"
user_admin="adminpasswd"
user_producer="producerpwd"
user_consumer="consumerpwd";
};
说明:该配置通过org.apache.org.apache.kafka.common.security.plain.PlainLoginModule由指定采用PLAIN机制,定义了用户。
- usemame和password指定该代理与集群其他代理初始化连接的用户名和密码
- "user_"为前缀后接用户名方式创建连接代理的用户名和密码,例如,user_p