File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ title : kafka认证配置
3+ ---
4+
5+ # 服务器
6+ ``` conf
7+
8+ # 关键点
9+ sasl.enabled.mechanisms=PLAIN,SCRAM-SHA-256
10+
11+ # listener.name.client.scram-sha-256.sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required \
12+ # username="admin" \
13+ # password="admin-secret";
14+ # listener.name.client.plain.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
15+ # username="admin" \
16+ # password="admin-secret" \
17+ # user_admin="admin-secret" \
18+ # user_alice="alice-secret";
19+ ```
20+ # 服务器jaas.conf
21+ ``` conf
22+ client1.KafkaServer {
23+ org.apache.kafka.common.security.plain.PlainLoginModule required
24+ username="admin"
25+ password="admin-secret"
26+ user_admin="admin-secret"
27+ user_alice="alice-secret";
28+ };
29+
30+ ```
31+
32+ # 服务器启动
33+ ``` bash
34+ export KAFKA_OPTS=" -Djava.security.auth.login.config=/mnt/d/devapps/kafka/kafka_2.13-4.0.0/kafka_server_jaas.conf"
35+ bin/kafka-server-start.sh config/server.properties
36+ ```
37+
38+ # 客户端
39+
40+ ``` conf
41+ # 三个属性都不能缺
42+ sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
43+ username="alice" \
44+ password="alice-secret";
45+
46+ security.protocol=SASL_PLAINTEXT
47+ sasl.mechanism=PLAIN
48+
49+ ```
50+
51+ # 客户端命令
52+ ``` bash
53+ bin/kafka-topics.sh --bootstrap-server localhost:9094 --list --command-config kafka-client-props.conf
54+ ```
You can’t perform that action at this time.
0 commit comments