当前位置: 首页 > wzjs >正文

河北最近发生了什么事网站优化价格

河北最近发生了什么事,网站优化价格,微信营销成,网站建设这个职业是什么基础命令 主题 参数含义–bootstrap-server连接的Broker主机名称以及端口号–topic操作的topic–create创建主题–delete删除主题–alter修改主题–list查看所有主题–describe查看主题的详细描述–partitions设置分区数–replication-factor设置分区副本–config更新系统默认…

基础命令

主题

参数含义
–bootstrap-server连接的Broker主机名称以及端口号
–topic操作的topic
–create创建主题
–delete删除主题
–alter修改主题
–list查看所有主题
–describe查看主题的详细描述
–partitions设置分区数
–replication-factor设置分区副本
–config更新系统默认的配置

在执行查看命令时

bin/kafka-topics.sh --bootstrap-server 192.168.27.101:9092 --list

显示以下报错信息

[2023-07-18 16:19:18,101] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (/192.168.27.101:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)

解决方案是修改server.properties,将下面的修改为自己的ip+端口

#advertised.listeners=PLAINTEXT://your.host.name:9092
advertised.listeners=PLAINTEXT://192.168.27.101:9092

新建一个topic,topic名称为first,设置分区数为1,分区副本为3(命令行不能修改分区副本的数量)

bin/kafka-topics.sh --bootstrap-server 192.168.27.101:9092 --topic first --create --partitions 1 --replication-factor 3

当命令正常执行之后,能够在zookeeper中查看到刚刚创建的kafka,在路径下有brokers:0,1,2,这就是设置的id。topics下的first就是刚刚创建的topic

在这里插入图片描述

命令查看topic的详细描述

[root@centos101 kafka_2.12-3.0.0]# bin/kafka-topics.sh --bootstrap-server 192.168.27.101:9092 --topic first --describe
Topic: first	TopicId: nM9fRCkARa2n2Ifgu37NnQ	PartitionCount: 1	ReplicationFactor: 3	Configs: segment.bytes=1073741824Topic: first	Partition: 0	Leader: 2	Replicas: 2,1,0	Isr: 2,1,P,1,0	Isr: 2,1,0

修改分区Partition数量

bin/kafka-topics.sh --bootstrap-server 192.168.27.101:9092 --topic first --alter --partitions 3

修改完成之后再次查看topic的详细描述

[root@centos101 kafka_2.12-3.0.0]# bin/kafka-topics.sh --bootstrap-server 192.168.27.101:9092 --topic first --describe
Topic: first	TopicId: nM9fRCkARa2n2Ifgu37NnQ	PartitionCount: 3	ReplicationFactor: 3	Configs: segment.bytes=1073741824Topic: first	Partition: 0	Leader: 2	Replicas: 2,1,0	Isr: 2,1,0Topic: first	Partition: 1	Leader: 0	Replicas: 0,1,2	Isr: 0,1,2Topic: first	Partition: 2	Leader: 1	Replicas: 1,2,0	Isr: 1,2,0

可以看到分区数量的增加,但是注意,分区数量增加后不能再减少比如修改分区为1

[root@centos101 kafka_2.12-3.0.0]# bin/kafka-topics.sh --bootstrap-server 192.168.27.101:9092 --topic first --alter --partitions 1
Error while executing topic command : Topic currently has 3 partitions, which is higher than the requested 1.
[2023-07-19 09:36:19,679] ERROR org.apache.kafka.common.errors.InvalidPartitionsException: Topic currently has 3 partitions, which is higher than the requested 1.(kafka.admin.TopicCommand$)

生产者

连接上主题,当出现回车之后就可以发送消息

bin/kafka-console-producer.sh --bootstrap-server 192.168.27.101:9092 --topic first

消费者

连接上主题,接收消费者连接上之后发送的消息

bin/kafka-console-consumer.sh --bootstrap-server 192.168.27.101:9092 --topic first

如果需要接收消费者连接上之前发送的所有消息,则在后面加上–from-beginning

bin/kafka-console-consumer.sh --bootstrap-server 192.168.27.101:9092 --topic first --from-beginning

生产与消费

当生产者和消费者都连接上了同一个topic之后,模拟生产者发送消息

[root@centos101 kafka_2.12-3.0.0]# bin/kafka-console-producer.sh --bootstrap-server 192.168.27.101:9092 --topic first
>nihao,kafka

此时消费者会立马接收到生产者的消息

[root@centos102 kafka_2.12-3.0.0]# bin/kafka-console-consumer.sh --bootstrap-server 192.168.27.101:9092 --topic first
nihao,kafka
http://www.dtcms.com/wzjs/109757.html

相关文章:

  • documentation wordpressseo网站的优化流程
  • 网站建设的成本有哪些内容百家联盟推广部电话多少
  • wordpress主题技术网惠州搜索引擎优化
  • 网站运营需要 做哪些工作内容公司网站制作要多少钱
  • 天河网站建设方案百度关键词网站排名优化软件
  • 文汇智能建站平台百度账号注册入口
  • 网络维护一个月多少钱上海最大的seo公司
  • 男女朋友在一起做那个的网站百度数据平台
  • 江门建站软件佛山seo教程
  • 创业网站模板非企户百度推广
  • 网站建设与管理案例教程第三版课后答案如何在百度上做产品推广
  • wordpress阿里巴巴图标长沙seo优化哪家好
  • 邯郸哪儿能做网站百度号码认证平台个人号码申诉
  • 昆明网站seo外包今天的头条新闻
  • 杭州网站建设公司电话营业推广方案怎么写
  • 怎么查网站有没有做推广shopify seo
  • 京挑客网站建设郑州seo推广优化
  • 东莞网站建设熊掌号网站域名备案查询
  • 大连模板建站代理如何在手机上建立自己的网站
  • 做国外的众筹网站西安网站制作建设
  • 连江网站建设网站制作网站推广
  • 建设手机版网站营销技巧
  • 贵州网站建设培训惠州seo网络推广
  • 宁波房产信息网官方网站建网站需要多少钱和什么条件
  • 高端公司网站设计外贸网络营销平台
  • 贵阳酒店网站建设网络运营培训哪里有学校
  • 济南网站制作服务价格免费建一个自己的网站
  • 58同城建设网站找关键词的方法与技巧
  • 网站制作公司汉狮网络知识付费小程序搭建
  • 自己做网站能赚到广告费吗网站seo基本流程