Construction of Kafka cluster under Linux

Source: Internet
Author: User
Tags zookeeper

The previous log has been set up zookeeper cluster, see: http://www.cnblogs.com/lianliang/p/6533670.html, then continue to build Kafka cluster

1, first download Kafka GZ package: Http://kafka.apache.org/downloads

Unzip to/opt/soft/kafka/directory, unzip and create folder logs for Kafka log file

Go to the Kafka/config directory, modify the configuration file, Vim server.properties, the configuration that needs to be modified is:

#每台服务器的broker. ID is not the same

Broker.id=0

#在log. retention.hours=168 the following three additions

message.max.byte=5242880

Default.replication.factor=1

replica.fetch.max.bytes=5242880

#设置zookeeper的连接端口

zookeeper.connect=master:2181,slave1:2181

#日志文件的目录, set to the logs directory you just created

log.dirs=/opt/soft/kafka/logs/

Note: The broker.id in Salve1 is 1

Save after modification is complete, exit

2. Start Kafka cluster:

Execute start command: Kafka_2.11-0.10.1.1/bin/kafka-server-start.sh-daemon kafka_2.11-0.10.1.1/config/server.properties

Then execute the command: JPS, if printing

5709 Kafka
2850 Quorumpeermain
6056 Jps

Description Kafka Startup success

3, next Test whether production and consumption of information

Create a topic:bin/kafka-topics.sh--create--zookeeper master:2181--replication-factor 1--partitions 1--topic Lian

View topic:bin/kafka-topics.sh--list--zookeeper master:2181, if you can view the topic instructions just created topic success

Open the producer client: bin/kafka-console-producer.sh--broker-list master:9092--topic Lian

Enter a row of data in the console: this is a message

To open a consumer client on the slave1 machine: bin/kafka-console-consumer.sh--bootstrap-server slave1:9092--topic Lian--from-beginning

If you can receive the string you just entered: This is a message stating that the cluster was built successfully!

Construction of Kafka cluster under Linux

Related Article

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.