kafka

启动kafka

nohup /home/pqctest/kafka/kafka_2.12-2.3.1/bin/zookeeper-server-start.sh /home/pqctest/kafka/kafka_2.12-2.3.1/config/zookeeper.properties  > /dev/null 2>&1 &
nohup /home/pqctest/kafka/kafka_2.12-2.3.1/bin/kafka-server-start.sh /home/pqctest/kafka/kafka_2.12-2.3.1/config/server.properties   > /dev/null 2>&1 &

创建topic

/home/pqctest/kafka/kafka_2.12-2.3.1/bin/kafka-topics.sh --create --zookeeper 192.168.64.101:2181,192.168.64.102:2181,192.168.64.103:2181 --partitions 3 --replication-factor 3 --topic test

创建消费者

/home/pqctest/kafka/kafka_2.12-2.3.1/bin/kafka-console-consumer.sh --bootstrap-server 192.168.64.101:9092,192.168.64.102:9092,192.168.64.103:9092 --topic test

向 topic 发送消息

/home/pqctest/kafka/kafka_2.12-2.3.1/bin/kafka-console-producer.sh --broker-list 192.168.64.101:9092,192.168.64.102:9092,192.168.64.103:9092 --topic test

安装CMAK

使用编译安装方法,安装失败

PATH=/home/pqctest/kafka/jdk11/jdk-11/bin:$PATH JAVA_HOME=/home/pqctest/kafka/jdk11/jdk-11 /home/pqctest/kafka/CMAK/sbt -java-home /home/pqctest/kafka/jdk11/jdk-11 clean dist

    $ PATH=/home/pqctest/kafka/jdk11/jdk-11/bin:$PATH \
      JAVA_HOME=/home/pqctest/kafka/jdk11/jdk-11 \
      /home/pqctest/kafka/CMAK/sbt -java-home /home/pqctest/kafka/jdk11/jdk-11 clean dist

换一种方式,直接下载并解压

	wget https://github.com/yahoo/CMAK/releases/download/3.0.0.4/cmak-3.0.0.4.zip  (比较慢)
	unzip cmak-3.0.0.4.zip

修改CMAK中的配置文件

	修改application.conf中的hosts为实际hosts
	kafka-manager.zkhosts=“10.120.75.102:2181,10.120.75.103:2181,10.120.75.107:2181”
cmak.zkhosts=“10.120.75.102:2181,10.120.75.103:2181,10.120.75.107:2181”

运行cmak

bin/cmak -Dconfig.file=conf/application.conf -Dhttp.port=8091 &

或者通过指定jdk方式运行(jdk版本过低无法运行最新的3.0.0.4)
bin/cmak -java-home /home/pqctest/kafka/jdk11/jdk-11 -Dconfig.file=conf/application.conf -Dhttp.port=8091 &
测试
如下输入ip和端口即可正常访问cmak。
http://localhost:8091

kafka知识学习:
在1个消费组中只有1个消费者能收到消息

posted on 2022-03-09 19:36  愚蠢的七橙  阅读(55)  评论(0)    收藏  举报