Kafka基本安装与使用
Kafka简介
基本概念
Kafka安装和测试
下载
配置
zookeeper.properties
1 | # the directory where the snapshot is stored. |
server.properties
1 | # The address the socket server listens on. It will get the value returned from |
启动
启动zookeeper
1 | ./bin/zookeeper-server-start.sh ./config/zookeeper.properties |
启动kafka
1 | ./bin/kafka-server-start.sh ./config/server.properties |
查看Kafka进程
1 | [root@Hmaster kafka_2.12-2.8.0]# jps | grep Kafka |
测试
查看主题列表
1 | bin/kafka-topics.sh --zookeeper localhost:2183 --list |
消息生产者
1 | bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test |
消息消费者
1 | bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning |
另一套方案
server.properties
1 | # The address the socket server listens on. It will get the value returned from |
消息生产者
1 | bin/kafka-console-producer.sh --broker-list localhost:9092 --topiest |
消息消费者
1 | bin/kafka-console-consumer.sh --bootstrap-server 192.168.123.21:9092 |
其他问题
win10访问
需要配置host
C:\Windows\System32\drivers\etc\hosts
192.168.123.21 Hmaster
1
2
3
4
5
6
7
8
9
10
11 查看 hostname
[root@Hmaster ~]# hostnamectl
Static hostname: Hmaster
Icon name: computer-desktop
Chassis: desktop
Machine ID: 87af5eaaaf7c48f6b1cd9f42bfb51c76
Boot ID: 9fe58388f3274f0e838b7cd1b720eacd
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-1160.el7.x86_64
Architecture: x86-64防火墙开启
systemctl start firewalld
端口开启
firewall-cmd —zone=public —add-port=9092/tcp —permanent
生效
firewall-cmd —reload
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 兼一书虫!
评论
TwikooValine