Difference between revisions of "Kafka-topics"

From wikieduonline
Jump to navigation Jump to search
(Created page with "<pre> kafka-topics Create, delete, describe, or change a topic. Option Description ------ ----------- --alt...")
 
 
(22 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{lowercase}}
 +
 +
[[kafka-topics --list]] --bootstrap-server localhost:[[9092]]
 +
(no output)
 +
 +
 +
 +
[[kafka-topics --create]] --topic your_topic_name --bootstrap-server localhost:9092 --partitions 3 --replication-factor 1
 +
WARNING: Due to limitations in metric names, topics with a period ('.') or underscore ('_') could [[collide]]. To avoid issues it is best to use either, but not both.
 +
Created topic your_topic_name.
 +
 +
 +
Create a [[topic]]:
 +
[[kafka-topics --create]] --topic YourTopicName1 --bootstrap-server localhost:9092 --partitions 3 --replication-factor 1
 +
Created topic YourTopicName1.
 +
 +
kafka-topics --list --bootstrap-server localhost:9092
 +
your_topic_name
 +
 +
  kafka-topics --list --bootstrap-server localhost:9092
 +
YourTopicName1
 +
YourTopicname1
 +
your_topic_name
 +
 +
== Errors ==
 +
[[kafka-topics --list]] --bootstrap-server localhost:9092
 +
[2024-03-14 20:19:31,152] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. [[Broker may not be available]]. ([[org.apache.kafka.clients.NetworkClient]])
 +
 +
[[kafka-topics --list]] --bootstrap-server localhost:9092
 +
[2024-03-20 19:52:51,677] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. [[Node may not be available]]. ([[org.apache.kafka.clients.NetworkClient]])
 +
 +
kafka-topics --list
 +
Exception in thread "main" java.lang.IllegalArgumentException: [[--bootstrap-server]] must be
 +
specified
 +
at kafka.admin.TopicCommand$TopicCommandOptions.checkArgs(TopicCommand.scala:609)
 +
at kafka.admin.TopicCommand$.main(TopicCommand.scala:50)
 +
at kafka.admin.TopicCommand.main(TopicCommand.scala)
 +
 +
== Help ==
 
<pre>
 
<pre>
 
kafka-topics
 
kafka-topics
Line 125: Line 164:
 
</pre>
 
</pre>
  
 +
 +
== Related ==
 +
[[kafka-consumer-groups]] --list --bootstrap-server localhost:9092
 +
[[kafka-console-producer]]
  
 
== See also ==
 
== See also ==
 +
* {{kafka-topics}}
 
* {{Kafka}}
 
* {{Kafka}}
  
 
[[Category:Kafka]]
 
[[Category:Kafka]]

Latest revision as of 10:07, 21 March 2024

kafka-topics --list --bootstrap-server localhost:9092
(no output)


kafka-topics --create --topic your_topic_name --bootstrap-server localhost:9092 --partitions 3 --replication-factor 1
WARNING: Due to limitations in metric names, topics with a period ('.') or underscore ('_') could collide. To avoid issues it is best to use either, but not both.
Created topic your_topic_name.


Create a topic:

kafka-topics --create --topic YourTopicName1 --bootstrap-server localhost:9092 --partitions 3 --replication-factor 1
Created topic YourTopicName1.
kafka-topics --list --bootstrap-server localhost:9092
your_topic_name
 kafka-topics --list --bootstrap-server localhost:9092
YourTopicName1
YourTopicname1
your_topic_name

Errors[edit]

kafka-topics --list --bootstrap-server localhost:9092
[2024-03-14 20:19:31,152] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
kafka-topics --list --bootstrap-server localhost:9092
[2024-03-20 19:52:51,677] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Node may not be available. (org.apache.kafka.clients.NetworkClient)
kafka-topics --list
Exception in thread "main" java.lang.IllegalArgumentException: --bootstrap-server must be 
specified
	at kafka.admin.TopicCommand$TopicCommandOptions.checkArgs(TopicCommand.scala:609)
	at kafka.admin.TopicCommand$.main(TopicCommand.scala:50)
	at kafka.admin.TopicCommand.main(TopicCommand.scala)

Help[edit]

kafka-topics
Create, delete, describe, or change a topic.
Option                                   Description
------                                   -----------
--alter                                  Alter the number of partitions,
                                           replica assignment, and/or
                                           configuration for the topic.
