当前位置:网站首页>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:21813、 ... 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
helloPublisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/131623.html Link to the original text :https://javaforall.cn
边栏推荐
- How to realize the four isolation levels of MySQL (brief)
- Can I open a securities account anywhere? Is it safe to open an account
- What are the advantages and disadvantages of PHP
- Neurips 2022 | cell image segmentation competition officially launched!
- Nordic nrf52832 flash 下载M4错误
- Dameng data rushes to the scientific innovation board: it plans to raise 2.4 billion yuan. Feng Yucai was once a professor of Huake
- 妙啊!MarkBERT
- Huawei Equipment configure les services de base du réseau WLAN à grande échelle
- How to make the development of liquidity pledge mining system, case analysis and source code of DAPP defi NFT LP liquidity pledge mining system development
- Flip the array gracefully
猜你喜欢

Combination of Oracle and JSON

Why must we move from Devops to bizdevops?

Combinaison Oracle et json

Numpy的矩阵

软件项目管理 9.2.软件项目配置管理过程

Huawei Equipment configure les services de base du réseau WLAN à grande échelle

Introduction to unittest framework and the first demo

Exposure:A White-Box Photo Post-Processing Framework阅读札记

applyMiddleware 原理

TEMPEST HDMI泄漏接收 3
随机推荐
2022/6/29学习总结
y48.第三章 Kubernetes从入门到精通 -- Pod的状态和探针(二一)
TEMPEST HDMI泄漏接收 5
What are the advantages and disadvantages of PHP
No statements may be issued when any streaming result sets are open and in use on a given connection
[buuctf.reverse] 144_[XMAN2018排位赛]easyvm
The project bar on the left side of CodeBlocks disappears, workspace automatically saves the project, default workspace, open the last workspace, workspace (Graphic tutorial, solved)
英特尔实验室公布集成光子学研究新进展
树莓派4B安装tensorflow2.0[通俗易懂]
技术分享 | Linkis参数介绍
华泰证券网上开户安全吗?
node版本管理器nvm安装及切换
Combinaison Oracle et json
Value 1000 graduation project campus information publishing platform website source code
8 best practices to protect your IAC security!
Nordic nrf52832 flash 下载M4错误
Getting started with Paxos
CPI教程-异步接口创建及使用
Vscode shortcut key (the most complete) [easy to understand]
Mutual conversion of pictures in fluent uint8list format and pictures in file format