Created symlink from /etc/systemd/system/kafka.service to /wisoft/kafka/kafka.service. kafka安装完成,KAFKA_HOME: /wisoft/kafka/kafka_2.12-2.6.0 执行 systemctl start kafka 启动或 reboot 自启
在提示安装完成后,最好执行 source ~/.bashrc 来刷新环境变量
kafka测试
安装完毕后,使用命令 systemctl start kafka 在各个节点启动集群
使用 jps|grep kafka 查看启动后进程是否存在
使用 cat /wisoft/kafka/logs/server.log 查看启动日志
安然无恙之后,使用在其中一个节点上使用名利创建一个topic 名为 test
1 2 3 4 5 6 7 8 9 10 11 12
[root@dfs-01 wisoft]# jps 11762 Jps 3113 QuorumPeerMain 11613 Kafka [root@dfs-01 wisoft]# kafka-topics.sh \ > --zookeeper 192.168.1.210,192.168.1.211,192.168.1.212/wi-kafka \ > --create \ > --replication-factor 1 \ > --partitions 1 \ > --topic test Java HotSpot(TM) 64-Bit Server VM warning: G1 GC is disabled in this release. Created topic test.
换个节点查看topic列表 是否可以查看到刚刚建立的topic test
1 2 3 4 5
[root@dfs-02 wisoft]# kafka-topics.sh \ > --zookeeper 192.168.1.210,192.168.1.211,192.168.1.212/wi-kafka \ > --list Java HotSpot(TM) 64-Bit Server VM warning: G1 GC is disabled in this release. test
在其中一台节点上打开消费者控制台
1 2 3 4 5
[root@dfs-03 wisoft]# kafka-console-consumer.sh \ > --bootstrap-server 192.168.1.210:9092,192.168.1.211:9092,192.168.1.212:9092 \ > --topic test \ > --from-beginning Java HotSpot(TM) 64-Bit Server VM warning: G1 GC is disabled in this release.
在另一台节点打开生产者控制台,发送消息,并查看消费控制台是否能接收到消息内容
1 2 3 4 5 6 7
[root@dfs-01 wisoft]# kafka-console-producer.sh \ > --broker-list 192.168.1.210:9092,192.168.1.211:9092,192.168.1.212:9092 \ > --topic test Java HotSpot(TM) 64-Bit Server VM warning: G1 GC is disabled in this release. >[2020-09-11 15:18:31,656] WARN [Producer clientId=console-producer] Bootstrap broker 192.168.1.212:9092 (id: -3 rack: null) disconnected (org.apache.kafka.clients.NetworkClient) hello kafka >hello wisoft
1 2 3 4 5 6 7
[root@dfs-03 wisoft]# kafka-console-consumer.sh \ > --bootstrap-server 192.168.1.210:9092,192.168.1.211:9092,192.168.1.212:9092 \ > --topic test \ > --from-beginning Java HotSpot(TM) 64-Bit Server VM warning: G1 GC is disabled in this release. hello kafka hello wisoft