--at-min-isr-partitions                  if set when describing topics, only
                                           show partitions whose isr count is
                                           equal to the configured minimum. Not
                                           supported with the --zookeeper
                                           option.
--bootstrap-server <String: server to    REQUIRED: The Kafka server to connect
  connect to>                              to. In case of providing this, a
                                           direct Zookeeper connection won't be
                                           required.
--command-config <String: command        Property file containing configs to be
  config property file>                    passed to Admin Client. This is used
                                           only with --bootstrap-server option
                                           for describing and altering broker
                                           configs.
--config <String: name=value>            A topic configuration override for the
                                           topic being created or altered. The
                                           following is a list of valid
                                           configurations:
                                         	cleanup.policy
                                         	compression.type
                                         	delete.retention.ms
                                         	file.delete.delay.ms
                                         	flush.messages
                                         	flush.ms
                                         	follower.replication.throttled.
                                           replicas
                                         	index.interval.bytes
                                         	leader.replication.throttled.replicas
                                         	max.compaction.lag.ms
                                         	max.message.bytes
                                         	message.downconversion.enable
                                         	message.format.version
                                         	message.timestamp.difference.max.ms
                                         	message.timestamp.type
                                         	min.cleanable.dirty.ratio
                                         	min.compaction.lag.ms
                                         	min.insync.replicas
                                         	preallocate
                                         	retention.bytes
                                         	retention.ms
                                         	segment.bytes
                                         	segment.index.bytes
                                         	segment.jitter.ms
                                         	segment.ms
                                         	unclean.leader.election.enable
                                         See the Kafka documentation for full
                                           details on the topic configs. It is
                                           supported only in combination with --
                                           create if --bootstrap-server option
                                           is used (the kafka-configs CLI
                                           supports altering topic configs with
                                           a --bootstrap-server option).
--create                                 Create a new topic.
--delete                                 Delete a topic
--delete-config <String: name>           A topic configuration override to be
                                           removed for an existing topic (see
                                           the list of configurations under the
                                           --config option). Not supported with
                                           the --bootstrap-server option.
--describe                               List details for the given topics.
--disable-rack-aware                     Disable rack aware replica assignment
--exclude-internal                       exclude internal topics when running
                                           list or describe command. The
                                           internal topics will be listed by
                                           default
--force                                  Suppress console prompts
--help                                   Print usage information.
--if-exists                              if set when altering or deleting or
                                           describing topics, the action will
                                           only execute if the topic exists.
--if-not-exists                          if set when creating topics, the
                                           action will only execute if the
                                           topic does not already exist.
--list                                   List all available topics.
--partitions <Integer: # of partitions>  The number of partitions for the topic
                                           being created or altered (WARNING:
                                           If partitions are increased for a
                                           topic that has a key, the partition
                                           logic or ordering of the messages
                                           will be affected). If not supplied
                                           for create, defaults to the cluster
                                           default.
--replica-assignment <String:            A list of manual partition-to-broker
  broker_id_for_part1_replica1 :           assignments for the topic being
  broker_id_for_part1_replica2 ,           created or altered.
  broker_id_for_part2_replica1 :
  broker_id_for_part2_replica2 , ...>
--replication-factor <Integer:           The replication factor for each
  replication factor>                      partition in the topic being
                                           created. If not supplied, defaults
                                           to the cluster default.
--topic <String: topic>                  The topic to create, alter, describe
                                           or delete. It also accepts a regular
                                           expression, except for --create
                                           option. Put topic name in double
                                           quotes and use the '\' prefix to
                                           escape regular expression symbols; e.
                                           g. "test\.topic".
--topics-with-overrides                  if set when describing topics, only
                                           show topics that have overridden
                                           configs
--unavailable-partitions                 if set when describing topics, only
                                           show partitions whose leader is not
                                           available
--under-min-isr-partitions               if set when describing topics, only
                                           show partitions whose isr count is
                                           less than the configured minimum.
                                           Not supported with the --zookeeper
                                           option.
--under-replicated-partitions            if set when describing topics, only
                                           show under replicated partitions
--version                                Display Kafka version.
--zookeeper <String: hosts>              DEPRECATED, The connection string for
                                           the zookeeper connection in the form
                                           host:port. Multiple hosts can be
                                           given to allow fail-over.


Related[edit]

kafka-consumer-groups --list --bootstrap-server localhost:9092
kafka-console-producer

See also[edit]

Advertising: