Karaf Practice Guide Kafka Install Karaf learn Kafka Help

Source: Internet
Author: User
Tags config zookeeper port number

Many of the company's products have in use Kafka for data processing, because of various reasons, not in the product useful to this fast, occasionally, their own to study, do a document to record:
This article is a Kafka cluster on a machine, divided into three nodes, and test peoducer, cunsumer in normal and abnormal conditions test: 1. Download and install Kafka

    > mkdir Kafka
    > CD kafka
    > Wget https://archive.apache.org/dist/kafka/0.8.0/kafka_2.8.0-0.8.0. tar.gz
    > TAR-XZVF kafka_2.8.0-0.8.0.tar.gz
    ok,kafka installation is complete, it is relatively simple.
2. Start a single-node zookeeper
    > $ nohup bin/zookeeper-server-start.sh config/zookeeper.properties &
3. Prepare to start a Kafka cluster of 3 broker nodes, so do the following configuration
    >CP config/server.properties config/server-1.properties 
    >cp config/server.properties config/ Server-2.properties
 Modify the following parameters as follows:
    Server-1.properties modified:
        config/server-1.properties:
        broker.id=1
        port=9093
        log.dir=/tmp/ Kafka-logs-1
    server-2.properties Modified:
        config/server-2.properties:
        broker.id=2
        port=9094
        Log.dir=/tmp/kafka-logs-2
    by the way:
        broker.id:broker node unique identity
        port:broker node uses port number
        LOG.DIR: Message directory Location
4. Start 3 broker Nodes
>jmx_port=9997 bin/kafka-server-start.sh config/server-1.properties &
>jmx_port=9998 bin/ kafka-server-start.sh config/server-2.properties &
>jmx_port=9999 bin/kafka-server-start.sh config/ Server.properties &

5. Create a topic and view

Bin/kafka-create-topic.sh–zookeeper Localhost:2181–replica 3–partition 1–topic 3test
Bin/kafka-list-topic.sh–zookeeper localhost:2181

6. Start Consumer & producer and enter some information in the console after producer startup

Bin/kafka-console-consumer.sh–zookeeper Localhost:2181–from-beginning–topic 3test
Messagea
Messageb
Messagec

>bin/kafka-console-producer.sh--broker-list localhost:9092,localhost:9093,localhost:9094--topic 3test
>messagea
>messageb
>messagec

Verification, Prodocer sent data in consumer is not able to consume normally.

Ok, configure the basic end, you can try to kill (Pkill-9-F server-1.properties), then you can continue to consume and production, to see if it can be normal.
By the way, check out topic:

Bin/kafka-list-topic.sh–zookeeper localhost:2181


End. qq:154833488

The following is an introduction to the official website:
Http://kafka.apache.org/07/quickstart.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.