当前位置:网站首页>Kafuka learning path (I) Kafuka installation and simple use
Kafuka learning path (I) Kafuka installation and simple use
2022-07-01 11:20:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
One , Installation environment and software version
linux | centOs6 64 |
---|---|
jdk | jdk-8u191-linux-x64.tar.gz |
zookeeper | zookeeper-3.4.10.tar.gz |
kafuka | kafka_2.11-0.11.0.2 |
Two , install
## decompression
-rwxrw-rw-. 1 root root 42136632 Jun 11 01:55 kafka_2.11-0.11.0.2.tgz
drwxr-xr-x. 12 1001 1001 4096 Jun 11 05:35 zookeeper-3.4.10
[[email protected] module]# tar -xvf kafka_2.11-0.11.0.2.tgz
[[email protected] kafka_2.11-0.11.0.2]# ll
total 56
drwxr-xr-x. 3 root root 4096 Nov 10 2017 bin
drwxr-xr-x. 2 root root 4096 Nov 10 2017 config
drwxr-xr-x. 2 root root 4096 Jun 11 20:09 libs
-rw-r--r--. 1 root root 28824 Nov 10 2017 LICENSE
drwxr-xr-x. 2 root root 4096 Jun 11 20:10 logs
-rw-r--r--. 1 root root 336 Nov 10 2017 NOTICE
drwxr-xr-x. 2 root root 4096 Nov 10 2017 site-docs
## Add log folder
[[email protected] kafka_2.11-0.11.0.2]# mkdir logs
[[email protected] kafka_2.11-0.11.0.2]# ll
# Modify configuration file
[[email protected] kafka_2.11-0.11.0.2]# cd config/
[[email protected] config]# vim server.properties
broker.id=1 #broker The global unique number of , Can't repeat ( Mine is with zk Of myid equally )
delete.topic.enable=true
listeners=PLAINTEXT://192.168.8.132:9092
log.dirs=/opt/module/kafka_2.11-0.11.0.2/logs
zookeeper.connect=192.168.8.129:2181,192.168.8.132:2181,192.168.8.133:2181
3、 ... and , Start and create partitions using
notes :zookeeper On the premise that the cluster starts normally
# start-up
[[email protected] kafka_2.11-0.11.0.2]# bin/kafka-server-start.sh config/server.properties &
# close
[[email protected] kafka_2.11-0.11.0.2]# bin/kafka-server-stop.sh stop
## establish topic
#topic Definition topic name
#replication-factor Define the number of copies
#partitions Define the number of partitions
[[email protected] kafka_2.11-0.11.0.2]# bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 3 --topic test
bin/kafka-topics.sh --zookeeper localhost:2181 --create --replication-factor 3 --partitions 3 --topic test
Created topic "test".
## see topic list
[[email protected] kafka_2.11-0.11.0.2]# bin/kafka-topics.sh --zookeeper localhost:2181 --list
test
## Check the details
[[email protected] kafka_2.11-0.11.0.2]# bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic test
Topic:test PartitionCount:3 ReplicationFactor:3 Configs: MarkedForDeletion:true
Topic: test Partition: 0 Leader: -1 Replicas: 0,1,2 Isr: 2
Topic: test Partition: 1 Leader: -1 Replicas: 1,2,0 Isr: 2
Topic: test Partition: 2 Leader: -1 Replicas: 2,0,1 Isr: 2
## Delete topic
[[email protected] kafka_2.11-0.11.0.2]# bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic test
Topic test is marked for deletion.
Note: This will have no impact if delete.topic.enable is not set to true.
# If there is one in the cluster kafuka No settings delete.topic.enable=true ,
# It won't delete , You need to restart all , Delete it again
# Delete the mark after success
[[email protected] kafka_2.11-0.11.0.2]# bin/kafka-topics.sh --zookeeper localhost:2181 --list
test - marked for deletion
# Again zk Delete the registered node in
rmr /brokers/topics/【topic name】
Four , Easy to use
## Send a message (localhost It has to be local ip)
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic topicTest
## News consumption (localhost It has to be local ip)
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --from-beginning --topic topicTest
# production
[[email protected] kafka_2.11-0.11.0.2]# bin/kafka-console-producer.sh --broker-list 192.168.8.129:9092 --topic test1
>123
>123
>123
>123
>123
>123
>123
>hool^H^H
>holl
>hello
>hello
>
# consumption 1
[[email protected] kafka_2.11-0.11.0.2]# bin/kafka-console-consumer.sh --zookeeper 192.168.8.132:2181 --from-beginning --topic test1
Using the ConsoleConsumer with old consumer is deprecated and will be removed in a future major release. Consider using the new consumer by passing [bootstrap-server] instead of [zookeeper].
123
123
123
123
123
123
123
hool
holl
hello
hello
# consumption 2, Quit halfway and come in , Early news will be out of order
[[email protected] kafka_2.11-0.11.0.2]# bin/kafka-console-consumer.sh --zookeeper 192.168.8.133:2181 --from-beginning --topic test1
Using the ConsoleConsumer with old consumer is deprecated and will be removed in a future major release. Consider using the new consumer by passing [bootstrap-server] instead of [zookeeper].
123
123
123
hello
123
123
hool
123
123
holl
hello
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/131623.html Link to the original text :https://javaforall.cn
边栏推荐
- kubernetes之ingress探索实践
- 十年磨一剑:蚂蚁集团可观测性平台 AntMonitor 揭秘
- 放弃深圳高薪工作回老家
- "Target detection" + "visual understanding" to realize the understanding and translation of the input image (with source code)
- Tempest HDMI leak receive 5
- 金鱼哥RHCA回忆录:DO447使用Ansible与API通信--使用Ansible Tower API启动作业
- 树莓派4B安装tensorflow2.0[通俗易懂]
- LeetCode. One question of the day: offer II 091 Paint the house (DP problem)
- Jd.com renewed its cooperation with Tencent: issuing class A shares to Tencent with a maximum value of US $220million
- Introduction to unittest framework and the first demo
猜你喜欢
Website source code whole site download website template source code download
Combinaison Oracle et json
Brief analysis of edgedb architecture
What are the advantages and disadvantages of PHP
CVPR 2022 | Virtual Correspondence: Humans as a Cue for Extreme-View Geometry
JS foundation -- data type
kubernetes之ingress探索实践
达梦数据冲刺科创板:拟募资24亿 冯裕才曾为华科教授
2022/6/30学习总结
【MAUI】为 Label、Image 等控件添加点击事件
随机推荐
金鱼哥RHCA回忆录:DO447使用Ansible与API通信--使用Ansible Tower API启动作业
Unittest框架中跳过要执行的测试用例
redis中value/set
MySQL IN 和 NOT IN () 空列表报错
Oneconnect plans to be listed in Hong Kong on July 4: a loss of nearly 3 billion in two years, with a market capitalization evaporation of more than 90%
sdp 协议中的packetization-mode方式和三种流传输模式
Get key code
CVPR 2022 | Virtual Correspondence: Humans as a Cue for Extreme-View Geometry
The idea runs with an error command line is too long Shorten command line for...
flutter path_ Provider: ^2.0.10 can get temporary directory
英特爾實驗室公布集成光子學研究新進展
Activity workflow engine
Width and widthstep of iplimage
银行卡借给别人是否构成犯罪
Getting started with Paxos
Oracle和JSON的結合
Intel Labs annonce de nouveaux progrès en photonique intégrée
名创拟7月13日上市:最高发行价22.1港元 单季净利下降19%
redis中value/SortedSet
[AI information monthly] 350 + resources! All the information and trends that can't be missed in June are here! < Download attached >