0Pricing
Apache Kafka & Stream Processing Fundamentals · บทเรียน

เครื่องมือบรรทัดคำสั่งสำหรับ Kafka

เชี่ยวชาญการใช้เครื่องมือบรรทัดคำสั่งในตัวของ Kafka เพื่อจัดการหัวข้อ ตรวจสอบกลุ่มผู้ใช้ และดำเนินการอื่น ๆ

เครื่องมือบรรทัดคำสั่งสำหรับ Kafka เป็นบทเรียน Apache Kafka & Stream Processing Fundamentals ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Apache Kafka & Stream Processing Fundamentals และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Apache Kafka & Stream Processing Fundamentals มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Kafka CLI Tools: Your Admin Toolkit

Welcome! Kafka command-line interface (CLI) tools are essential for managing your Kafka cluster. They allow you to interact directly with brokers, topics, and consumer groups.

Mastering these tools is a crucial skill for any Kafka administrator or developer, enabling quick setup, debugging, and monitoring.

How to Use Kafka CLI Scripts

Kafka's CLI tools are shell scripts located in the bin/ directory of your Kafka installation. You typically execute them directly from your terminal.

Most commands follow a similar structure: bin/kafka-tool.sh --bootstrap-server <broker_address> --<action> [options].

Listing All Kafka Topics

The kafka-topics.sh tool is your primary utility for managing topics. Let's start by listing all topics currently available in your Kafka cluster.

The --list option does exactly that, showing you an overview of your data streams.

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

Creating New Topics

To store data, you need to create a topic. When creating one, you must specify its name, the number of partitions, and the replication factor.

  • Partitions: How many segments a topic is divided into. More partitions allow for greater parallelism.
  • Replication Factor: The number of copies of each partition kept across different brokers for fault tolerance.
bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic my_first_topic --partitions 1 --replication-factor 1

Inspecting Topic Details

Once a topic is created, you might want to check its configuration and status. The --describe option provides detailed information, including partition assignments, leader, and replica status.

bin/kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic my_first_topic

Deleting Topics

You can remove topics that are no longer needed. Be cautious, as deleting a topic will permanently remove all its data!

For topic deletion to work, ensure delete.topic.enable=true is set in your Kafka broker's configuration.

bin/kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic my_first_topic

Sending Messages from Console

The kafka-console-producer.sh tool lets you send messages directly from your terminal. It's perfect for quick tests or manually injecting data into a topic.

After running the command, simply type your message and press Enter to send it.

bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic my_first_topic

Receiving Messages from Console

To read messages from a topic, use kafka-console-consumer.sh. You can specify whether to read from the beginning of the topic or only new messages that arrive after the consumer starts.

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic my_first_topic --from-beginning

Managing Consumer Groups

Consumers typically operate within a "consumer group" to enable distributed message processing. The kafka-consumer-groups.sh tool is vital for inspecting and managing these groups.

You can use it to list all active consumer groups and check their offsets.

bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list

CLI Tool Quiz

You need to view the detailed configuration, including partitions, replication factor, leader, and replica assignments, for a Kafka topic named app_events. Which command-line option for kafka-topics.sh would you use?

Recap: Kafka CLI Power

You've learned how Kafka's command-line tools are indispensable for daily administration and quick interactions with your cluster. We covered:

  • Listing, creating, describing, and deleting topics using kafka-topics.sh.
  • Sending messages with kafka-console-producer.sh.
  • Receiving messages with kafka-console-consumer.sh.
  • Inspecting consumer groups with kafka-consumer-groups.sh.

These powerful tools are your first line of interaction for managing and monitoring Kafka!

คำถามที่พบบ่อย

บทเรียน “เครื่องมือบรรทัดคำสั่งสำหรับ Kafka” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “เครื่องมือบรรทัดคำสั่งสำหรับ Kafka” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Apache Kafka & Stream Processing Fundamentals ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Apache Kafka & Stream Processing Fundamentals มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “เครื่องมือบรรทัดคำสั่งสำหรับ Kafka”

เชี่ยวชาญการใช้เครื่องมือบรรทัดคำสั่งในตัวของ Kafka เพื่อจัดการหัวข้อ ตรวจสอบกลุ่มผู้ใช้ และดำเนินการอื่น ๆ คุณปฏิบัติ Apache Kafka & Stream Processing Fundamentals ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Apache Kafka & Stream Processing Fundamentals หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Apache Kafka & Stream Processing Fundamentals บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน

บทเรียน “เครื่องมือบรรทัดคำสั่งสำหรับ Kafka” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Apache Kafka & Stream Processing Fundamentals นี้ได้ไหม

ได้ บทเรียน Apache Kafka & Stream Processing Fundamentals ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. เครื่องมือบรรทัดคำสั่งสำหรับ Kafka
  2. การตรวจสอบ Kafka ด้วย JMX และเครื่องมือ
  3. ความปลอดภัย: การตรวจสอบสิทธิ์และการกำหนดสิทธิ์
  4. การติดตามและแจ้งเตือนความล่าช้าของผู้บริโภค
← กลับไปที่ Apache Kafka & Stream Processing Fundamentals