提前安装Zookeeper:Zookeeper 3.7.0 安装部署_与光同尘~追光者的博客-CSDN博客_zookeeper3.7.0
地址:Apache Kafka
tar -zxf ./kafka_2.12-3.2.0.tgz -C /opt/module/
server.properties
- broker.id=1 #当前机器在集群中的唯一标识,和zookeeper的myid性质一样
- log.dirs=/data/kafka/kafka-logs
- num.partitions=3
- zookeeper.connect=bigdata01:2181,bigdata02:2181,bigdata03:2181
producer.properties
- bootstrap.servers=bigdata01:9092,bigdata02:9092,bigdata03:9092
- compression.type=snappy
consumer.properties
- bootstrap.servers=bigdata01:9092,bigdata02:9092,bigdata03:9092
- group.id=bigdata-consumer-group
- #分发
- xsync kafka_2.12-3.2.0
-
- #修改对应服务器上的broker.id
- broker.id=2 (bigdata02)
- broker.id=3 (bigdata03)
- vim /etc/profile.d/my_env.sh
-
- #KAFKA_HOME
- export KAFKA_HOME=/opt/module/kafka_2.12-3.2.0
- export PATH=$PATH:$KAFKA_HOME/bin
- #前台启动
- kafka-server-start.sh config/server.properties
-
- #后台启动
- nohup kafka-server-start.sh config/server.properties &
- kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 2 --partitions 3 --topic test
- 或者
- kafka-topics.sh --create --bootstrap-server bigdata01:9092,bigdata02:9092,bigdata03:9092 --replication-factor 2 --partitions 3 --topic test
kafka-topics.sh --bootstrap-server bigdata01:9092,bigdata02:9092,bigdata03:9092 --list
kafka-console-producer.sh --bootstrap-server bigdata01:9092,bigdata02:9092,bigdata03:9092 --topic test
kafka-console-consumer.sh --bootstrap-server bigdata01:9092,bigdata02:9092,bigdata03:9092 --topic test --group test --from-beginning
kafka-consumer-groups.sh --bootstrap-server bigdata01:9092,bigdata02:9092,bigdata03:9092 --list
kafka-consumer-groups.sh --bootstrap-server bigdata01:9092,bigdata02:9092,bigdata03:9092 --group test --describe
kafka-topics.sh --bootstrap-server bigdata01:9092,bigdata02:9092,bigdata03:9092 --delete --topic test