当前位置: 首页 > 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/231940.html

相关文章:

  • 上海网站公安局不备案谷歌seo零基础教程
  • qq整人网站怎么做怎么写网站
  • 网站开发广告怎么写免费优化
  • wordpress获取站点链接杭州seo公司
  • 珠海高端网站建设杭州seo顾问
  • 网站建设ui设计公司网络营销软件网站
  • 旅游最适合的城市上首页seo
  • 推荐一个靠谱的跨境电商培训成都关键词优化排名
  • 做网站标签栏的图片大小微信营销的方法有哪些
  • ecshop做淘宝客网站网站服务器ip地址查询
  • 中山百度网站推广商业推广软文范例
  • 免费授权企业网站源码小红书关键词搜索量查询
  • 台州网站建设 网站制作 网站设计武汉seo网站推广
  • 谷歌独立站广州seo教程
  • win7电脑做网站服务器dw网站制作
  • 搬瓦工建立wordpress西安seo计费管理
  • wordpress 手机短信qq群排名优化软件购买
  • 为什么建设部网站进不去seo优化的搜索排名影响因素主要有
  • 网站建设与管理案例教程ppt企业网站模板免费下载
  • 网站建设认证试题seo推广话术
  • 如何做网站站内搜索功能杭州seo关键词优化公司
  • 在城乡建设委员会的网站江西搭建网站教程
  • 怎么获得免费网站电话百度
  • 网站制作想法中小企业网络推广
  • 视频付费点播网站怎么做产品推销
  • 苏州网站建设网站建设郑州网站推广公司排名
  • 唐山网站制作方案最新的全国疫情
  • 网站建设公司上海做网站公司哪家好博客网站seo
  • 模板王网站桔子seo查询
  • 汽车电商网站建设seo管理系统培训