chia7712 commented on code in PR #925: URL: https://github.com/apache/kafka-site/pull/925#discussion_r4315020213
########## content/en/44/_index.md: ########## @@ -0,0 +1,28 @@ +--- +title: AK 4.3.X Review Comment: I will update the kafka repo as well ... ########## content/en/44/getting-started/quickstart.md: ########## @@ -0,0 +1,249 @@ +--- +title: Quick Start +description: Run Kafka locally, create a topic, produce and consume events, and explore Kafka Connect and Kafka Streams. +weight: 3 +tags: ['kafka', 'docs'] +aliases: +keywords: +type: docs +--- + +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + + +## Step 1: Get Kafka + +[Download](https://www.apache.org/dyn/closer.cgi?path=/kafka/4.3.0/kafka_2.13-4.3.0.tgz) the latest Kafka release and extract it: + +```bash +$ tar -xzf kafka_2.13-4.3.0.tgz +$ cd kafka_2.13-4.3.0 +``` + +## Step 2: Start the Kafka environment + +NOTE: Your local environment must have Java 17+ installed. + +Kafka can be run using local scripts and downloaded files or the docker image. + +### Using downloaded files + +Generate a Cluster UUID + +```bash +$ KAFKA_CLUSTER_ID="$(bin/kafka-storage.sh random-uuid)" +``` + +Format Log Directories + +```bash +$ bin/kafka-storage.sh format --standalone -t $KAFKA_CLUSTER_ID -c config/server.properties +``` + +Start the Kafka Server + +```bash +$ bin/kafka-server-start.sh config/server.properties +``` + +Once the Kafka server has successfully launched, you will have a basic Kafka environment running and ready to use. + +### Using JVM Based Apache Kafka Docker Image + +Get the Docker image: + +```bash +$ docker pull apache/kafka:4.3.0 +``` + +Start the Kafka Docker container: + +```bash +$ docker run -p 9092:9092 apache/kafka:4.3.0 +``` + +### Using GraalVM Based Native Apache Kafka Docker Image + +Get the Docker image: + +```bash +$ docker pull apache/kafka-native:4.3.0 +``` + +Start the Kafka Docker container: + +```bash +$ docker run -p 9092:9092 apache/kafka-native:4.3.0 +``` + +## Step 3: Create a topic to store your events + +Kafka is a distributed _event streaming platform_ that lets you read, write, store, and process [_events_](/documentation/#messages) (also called _records_ or _messages_ in the documentation) across many machines. + +Example events are payment transactions, geolocation updates from mobile phones, shipping orders, sensor measurements from IoT devices or medical equipment, and much more. These events are organized and stored in [_topics_](/{version}/getting-started/introduction/#main-concepts-and-terminology). Very simplified, a topic is similar to a folder in a filesystem, and the events are the files in that folder. + +So before you can write your first events, you must create a topic. Open another terminal session and run: + +```bash +$ bin/kafka-topics.sh --create --topic quickstart-events --bootstrap-server localhost:9092 +``` + +All of Kafka's command line tools have additional options: run the `kafka-topics.sh` command without any arguments to display usage information. For example, it can also show you [details such as the partition count](/{version}/getting-started/introduction/#main-concepts-and-terminology) of the new topic: + +```bash +$ bin/kafka-topics.sh --describe --topic quickstart-events --bootstrap-server localhost:9092 +Topic: quickstart-events TopicId: NPmZHyhbR9y00wMglMH2sg PartitionCount: 1 ReplicationFactor: 1 Configs: +Topic: quickstart-events Partition: 0 Leader: 0 Replicas: 0 Isr: 0 +``` + +## Step 4: Write some events into the topic + +A Kafka client communicates with the Kafka brokers via the network for writing (or reading) events. Once received, the brokers will store the events in a durable and fault-tolerant manner for as long as you need-even forever. + +Run the console producer client to write a few events into your topic. By default, each line you enter will result in a separate event being written to the topic. + +```bash +$ bin/kafka-console-producer.sh --topic quickstart-events --bootstrap-server localhost:9092 +>This is my first event +>This is my second event +``` + +You can stop the producer client with `Ctrl-C` at any time. + +## Step 5: Read the events + +Open another terminal session and run the console consumer client to read the events you just created: + +```bash +$ bin/kafka-console-consumer.sh --topic quickstart-events --from-beginning --bootstrap-server localhost:9092 +This is my first event +This is my second event +``` + +You can stop the consumer client with `Ctrl-C` at any time. + +Feel free to experiment: for example, switch back to your producer terminal (previous step) to write additional events, and see how the events immediately show up in your consumer terminal. + +Because events are durably stored in Kafka, they can be read as many times and by as many consumers as you want. You can easily verify this by opening yet another terminal session and re-running the previous command again. + +## Step 6: Import/export your data as streams of events with Kafka Connect + +You probably have lots of data in existing systems like relational databases or traditional messaging systems, along with many applications that already use these systems. [Kafka Connect](/documentation/#connect) allows you to continuously ingest data from external systems into Kafka, and vice versa. It is an extensible tool that runs _connectors_ , which implement the custom logic for interacting with an external system. It is thus very easy to integrate existing systems with Kafka. To make this process even easier, there are hundreds of such connectors readily available. + +In this quickstart we'll see how to run Kafka Connect with simple connectors that import data from a file to a Kafka topic and export data from a Kafka topic to a file. + +First, make sure to add `connect-file-4.3.0.jar` to the `plugin.path` property in the Connect worker's configuration. For the purpose of this quickstart we'll use a relative path and consider the connectors' package as an uber jar, which works when the quickstart commands are run from the installation directory. However, it's worth noting that for production deployments using absolute paths is always preferable. See [plugin.path](../../configuration/kafka-connect-configs/#connectconfigs_plugin.path) for a detailed description of how to set this config. Review Comment: ummm, we missed those parts ... I will update kafka repo soon ... @OmniaGM You could fix it manually -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
