惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tailwind CSS Blog
C
CERT Recently Published Vulnerability Notes
P
Proofpoint News Feed
Vercel News
Vercel News
博客园 - 三生石上(FineUI控件)
IT之家
IT之家
Help Net Security
Help Net Security
月光博客
月光博客
N
News and Events Feed by Topic
Cloudbric
Cloudbric
博客园 - 司徒正美
L
LangChain Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tenable Blog
The Register - Security
The Register - Security
The Hacker News
The Hacker News
I
InfoQ
The Last Watchdog
The Last Watchdog
MyScale Blog
MyScale Blog
Schneier on Security
Schneier on Security
WordPress大学
WordPress大学
小众软件
小众软件
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
宝玉的分享
宝玉的分享
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
K
Kaspersky official blog
L
LINUX DO - 热门话题
N
News | PayPal Newsroom
F
Fortinet All Blogs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Security @ Cisco Blogs
Recorded Future
Recorded Future
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
Google Online Security Blog
Google Online Security Blog
S
Schneier on Security
C
Cisco Blogs
N
News and Events Feed by Topic
V2EX - 技术
V2EX - 技术
Latest news
Latest news
PCI Perspectives
PCI Perspectives
T
The Blog of Author Tim Ferriss
P
Palo Alto Networks Blog
T
Tor Project blog
Project Zero
Project Zero
云风的 BLOG
云风的 BLOG
Webroot Blog
Webroot Blog
Attack and Defense Labs
Attack and Defense Labs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org

博客园 - koushr

hls k8s常用命令 k8s 1.18.0安装 mysql json函数 group by的列、where的列的有效性 go基础第六篇:sync包 doris脚本 es es语法 veo ride nacos 枫叶互动 极光矩阵 富途 移卡科技 nginx高可用 k8s第一篇:k8s集群架构组件 架构设计第二篇:支付模块架构设计 可观测性体系设计第一篇:可观测性体系基本概念 架构设计第一篇:点赞模块功能设计 ES高级第一篇:倒排索引 山海星辰 python第一篇:基础语法 pulsar基础第一篇:pulsar安装及基本概念 clickhouse第三篇:安装 clickhouse第二篇:MergeTree引擎 clickhouse第一篇:引擎 redis高阶第一篇:令牌桶算法限流 http2.0 gin入参多次获取 docker第二篇:docker安装常用中间件
pulsar基础第二篇:命令行
koushr · 2025-05-15 · via 博客园 - koushr

pulsar-admin --admin-url http://xxx:8080

1、tenant管理(租户管理)

查看列表:pulsar-admin tenants list

创建:pulsar-admin tenants create xndm

2、namespace管理

查看某租户的namespace列表:pulsar-admin namespaces list xndm

在某租户下创建:pulsar-admin namespaces create xndm/blackbox

查看某namespace下topic的副本数:

查看namespace的配置策略:pulsar-admin namespaces policies xndm/blackbox,可以看到bundles、replication_clusters信息

配置堆积限额策略:pulsar-admin namespaces set-backlog-quota --limit 10G --limitTime 36000 --policy producer_exception xndm/blackbox。限制namespace下的存储。producer_exception表示生产者抛异常。

查看ttl:pulsar-admin namespaces get-message-ttl xndm/blackbox

设置ttl:pulsar-admin namespaces set-message-ttl -ttl 1d xndm/blackbox,未消费的消息的保留时间,如1d表示仅保留一天。默认是永久保留。

查看保留策略:pulsar-admin namespaces get-retention xndm/blackbox,默认返回null,代表消费过的消息不保存。

设置保留策略:pulsar-admin namespaces set-retention -s 10g -t -1 xndm/blackbox 

3、topic管理

查看某namespace下所有topic:pulsar-admin topics list xndm/blackbox

禁止自动创建:broker.conf文件(如果是standalone模式,则是standalone.conf文件)中的allowAutoTopicCreation,修改为false。

①不分区topic

创建:pulsar-admin topics create persistent://xndm/blackbox/my-unpartitioned-topic。pulsar会自动删除一定时间内不活跃(没有生产者、没有订阅)的不分区topic,要想不自动删除,需要修改broker.conf文件(如果是standalone模式,则是standalone.conf文件)中的brokerDeleteInactiveTopicsEnabled,修改为false。

查看topic状态:pulsar-admin topics stats persistent://xndm/blackbox/my-unpartitioned-topic

删除:pulsar-admin topics delete persistent://xndm/blackbox/my-unpartitioned-topic

查看stats:pulsar-admin topics stats persistent://xndm/blackbox/my-unpartitioned-topic --get-precise-backlog

②分区topic

创建:pulsar-admin topics create-partitioned-topic persistent://xndm/blackbox/my-topic -p 4

查看某namespace下所有分区topic:pulsar-admin topics list-partitioned-topics xndm/blackbox

删除:pulsar-admin topics delete-partitioned-topic persistent://xndm/blackbox/my-topic

查看stats:pulsar-admin topics partitioned-stats persistent://xndm/blackbox/my-topic --per-partition,可以查看topic的分区数、topic的生产者列表(客户端ip、客户端类型(是java客户端,还是go客户端)、连接时间)、topic及各分区的消费者列表、topic及各分区的消息总数(msgInCounter字段值)、topic的订阅列表及各订阅的消费者列表(各消费者客户端ip、客户端类型(是java客户端,还是go客户端)、连接时间、已消费的消息数(msgOutCounter字段值,这个值不太准))。在各分区的publishers中可以看到producerName,在各分区的subscription的consumers中可以看到consumerName。

subscription中:

1、msgBacklog:订阅堆积(未消费)的消息数,即当前topic被当前订阅订阅后,还有多少消息没有被消费。包括那些还没到时间的延时消息。

2、msgBacklogNoDelayed:订阅堆积(未消费)的消息中,非延时消息以及到时间的延时消息的数量。msgBacklog与msgBacklogNoDelayed的差值,即为还没到时间的延时消息数。

3、msgDelayed:还没到时间的延时消息数。

4、unackedMessages:当前订阅的未ack的消息数。还没receive的消息也算。

consumer中:

1、unackedMessages:当前消费者的未ack的消息数。还没receive的消息也算。

查看内部stats:pulsar-admin topics partitioned-stats-internal persistent://xndm/blackbox/my-topic,可以看到cursor相关信息。

pulsar-client --url pulsar://xxx:6650