Kafka's startup application

1. Start zookeeper

/opt/kafka/bin/zookeeper-server-start.sh  /opt/kafka/config/zookeeper.properties 

2. Start kafka

/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties 

3. Create a theme (let's create a theme called "test", which contains only one partition and only one copy)

--create --zookeeper localhost /opt/kafka/bin/kafka-topics.sh: 2181 --replication factor-1 --partitions 1 --topic 1704d • Note: Alternatively, you can configure the agent not to publish Themes are created automatically when they exist, rather than manually.

4. View topic: If we run the list topic command, we can now see the topic

 

/opt/kafka/bin/kafka-topics.sh --list --zookeeper localhost:2181

 

5. Send some messages Kafka comes with a command line client that will take input from files or standard input and send it as a message to the Kafka cluster. By default, each line will be sent as a separate message. Run the producer, and then type some messages in the console to send to the server.

 

--broker-List localhost /opt/kafka/bin/kafka-console-producer.sh: 9092 --topic 1704d •> sent a message waiting for input

6. Start consumers

/opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server 192.168.25.133:9092 --topic 1704D --from-beginning accept / opt / kafka / bin / kafka-console- from the first 
consumer.sh --bootstrap-server 192.168.25.133:9092 --topic 1704D will be accepted from the current producer sending.





 

Guess you like

Origin www.cnblogs.com/shanzhongqi/p/12690915.html