1.安装kafka
下载地址 : https://www.apache.org/dyn/closer.cgi?path=/kafka/0.9.0.0/kafka_2.11-0.9.0.0.tgz
rz tar zxf kafka_2.11-0.9.0.0.tgz mv kafka_2.11-0.9.0.0 /usr/local/kafka
2.启停
/usr/local/kafka/bin/kafka-server-stop.sh /usr/local/kafka/config/server.properties /usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties & jps 2695 QuorumPeerMain # ZooKeeper 守护进程 6268 Kafka # Kafka 守护进程 6553 Jps
3.以上是"单节点 & 单代理"配置
4.简单修改配置
cd /usr/local/kafka vim config/server.properties ------------- advertised.host.name=10.1.44.187 -------------
5.创建和删除topic
# 创建topic bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic HelloWorld # 删除 bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic HelloWorld # 查看已有topic bin/kafka-topics.sh --list --zookeeper localhost:2181
6.开启2个窗口进行生产和消费测试
# 生产 /usr/local/kafka/bin/kafka-console-producer.sh --broker-list 10.1.44.187:9092 --topic HelloWorld # 消费 /usr/local/kafka/bin/kafka-console-consumer.sh --zookeeper 10.1.44.187:2181 --topic HelloWorld --from-beginning
原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/191580.html