Mac 搭建 Kafka集群
如何搭建单机Kafka,参考我的博客,https://www.cnblogs.com/yi1036943655/p/15834545.html
进入之前用于单机启动的Kafka目录
打开 \config\server.properties ,需要修改三处内容
- broker.id 保证唯一性(集群内)
- listeners 该台服务器的kafka端口(默认是注释的)
- log.dirs 新创建个文件夹,指定上即可
启动命令
// 指定不同的server.properties ./kafka-server-start.sh ../config/server1.properties
如何查看集群是否搭建成功
[zk: localhost:2181(CONNECTED) 3] ls /brokers/ids
[0, 1, 2]
启动过程中
错误:
[2022-01-23 15:38:19,798] ERROR Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer) kafka.common.InconsistentBrokerIdException: Configured broker.id 1 doesn't match stored broker.id Some(0) in meta.properties. If you moved your data, make sure your configured broker.id matches. If you intend to create a new broker, you should remove all data in your data directories (log.dirs). at kafka.server.KafkaServer.getOrGenerateBrokerId(KafkaServer.scala:793) at kafka.server.KafkaServer.startup(KafkaServer.scala:221) at kafka.Kafka$.main(Kafka.scala:109) at kafka.Kafka.main(Kafka.scala)
解决办法:
这个是因为指定了一个新的 "log.dirs" 路径 ,在该路径下有个 "meta.properties" 它里面有个配置
// 需要和server.properties(正在启动的) broker.id 保持一致 broker.id=2