Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Summary of authentication configuration of kafka under windows

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Create a kafka_server_jaas.conf file under the config directory: the contents are as follows:

KafkaServer {

Org.apache.kafka.common.security.plain.PlainLoginModule required

Username= "admin"

Password= "admin-secret"

User_admin= "admin-secret"

User_alice= "alice-secret"

}

Create a kafka_client_jaas.conf file under the config directory: the contents are as follows:

KafkaClient {

Org.apache.kafka.common.security.plain.PlainLoginModule required

Username= "alice"

Password= "alice-secret"

}

3. Modify the server.properties file in the config directory:

Modification: custom log.dirs (redefine log file)

Log.dirs=D:/kafka_2.10-0.9.0.0/kafka_2.10-0.10.1.0/kafka-logs

Add content:

# advertised.listeners=PLAINTEXT://192.168.66.119:9092

Listeners=SASL_PLAINTEXT://localhost:9092

Security.inter.broker.protocol=SASL_PLAINTEXT

Sasl.mechanism.inter.broker.protocol=PLAIN

Sasl.enabled.mechanisms=PLAIN

# configure this will report org.apache.kafka.common.errors.GroupAuthorizationException: Not authorized to access group: this is authorized configuration

# authorizer.class.name = kafka.security.auth.SimpleAclAuthorizer

Allow.everyone.if.no.acl.found=false

4. Add the following contents to consumer.properties and producer.properties under the config directory:

Security.protocol=SASL_PLAINTEXT

Sasl.mechanism=PLAIN

5. The kafka-server-start.bat file in the\ bin\ windows directory is added as follows:

Set KAFKA_OPTS=-Djava.security.auth.login.config=D:/kafka_2.10-0.9.0.0/kafka_2.10-0.10.1.0/config/kafka_server_jaas.conf

6. The kafka-console-producer.bat and kafka-console-consumer.bat files in the\ bin\ windows directory are added as follows:

Set KAFKA_OPTS=-Djava.security.auth.login.config=D:/kafka_2.10-0.9.0.0/kafka_2.10-0.10.1.0/config/kafka_client_jaas.conf

-the basic configuration has been completed, now start one by one--

7. Start the zookeeper that comes with kafka:

In the\ bin\ windows directory: shit+ right: pop-up box and click (open command window here), enter the command: zkserver

8. Start kafka

Under the kafka root directory: shit+ right: click on the pop-up box (open the command window here), and enter the command:

.\ bin\ windows\ kafka-server-start.bat.\ config\ server.properties

9. Create a theme:

In the\ bin\ windows directory: shit+ right: click on the pop-up box (open the command window here), and enter the command:

Kafka-topics.bat-create-zookeeper localhost:2181-replication-factor 1-partitions 1-topic test

10. Create a producer:

In the\ bin\ windows directory: shit+ right: click on the pop-up box (open the command window here), and enter the command:

Kafka-console-producer.bat-- broker-list localhost:9092-- topic test-- producer.config D:/kafka_2.10-0.9.0.0/kafka_2.10-0.10.1.0/config/producer.properties

11. Create a consumer:

In the\ bin\ windows directory: shit+ right: click on the pop-up box (open the command window here), and enter the command:

Kafka-console-consumer.bat-bootstrap-server localhost:9092-topic test-from-beginning-consumer.config D:/kafka_2.10-0.9.0.0/kafka_2.10-0.10.1.0/config/consumer.properties

twelve。 Enter randomly in the producer's command window, enter to send the message, and view the received message in the consumer window.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report