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

[kafka] single node multi-broker configuration

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

1. Before entering multiple broker settings, start the ZooKeeper server first

/ usr/local/zookeeper/bin/zkServer.sh start

two。 Copy the server.properties file of kafka

Cd / usr/local/kafka/config/cp-a server.properties server1.propertiescp-a server.properties server2.propertiesvim server.properties--# The id of the broker. This must be set to a unique integer for each broker.broker.id=0# The port the socket server listens onlisteners=PLAINTEXT://:9092port=9092# A comma seperated list of directories under which to store log fileslog.dirs=/tmp/kafka-logsvim server1.properties--# The id of the broker. This must be set to a unique integer for each broker.broker.id=1# The port the socket server listens onlisteners=PLAINTEXT://:9093port=9093# A comma seperated list of directories under which to store log fileslog.dirs=/tmp/kafka-logs-1vim server2.properties--# The id of the broker. This must be set to a unique integer for each broker.broker.id=2# The port the socket server listens onlisteners=PLAINTEXT://:9094port=9094# A comma seperated list of directories under which to store log fileslog.dirs=/tmp/kafka-logs-2

3. Start 3 broker

# Broker1cd / usr/local/kafkabin/kafka-server-start.sh config/server.properties & # Broker2cd / usr/local/kafkabin/kafka-server-start.sh config/server1.properties & # Broker3cd / usr/local/kafkabin/kafka-server-start.sh config/server2.properties & # jps8274 Jps8079 Kafka8145 Kafka8210 Kafka2004 QuorumPeerMain

4. Create topic

(1) specify 3 replication factor values (replication-factor) for this topic because we have three different broker runs

(2) if there are two broker, then the assigned replication factor must also be 2.

Cd / usr/local/kafkabin/kafka-topics.sh-create-zookeeper localhost:2181-replication-factor 3-partitions 1-topic Three

5. Check which broker is listening on the currently created topic

Cd / usr/local/kafkabin/kafka-topics.sh-- describe-- zookeeper localhost:2181-- topic Three-Topic: Three PartitionCount:1 ReplicationFactor:3 Configs: # Partition summary information, topic name, number of partitions, replication factor Topic: Three Partition: 0 Leader: 0 Replicas: 0meme 1 Isr: 0 broker 0 is the leader-

6. Production and consumption (note ip and port)

# production / usr/local/kafka/bin/kafka-console-producer.sh-- broker-list 10.1.44.188 topic Three/usr/local/kafka/bin/kafka-console-producer.sh 9092-- topic Three/usr/local/kafka/bin/kafka-console-producer.sh-- broker-list 10.1.44.188 topic Three/usr/local/kafka/bin/kafka-console-producer.sh-- topic Three/usr/local/kafka/bin/kafka-console-producer.sh-- broker-list 10.1.44.188 topic Three/usr/local/kafka/bin/kafka-console-producer.sh 9094-topic Three# consumption / usr/local/kafka/ Bin/kafka-console-consumer.sh-- zookeeper 10.1.44.188 topic Three-- from-beginningjps2290 ConsoleConsumer1974 Kafka1946 QuorumPeerMain2042 Kafka2107 Kafka2460 Jps2364 ConsoleProducer2414 ConsoleProducer2239 ConsoleProducer

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: 250

*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

Internet Technology

Wechat

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

12
Report