扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
1.查看已经创建的Topic
我们提供的服务有:成都做网站、网站设计、微信公众号开发、网站优化、网站认证、民和ssl等。为上1000家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的民和网站制作公司cd /usr/local/kafka ./bin/kafka-topics.sh --list --zookeeper 10.1.44.186:2181,10.1.44.187:2181,10.1.44.188:2181 186 187 188 ------------------ ------------------ ------------------ __consumer_offsets __consumer_offsets __consumer_offsets connect-test connect-test connect-test test0320 test0320 test0320
2.创建topic
cd /usr/local/kafka ./bin/kafka-topics.sh --create --zookeeper 10.1.44.186:2181,10.1.44.187:2181,10.1.44.188:2181 --partitions 3 --replication-factor 2 --topic test0326 # 创建后各broker上的物理目录 186 187 188 ---------- ---------- ---------- test0326-1 test0326-1 test0326-1 test0326-2 test0326-2 test0326-2
3.查看指定topic中Leader的信息
cd /usr/local/kafka ./bin/kafka-topics.sh --describe --zookeeper 10.1.44.186:2181,10.1.44.187:2181,10.1.44.188:2181 --topic test0326 Topic: test0326 PartitionCount:3 ReplicationFactor:2 Configs: Topic: test0326 Partition: 0 Leader: 0 Replicas: 0,2 Isr: 0,2 Topic: test0326 Partition: 1 Leader: 1 Replicas: 1,0 Isr: 1,0 Topic: test0326 Partition: 2 Leader: 2 Replicas: 2,1 Isr: 2,1
4.查看consumer组内消费的offset
(1) 使用生产者生成一次
(2) 使用test组消费一次
(3) test组当前的消费偏移
offset = 828 , partition=1, key = 4, value = hh老高4
offset = 829 , partition=1, key = 6, value = hh老高6
offset = 1095, partition=0, key = 1, value = hh老高1
offset = 1096, partition=0, key = 5, value = hh老高5
offset = 1097, partition=0, key = 7, value = hh老高7
offset = 1098, partition=0, key = 8, value = hh老高8
offset = 568 , partition=2, key = 0, value = hh老高0
offset = 569 , partition=2, key = 2, value = hh老高2
offset = 570 , partition=2, key = 3, value = hh老高3
offset = 571 , partition=2, key = 9, value = hh老高9
cd /usr/local/kafka ./bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zookeeper 10.1.44.186:2181,10.1.44.187:2181,10.1.44.188:2181 --group test --topic test0320 # [2018-03-26 11:06:17,939] WARN WARNING: ConsumerOffsetChecker is deprecated and will be dropped in releases following 0.9.0. Use ConsumerGroupCommand instead. (kafka.tools.ConsumerOffsetChecker$) Group Topic Pid Offset logSize Lag Owner test test0320 0 1099 1099 0 none test test0320 1 830 830 0 none test test0320 2 572 572 0 none
5.kafka-consumer-offset-checker.sh脚本
# bin/kafka-consumer-offset-checker.sh Option Description ------ ----------- --broker-info 打印broker信息 --group 消费着组 --help 帮助信息 --retry.backoff.ms? Retry back-off to use for failed offset queries. (default: 3000) --socket.timeout.ms ? Socket timeout to use when querying for offsets. (default: 6000) --topic 以逗号分隔的消费者主题列表(如果不存在的话,所有主题) --zookeeper zookeeper地址 cd /usr/local/kafka bin/kafka-consumer-offset-checker.sh --zookeeper 10.1.44.186:2181,10.1.44.187:2181,10.1.44.188:2181 --topic test0320 --group test --broker-info [2018-03-26 11:24:52,014] WARN WARNING: ConsumerOffsetChecker is deprecated and will be dropped in releases following 0.9.0. Use ConsumerGroupCommand instead. (kafka.tools.ConsumerOffsetChecker$) Group Topic Pid Offset logSize Lag Owner test test0320 0 1115 1115 0 none test test0320 1 838 838 0 none test test0320 2 588 588 0 none BROKER INFO 2 -> 10.1.44.188:9092 1 -> 10.1.44.187:9092 0 -> 10.1.44.186:9092
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流