Admin cheat sheet of commands

Published: February 24, 2022

Prerequisites

To run these commands you’ll need the binaries installed…

Pulsar is developed for 64-bit Java. To run the binaries you need either the Java Runtime Environment(JRE) or Java Developer Kit(JDK) version 8 or later installed. Installers and more info available here.

With a Java environment in place, all popular 64-bit desktops are supported - Windows, Linux, and MacOS. The tarball is around 300mb, so please be patient while downloading.

Admin commands

List tenants

1
bin/pulsar-admin tenants list

List namespaces within a tenant

1
bin/pulsar-admin namespaces list "public"

List topics within a namespace

1
bin/pulsar-admin topics list "public/default"

Create a persistent topic

1
bin/pulsar-admin topics create "persistent://public/default/a-new-topic"

Create a non-persistent topic

1
bin/pulsar-admin topics create "non-persistent://public/default/a-new-topic"

Forcefully delete a topic (close all producers/consumers/replicators & delete schemas)

1
bin/pulsar-admin topics delete -f -d "persistent://public/default/a-new-topic"

Get stats about a topic (includes active subscriptions, active publishers, messages in, and other interesting things)

1
bin/pulsar-admin topics stats "persistent://public/default/a-new-topic"

List message for a subscription

1
bin/pulsar-admin topics peek-messages --count 1 -s "my-subscription" "persistent://public/default/a-new-topic"

Get the latest message details

1
bin/pulsar-admin topics examine-messages --initialPosition latest --messagePosition 1 "persistent://public/default/a-new-topic"

Reset subscription cursor back to 0 (the first message in the queue), in ledger 0 (the first ledger)

1
bin/pulsar-admin topics reset-cursor --messageId 0:0 -s "my-subscription" "persistent://public/default/a-new-topic"

Troubleshooting

As you interact with the admin client, it helps to have messages loaded. Publish a message to a topic (the topic will be created as persistent, if it doesn’t exist)

1
bin/pulsar-client produce "persistent://public/default/a-new-topic" --messages "Hello there"