配置
保证集群中每个broker的broker.id配置参数不一样,listeners配置参数改成对应的ip与端口,若在同一台机器日志路径不同,zk地址需一致
Node1
broker.id=3
listeners=PLAINTEXT://192.168.94.151:9093
log.dirs=/opt/module/kafka/cluster/logs9093
zookeeper.connect=192.168.94.151:2181/kafkaCluster
Node2
broker.id=4
listeners=PLAINTEXT://192.168.94.151:9094
log.dirs=/opt/module/kafka/cluster/logs9094
zookeeper.connect=192.168.94.151:2181/kafkaCluster
Node3
broker.id=5
listeners=PLAINTEXT://192.168.94.151:9095
log.dirs=/opt/module/kafka/cluster/logs9095
zookeeper.connect=192.168.94.151:2181/kafkaCluster
启动脚本
start.sh
/opt/module/kafka/kafka_2.13-2.7.0/bin/kafka-server-start.sh -daemon /opt/module/kafka/cluster/config9093/server.properties
/opt/module/kafka/kafka_2.13-2.7.0/bin/kafka-server-start.sh -daemon /opt/module/kafka/cluster/config9094/server.properties
/opt/module/kafka/kafka_2.13-2.7.0/bin/kafka-server-start.sh -daemon /opt/module/kafka/cluster/config9095/server.properties
创建主题
xuhaixing@xhxpc:~$ kafka-topics.sh --zookeeper 192.168.94.151:2181/kafkaCluster --create --topic demo-test01 --replication-factor 2 --partitions 2
Created topic demo-test01.
xuhaixing@xhxpc:~$ kafka-topics.sh --zookeeper 192.168.94.151:2181/kafkaCluster --describe --topic demo-test01
Topic: demo-test01 TopicId: 7ndbddtZQESHYZ9s7GNviQ PartitionCount: 2 ReplicationFactor: 2 Configs:
Topic: demo-test01 Partition: 0 Leader: 4 Replicas: 4,5 Isr: 4,5
Topic: demo-test01 Partition: 1 Leader: 5 Replicas: 5,3 Isr: 5,3